Why std::is_integral returns false for decltype(*t) where t is int*?

106 Views Asked by At
#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?

1

There are 1 best solutions below

0
On BEST ANSWER

*t is an lvalue expression, then decltype(*t) leads to a reference type as int&.

b) if the value category of expression is lvalue, then decltype yields T&;

You might use std::remove_reference to get the result you expected. E.g.

is_integral<remove_reference_t<T>>::value

LIVE