Why is it disallowed for partial specialization in a non-type argument to use nested template parameters

前端 未结 2 1054
清歌不尽
清歌不尽 2020-12-03 00:33

I have this code

template
struct A;

template
struct A {
  /* ... */
};

// should work
A<25&g         


        
2条回答
  •  抹茶落季
    2020-12-03 01:25

    I think a lot of it is historical. Non-type template parameters weren't originally allowed at all. When they were added, there were lots of limitations. As people tried different possibilities, and confirmed that they didn't cause problems, some of the limitations were removed.

    Some of those original limitations remain for no particular reason beyond the fact that nobody bothered to work at changing them. Much like there, many of them can be worked around so removing them generally often wouldn't cause any particular difficulty. Mostly it comes down to a question of whether anybody cared enough about this particular case to write a paper about it.

提交回复
热议问题