I study type traits and type conversions (modification?), So I came across std::remove_reference. I tried to implement it as follows:
template <class T>
struct remove_reference { typedef T type; };
template <class T>
struct remove_reference<const T> { typedef const T type; };
template <class T>
struct remove_reference<T&> { typedef T type; };
template <class T>
struct remove_reference<const T&> { typedef const T type; };
Now when I use it:
remove_reference<int>::type x1;
remove_reference<const int>::type x2;
remove_reference<int&>::type x3;
remove_reference<const int&>::type x4;
I am using Visual Studio 2015 and it tells me what type x2and x4is is <type>, so what am I missing here?
Note:
- I do
{ typedef const T type }to remove the link and keep the constant ... - I do not know the standard implementation of the C ++ standard std :: remove_reference
Edit: There is nothing wrong with std :: remove_reference, I just do it for the sake of learning ...
Laith source
share