#include<iostream>
using namespace std;
int main() {
int* t;
using T = decltype(*t);
cout << is_integral<T>::value << endl;
return 0;
}
Why does the code above print 0?
#include<iostream>
using namespace std;
int main() {
int* t;
using T = decltype(*t);
cout << is_integral<T>::value << endl;
return 0;
}
Why does the code above print 0?
Copyright © 2021 Jogjafile Inc.
*t
is an lvalue expression, thendecltype(*t)
leads to a reference type asint&
.You might use
std::remove_reference
to get the result you expected. E.g.LIVE