0

type_traits

template<typename _Tp>
    struct remove_reference
    { typedef _Tp   type; };

template<typename _Tp>
    struct remove_reference<_Tp&>
    { typedef _Tp   type; };

template<typename _Tp>
    struct remove_reference<_Tp&&>
    { typedef _Tp   type; };

They do the same thing, so why do we need template specialization there?

Kanony
  • 509
  • 2
  • 12
  • 1
    It's in the name right, `remove_reference` ... – Mansoor Feb 02 '21 at 21:06
  • I'm not sure what you mean. They don't do the same thing. They are specialized for reference and rvalue references to remove the references from the types. – Kevin Feb 02 '21 at 21:07
  • They don't do the same thing, they remove reference by converting referenced type into a raw one (T& -> T, T&& -> T). – Dmitry Feb 02 '21 at 21:07

0 Answers0