Vote count:
0
In the code below, I passed both class type R and a constant expression of that type as template parameters. But clang doesn't accept that:
#include <iostream>
template<class T, T t>
void foo(){ std::cout << "foo()" << std::endl; }
class R
{
public:
int f;
constexpr R(): f(15){ }
};
constexpr R r;
int main(){ foo<R, r>(); } //note: candidate template ignored:
//invalid explicitly-specified argument
//for template parameter 't'
In N4296::14.3.2 [temp.arg.nontype] I can't find any restriction other than the non-type template parameter should be a constant expression.
asked 45 secs ago
How can we use a variable of a type of a template parameter?
Aucun commentaire:
Enregistrer un commentaire