Is substitution failure an error with dependent non-type template parameters?

后端 未结 1 978
轻奢々
轻奢々 2021-02-14 11:35

Let\'s say I have these template aliases:

enum class enabler {};

template 
using EnableIf = typename std::enable_if::         


        
相关标签:
1条回答
  • 2021-02-14 12:00

    First and foremost, thanks to @Richard Smith on the #llvm IRC Channel on oftc for the explanation.
    Unfortunately, this is not legal C++ and as such Clang is correct: {} is not an expression but a braced-init-list and as such will never be a constant expression as is needed in the initializer of a non-type template parameter.

    §14.3.2 [temp.arg.non-type] p1

    A template-argument for a non-type, non-template template-parameter shall be one of:

    • for a non-type template-parameter of integral or enumeration type, a converted constant expression (5.19) of the type of the template-parameter; or
    • [...]

    One solution would be a dummy value in enabler.

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