Quantcast
Channel: Intel® Software - Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1175

[Bug report] Compiler error for nested template parameter deduction

$
0
0

Dear all,

a minimal example of the code I was trying to compile is

 #include <type_traits>

 template <bool... Values> struct BoolStorage;

 template <bool... Values>
 struct all_true
 {
   static constexpr bool value = std::is_same<BoolStorage<Values..., true>,
                                              BoolStorage<true, Values...>>::value;
 };

 template <bool... Values>
 struct enable_if_all : std::enable_if<all_true<Values...>::value> {};

 template <int dim>
 class FiniteElement
 {};

 template <int dim>
 class FESystem
 {
   public:
   template <class... FEPairs,
                      typename = typename enable_if_all<(std::is_same<typename std::decay<FEPairs>::type,
                                                                                           FiniteElement<dim>*>::value)...>::type>
   FESystem(FEPairs &&... fe_pairs)
   {}
 };

 int main()
 {
   FiniteElement<2> fe;
   FESystem<2> fe_system(&fe, &fe);
 }

This should be C++11 compliant but I get the following errors with ICC18:

test_fe_system_constructor.cc(34): error: no instance of constructor "FESystem<dim>::FESystem [with dim=2]" matches the argument list
            argument types are: (FiniteElement<2> *, FiniteElement<2> *)
    FESystem<2> fe_system(&fe, &fe);
                          ^
test_fe_system_constructor.cc(20): note: this candidate was rejected because mismatch in count of arguments
  class FESystem
        ^
test_fe_system_constructor.cc(20): note: this candidate was rejected because mismatch in count of arguments
  class FESystem
        ^
test_fe_system_constructor.cc(27): note: this candidate was rejected because at least one template argument could not be deduced
    FESystem(FEPairs &&... fe_pairs)
    ^

compilation aborted for test_fe_system_constructor.cc (code 2)

Best,

Daniel


Viewing all articles
Browse latest Browse all 1175

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>