Type qualifier traits¶
Traits related to cv (const and volatile)
type qualifiers,
as well as reference declaration.
Reference¶
Detection traits¶
#include <actl/meta/qualifiers/detection.hpp>
-
template<typename T>
bool ac::is_cv_v = std::is_const_v<T> && std::is_volatile_v<T>¶ Checks if the type has both
constandvolatilequalifiers.
-
template<typename T>
bool ac::has_qualifiers_v = std::is_reference_v<T> || std::is_const_v<T> || std::is_volatile_v<T>¶ Checks if the type has any of
const,volatileor reference qualifiers.
See tests at tests/meta/qualifiers/detection.cpp
Qualifiers copy between types¶
Traits that replace type qualifiers with the ones from the source type.
Table below shows the effect of different source types
on the following destination types: int, int const, int&.
It’s important to understand the behavior of a referenced type qualifiers.
Unless ac::copy_cvref_t is used:
Referenced type qualifiers of a source type don’t affect the result.
Referenced type qualifiers of a destination type are not changed.
Expression |
unqualified |
cv-qualified |
l-value ref |
r-value ref |
|---|---|---|---|---|
Source type S |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Note
Boost.TypeTraits, for example, boost::copy_reference, don’t remove existing qualifiers and only add new ones. Our copy is different and instead fully replaces qualifiers, because this behavior is consistent with data copy.
#include <actl/meta/qualifiers/copy.hpp>
-
template<typename Target, typename Source>
using ac::copy_const_t = typename copy_const<Target, Source>::type¶
-
template<typename Target, typename Source>
using ac::copy_volatile_t = typename copy_volatile<Target, Source>::type¶
-
template<typename Target, typename Source>
using ac::copy_cv_t = typename copy_cv<Target, Source>::type¶
-
template<typename Target, typename Source>
using ac::copy_reference_t = typename copy_reference<Target, Source>::type¶
-
template<typename Target, typename Source>
using ac::copy_cvref_t = typename copy_cvref<Target, Source>::type¶
See tests at tests/meta/qualifiers/copy.cpp
Inner qualifiers modification¶
Traits that add or remove type qualifiers. If the type is a reference, then the referenced type is modified.
Trait name |
Non-reference |
Reference |
|---|---|---|
Input type |
|
|
|
|
|
|
|
|
|
|
|
Trait name |
Non-reference |
Reference |
|---|---|---|
Input type |
|
|
|
|
|
|
|
|
|
|
|
#include <actl/meta/qualifiers/inner.hpp>
See tests at tests/meta/qualifiers/inner.cpp