Mam problem z użyciem
static_assert
o to fragment kodu:
template <typename T1, typename T2>
class Unit
{
T1 papryka;
T2 rower;
public:
Unit(T1 p, T2 r) : papryka(p), rower(r)
{
static_assert(sizeof(int)!=sizeof(int), "LOL"); //TUTAJ!
}
T2 fun2();
T1 fun()
{
cout<<sizeof(T1)<<endl;
}
};
template<typename T1, typename T2>
T2 Unit<T1,T2>::fun2()
{
cout<<sizeof(T2)<<endl;
}
Blad zglaszany przez kompilator gcc v 4.8.4:
cp4.cpp: In constructor ‘Unit<T1, T2>::Unit(T1, T2)’:
cp4.cpp:15:47: error: there are no arguments to ‘static_assert’ that depend on a template parameter, so a declaration of ‘static_assert’ must be available [-fpermissive]
static_assert(sizeof(int)!=sizeof(int), "LOL");
^
cp4.cpp:15:47: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
Czy ktoś wie czym spowodowany jest ten błąd?