Get base type of a template type (remove const/reference/etc.)

后端 未结 3 1542
天涯浪人
天涯浪人 2021-02-19 09:45

Is there a type traits template which returns the base type of a given type. By base type I mean the type with all value modifiers, const, volatile, etc. strip

3条回答
  •  清酒与你
    2021-02-19 10:15

    I would probaby define a type alias such as:

    template
    using base_type = typename std::remove_cv::type>::type;
    

    Notice, that here R. Martinho Fernandes proposes the name Unqualified for such a type alias.

    The standard type trait std::decay, on the other hand does the same as the above and something more for array and function types, which may or may not be what you want.

提交回复
热议问题