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

后端 未结 3 1545
天涯浪人
天涯浪人 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:11

    Obviously it depends on what exactly you want to remove from the type. std::decay could be what you are looking for (removes references, const/volatile, decays array to pointer and function to function pointer). If you don't want the array to pointer and function to functionpointer decay, you need to stick with std::remove_reference and std::remove_cv (removes const and volatile). Of course you could combine the two into your own typetrait to make using it easier.

提交回复
热议问题