variadic function template without formal parameters

后端 未结 3 1989
無奈伤痛
無奈伤痛 2021-01-05 01:00

This is what I\'m trying to do:

// base case
void f() {}

template 
void f() {
             


        
3条回答
  •  难免孤独
    2021-01-05 01:58

    Since c++20 you can use constraints to functions, instead of SFINAE.

    template 
    requires (sizeof...(Ts) == 0)
    void f(){}
    
    template 
    void f() {
        // do something with T
        f();
    }
    

提交回复
热议问题