我有一些代码。
#include <iostream>
template<typename T>
struct Test
{
   Test(bool v):flg(v) { }
   void func() { }
   typedef void (Test::*unspecified)();
   operator unspecified() const
   {
      return flg ? &Test::func : 0;
   }
   bool flg;
};
template<typename T>
std::ostream& operator << (std::ostream&, typename Test<T>::unspecified);
int main()
{
   Test<int> t(true);
   std::cout << t << std::endl;
}
输出是
1
它工作正常,但我想获得未定义的参考。如果Test是not template class我得到未定义的参考。那么,为什么编译器不使用operator <<函数类型并从pointer to class-memberto进行标准转换bool?