Explicitly use defaults for some parameters in class template instantiation

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

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

template

        
4条回答
  •  广开言路
    2021-02-18 14:56

    I came across this issue again and came up with a more general version of Sebastian Redl's solution.

    //given an index to replace at, a type to replace with and a tuple to replace in
    //return a tuple of the same type as given, with the type at ReplaceAt set to ReplaceWith
    template 
    auto replace_type (std::index_sequence, std::tuple)
        -> std::tuple...>;
    
    //instantiates a template with the types held in a tuple
    template