Here's a trick, so you can make the compiler to print a type:
template <typename>
struct TD;
Then use:
TD<decltype(myWidget1)>();
As TD<...>
is an incomplete type, the compiler will complain, and will print your type in the error message:
error: invalid use of incomplete type
struct TD<Widget>
So myWidget1
's type is Widget
.
Type of myWidget2
:
error: invalid use of incomplete type
struct TD<const Widget&>
So its type is indeed const Widget &
, as you suspected.
So yes, what you've described is right.