Perché questo codice produce un'uscita falsa?Funzione template is_same nelle classi template
//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;
}
uscita:
$ g++ -std=c++11 this-type.cpp
$ ./a.out
false
Il tipo di "* questo" dentro da A a B è un < int>, non è vero?
Poi, il tipo completo di 'questo' che cos'è, 'A e * questo'? –
Sicuramente non ovvio. –
L'ultima riga non funziona per me. Il mio output è 'false', 'true', 'false' (g ++ (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2) –