Reputation: 1389
Basically I want to this:
template<typename TYPE>
struct not_rvalue_reference{
typedef std::conditional_t<std::is_rvalue_reference_v<TYPE>, std::remove_reference_t<TYPE>, TYPE> type;
};
template<typename TYPE>
using not_rvalue_reference_t = typename not_rvalue_reference<TYPE>::type;
So for what ever type, I would get either a non reference type or a lvalue reference type.
And I was wondering if such thing exists in the standard library, and if not and I have to use this, what is the best name for it?
Upvotes: 0
Views: 148
Reputation: 781
Consulting the cppreference documentation for <type_traits>, it appears that there is not such a tool in the standard library. I agree with the commenter 康桓瑋 that remove_rvalue_reference
is a good name for this. To reduce template instantiation overhead, I would recommend a more direct implementation:
template<typename T>
struct remove_rvalue_reference
{
using type = T;
};
template<typename T>
struct remove_rvalue_reference<T&&>
{
using type = T;
};
template<typename T>
using remove_rvalue_reference_t = remove_rvalue_reference<T>::type;
Upvotes: 1