C++1y/C++14: Variable Template Specialization?

后端 未结 4 2025
[愿得一人]
[愿得一人] 2020-12-13 18:02

According to C++1y/C++14 N3690, does the type of a variable template specialization have to be the same as the type of the primary template?

template

        
4条回答
  •  一生所求
    2020-12-13 18:50

    The following compiles with clang trunk -std=c++1y:

    #include 
    
    template
    char y = 3;
    
    template<>
    double y<42> = 2.5;
    
    char c {y<17>};
    
    double d {y<42>};
    

    So either a specialization of a variable template doesn't need to have the same type as its primary, or clang has a buggy implementation of N3690

提交回复
热议问题