Non-type variadic function templates in C++11

前端 未结 5 1456
有刺的猬
有刺的猬 2020-12-05 23:48

I saw a blog post which used non-type variadic templates (currently not supported by gcc, only by clang).

template 
stru         


        
5条回答
  •  甜味超标
    2020-12-06 00:22

    This will print out all elements, get max could be implemented similarly

    template 
    void foo(){
      cout << N << endl;
    }
    
    template 
    void foo(){
      cout << N << endl;
      foo();
    }
    
    
    int main(){
      foo<1, 5, 7>();
    
      return 0;
    }
    

提交回复
热议问题