What is the correct process to pass a standard type traits qualified type as an argument to a template class?
I have the following (rather useless but useful to depict my problem) program that qualifies a type via standard type traits before passing to a template class.
#include <iostream>
#include <type_traits>
#include <vector>
template <typename T>
struct is_foo
{
static bool const value = true;
};
template<
typename Ty,
bool foo = is_foo<std::remove_reference<Ty>::type>::value
>
struct bar {
static bool const value = true;
};
int main() {
int elem;
std::cout << bar<decltype(elem)>::value << std::endl;
return 0;
}
This program compiles fine with VC12 but fails to compile with g++ 4.8 with the following error
prog.cpp:11:51: error: type/value mismatch at argument 1 in template parameter list for ‘template<class T> struct is_foo’
bool foo = is_foo<std::remove_reference<Ty>::type>::value
^
prog.cpp:11:51: error: expected a type, got ‘std::remove_reference< <template-parameter-1-1> >::type’
prog.cpp: In function ‘int main()’:
prog.cpp:18:33: error: template argument 2 is invalid
std::cout << bar<decltype(elem)>::value << std::endl;
^
Any idea what might be wrong with my code?