Here is my code:
#include <iostream>
class c{
public:
int y;
c(int x,int p):y(x){
std::cout<<"has been made"<<std::endl;
}
};
template<int x,typename B = void>
struct checkeven{
};
template<typename B>
struct checkeven<0,B>{
typedef B type;
};
template<int x,int y,class = typename checkeven<x%2,int>::type>
struct t{
static const c tee;
static const inline c& initor(){
return tee;
}
};
template<int x,int y>
const c t<x,y>::tee(x,y);
int main(int argc, char** argv) {
return 0;
}
I tried to study it, but I can not find anything but a suggestion to remove the duplicate by default. I want to implement SFINAE to make sure that the first value is an even number. I have a static constant variable that I want to initialize. It worked perfectly without my default class, but as soon as I added it, everything became messy. How to initialize my constant static member? I would also like to know why my code is not working.
source
share