Explicitly use defaults for some parameters in class template instantiation

后端 未结 4 1745
囚心锁ツ
囚心锁ツ 2021-02-18 14:42

A class template can have multiple parameters that all have defaults.

template

        
4条回答
  •  臣服心动
    2021-02-18 15:11

    There isn't a way to reuse the default parameters directly. You can use Floris's comment as a way to provide shorthands for common uses, but the template alias will still repeat the defaults.

    Alternatively, the options struct could be set up to allow switching out parameters:

    template 
    struct options {
      template 
      using WithT0 = options;
      template 
      using WithT1 = options;
      template 
      using WithStringT = options;
    };
    

    And then use it as

    options<>::WithT1::WithStringT
    

提交回复
热议问题