为什么此代码会产生错误输出?模板类中的模板函数is_same
//this-type.cpp
#include <iostream>
#include <type_traits>
using namespace std;
template<typename testype>
class A
{
public:
A()
{
cout << boolalpha;
cout << is_same<decltype(*this), A<int>>::value << endl;
}
};
class B : public A<int>
{
};
int main()
{
B b;
}
输出:
$ g++ -std=c++11 this-type.cpp
$ ./a.out
false
类型的 “*这种” 内部的通过B是A < int>的,是吗?
然后,完全型的 '本'什么是'A&*这'? –
虽然不是很明显。 –
最后一行对我不起作用。我的输出是'false','true','false'(g ++(Ubuntu/Linaro 4.7.2-2ubuntu1)4.7.2) –