Equivalent of `using` aliases for `template`s

前端 未结 1 1352
执笔经年
执笔经年 2021-01-12 10:00

C++11 added alias templates such as:

 template using identity = T;
 template using EnableIf = typename std         


        
1条回答
  •  臣服心动
    2021-01-12 10:43

    Best way I know to remove template is made simple warper that will do it for you:

    template
    using apply = typename Meta::template Template;
    

    and every where you previously used template class Template replace it with typename Meta.

    template
    void do_more_stuff()
    {
        apply::func(); //=== Meta::template Template::func();
    }
    
    template
    void do_stuff() {
      do_more_stuff< my_meta >();
      do_more_stuff< my_meta >();
    };
    

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