alias template not recognized by is_same

145 views
Skip to first unread message

Oliver Rosten

unread,
Dec 5, 2017, 5:21:12 PM12/5/17
to std-dis...@isocpp.org
template<class T> struct component {};

template<class T> using alias = component<T>;

template<class T, class C> struct thing {};
      
template<class T, template<class> class C> struct thing2 {};   


static_assert(std::is_same_v<thing<int, component<int>>, thing<int, alias<int>>>); 
// succeeds

static_assert(std::is_same_v<thing2<int, component>, thing2<int, alias>>); 
// fails on both gcc and clang

I can't think of any good reason why the second assert should fail, but perhaps I've missed something!

Todd Fleming

unread,
Dec 5, 2017, 6:30:20 PM12/5/17
to ISO C++ Standard - Discussion
alias<T> and component<T> are the same type. However, alias and component are separate templates. That makes thing2<int, component> and thing2<int, alias> separate types.

Todd

Christof Meerwald

unread,
Dec 6, 2017, 2:18:00 AM12/6/17
to 'Oliver Rosten' via ISO C++ Standard - Discussion
On Tue, Dec 05, 2017 at 10:21:09PM +0000, 'Oliver Rosten' via ISO C++ Standard - Discussion wrote:
> template<class T> struct component {};
>
> template<class T> using alias = component<T>;

see CWG issue 1286
https://wg21.cmeerw.net/cwg/issue1286


Christof

--

http://cmeerw.org sip:cmeerw at cmeerw.org
mailto:cmeerw at cmeerw.org xmpp:cmeerw at cmeerw.org
Reply all
Reply to author
Forward
0 new messages