Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test if std::remove_cvref is defined in the standard library?

I don't see anything resembling feature test macro for it in here: https://en.cppreference.com/w/cpp/utility/feature_test

Neither it does not seem to be mentioned in the original paper: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0550r2.pdf

Testing for __cplusplus is also not appropriate since C++20 is not yet published but this feature could already be supported.

Could feature-test macro support appear later during standardization or is this addition too small to become part of feature-test macro and thus people who want to use the standard version conditionally are bound to get back to old school manual compiler version checking?

like image 645
Predelnik Avatar asked Jul 17 '19 09:07

Predelnik


1 Answers

Looking through [tab:cpp.predefined.ft], I don't see anything possibly related to it either. Presumably because this feature is deemed to minor and t is very easy to implement one yourself:

template <typename T>
struct remove_cvref :remove_cv<remove_reference_t<T>> {};

template <typename T>
using remove_cvref_t = typename remove_cvref<T>::type;

If you are just trying to write portable code, it suffices to roll out your own version. If you are genuinely try to detect the availability of this feature, you may have to resort to the "old school manual compiler version checking", unfortunately.

like image 50
L. F. Avatar answered Nov 18 '22 21:11

L. F.