decltype(entity)
specifies the declared type of the entity
specified by this expression.
Due to the constexpr
, (A constexpr
specifier used in an object declaration implies const
), your cv
variable is of type const uint16_t
.
You know that const uint16_t
is different from uint16_t
then your line:
static_assert( std::is_same< uint16_t, decltype(cv)>::value, "!");
fail as this is expected.
The line
constexpr uint16_t foo(){ return 0;}
specifies that the function foo
can be evaluated at compile time but the function still returns a uint16_t
. That why on the line
auto v = foo();
v
is of type uint16_t
then the line
static_assert( std::is_same< uint16_t, decltype(v) >::value, "!");
works as expected too.