Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

decltype("a")

26 views
Skip to first unread message

nice...@gmail.com

unread,
Dec 26, 2015, 3:34:17 AM12/26/15
to
1) What is the type of "a"? Is it const char [2]?

2) What is the type of decltype("a") ???
How does one get the following to compile and run without asserting?


#include <iostream>
#include <cassert>

int main()
{
assert((std::is_same<
decltype("a"),
???? /* const char [2] */
>::value));
return 0;
}





Thanks.

nice...@gmail.com

unread,
Dec 26, 2015, 3:38:46 AM12/26/15
to
Ah I figured it out. One needs to watch out for references when using decltype!


#include <cassert>

int main()
{
assert((std::is_same<decltype("a"), const char (&)[2]>::value));
return 0;
}

nice...@gmail.com

unread,
Dec 26, 2015, 3:42:31 AM12/26/15
to
Header <type_traits> is needed also.


#include <type_traits>
0 new messages