I'm using clang on mac and having:
$cat my.cpp
#include<type_traits>
using namespace std;
template<int i>
struct place_holder{};
place_holder<1> _1;
place_holder<2> _2;
template<typename T>
struct is_placeholder:public integral_constant<int,0>{};
template<int i>
struct is_placeholder<place_holder<i> >:public integral_constant<int,i>{};
template<typename T>
int check(T&& t){
return is_placeholder<t>()::value;
}
int main(){
int i=check<_1>();
return 0;
}
The last line failed to compile:
my.cpp:13:27: error: template argument for template type parameter must be a type
return is_placeholder<t>()::value;
^
my.cpp:7:19: note: template parameter is declared here
template<typename T>
^
my.cpp:16:11: error: no matching function for call to 'check'
int i=check<_1>();
^~~~~~~~~
my.cpp:12:5: note: candidate function template not viable: requires single argument 't', but no arguments were
provided
int check(T&& t){
^
2 errors generated.
Really odd, my "struct is_placeholder" is really a template, right? Why it say it's not?
How to correct my program? Thanks!