Reputation: 51
Quick question for the folks out there. I have the function signature below that under some but not all circumstances returns a const type qualifier on the return type.
template <typename U,
typename V,
std::enable_if_t<std::is_arithmetic<V>::value, int>/* = 0*/ > // SFINAE dummy
Vector3D<decltype(std::declval<U>() / std::declval<V>())> operator/ (const Vector3D<U>& p_vector, const Matrix3D<V>& p_matrix)
How can I use const_cast
to remove any const qualifiers returned by decltype(std::declval<U>() / std::declval<V>())
?
Upvotes: 0
Views: 624
Reputation: 75717
The answer is std::remove_const
:
template <typename U,
typename V,
std::enable_if_t<std::is_arithmetic<V>::value, int>/* = 0*/ > // SFINAE dummy
Vector3D<std::remove_const_t<decltype(std::declval<U>() / std::declval<V>())>>
operator/ (const Vector3D<U>& p_vector, const Matrix3D<V>& p_matrix)
If U/V
might return a reference you might want std::remove_cvref
instead.
Upvotes: 2