A
Aarti
I was trying my hand on a template class and i am getting a
compilation error
error C2146: syntax error : missing ';' before identifier
'isOptimizedImplAvailable'. Any pointers would be of great help.
Here is my code
#include <iostream>
using namespace std;
template<typename T>
class foo_traits
{
public:
static bool customImpl;
};
template<>
class foo_traits<int>
{
public:
static bool customImpl;
};
template<>
class foo_traits<char>
{
public:
static bool customImpl;
};
bool foo_traits<char>::customImpl = false;
bool foo_traits<int>::customImpl = true;
template<typename T>
class foo
{
public:
typename foo_traits<T>::customImpl isOptimizedImplAvailable()
{
return foo_traits<T>::customImpl;
}
};
int main()
{
foo<int> f;
}
compilation error
error C2146: syntax error : missing ';' before identifier
'isOptimizedImplAvailable'. Any pointers would be of great help.
Here is my code
#include <iostream>
using namespace std;
template<typename T>
class foo_traits
{
public:
static bool customImpl;
};
template<>
class foo_traits<int>
{
public:
static bool customImpl;
};
template<>
class foo_traits<char>
{
public:
static bool customImpl;
};
bool foo_traits<char>::customImpl = false;
bool foo_traits<int>::customImpl = true;
template<typename T>
class foo
{
public:
typename foo_traits<T>::customImpl isOptimizedImplAvailable()
{
return foo_traits<T>::customImpl;
}
};
int main()
{
foo<int> f;
}