我hava重载了流操作符&lt;&lt;对于新模板类型X<T>
,这是有效的。但是,如果我用身份函数identity<X<T>>::type
包装该类型,代码就会中断。
我试过gcc 4.6.2 / gcc 4.8.1 / clang 3.3
任何提示?
#include <iostream>
template <typename T>
struct ebenso // because I could not find std::identity, any hint?
{
typedef T type;
};
template <typename T>
struct X
{
T value;
};
template<typename T>
inline std::ostream &
operator << (std::ostream& stream, typename ebenso< X<T> >::type const & x)
{
return stream << x.value << std::endl;
}
int main ()
{
X<int> x;
x.value = 7;
std::cout << x << std::endl; // The overload is not found
}