Equality of template aliases

后端 未结 1 1141
情话喂你
情话喂你 2021-01-04 13:34

I try to create template alias which cannot be distinguished from original.

So, I create traits to check when 2 templates (not types) are equal:

temp         


        
相关标签:
1条回答
  • 2021-01-04 14:24

    I try to create template alias which cannot be distinguished from original.

    I don't think this is currently possible. There are (unfortunately) no template aliases, there are only alias templates. And an alias template is always a template of its own [temp.alias]/1. A specialization of an alias template is equivalent to the type you get by substituting the template arguments into the alias template, but the alias template itself is not an alias for another template [temp.alias]/2. I would consider GCC letting your second static_assert pass a bug in GCC…

    As pointed out by @HolyBlackCat in the comment above, there is a related question and answer which points to numerous related CWG issues. One issue in particular (CWG 1286) would seem to suggest that there is desire to allow an alias template to itself be equivalent to the template it refers to under certain circumstances. However, it does not seem that the proposed resolution has been adopted due to concerns raised later. The relevant wording in the current standard draft ([temp.alias] and [temp.type]) appears to be unchanged from C++11…

    0 讨论(0)
提交回复
热议问题