SUNphi
1.0
|
Defines convenient adaptation of the std type_traits library, and extensions useful for the expression handling. More...
Go to the source code of this file.
Macros | |
#define | NON_CONST_QUALIF |
Empty token to be used in macro expecting qualifier. | |
#define | CONST_QUALIF const |
Token to be used in macro indicating "const" keyword. | |
#define | NON_REF |
Empty token to be used in macro expecting the kind of reference. | |
#define | LVALUE_REF & |
Token to be used in macro indicating "l-value" reference. | |
#define | RVALUE_REF && |
Token to be used in macro indicating "r-value" reference. | |
#define | FORBID_CONSTRUCT_BY_COPY(CLASS) |
Delete the copy-constructor. More... | |
#define | STATIC_ASSERT_ARE_SAME(...) static_assert(areSame<__VA_ARGS__>,"Error, types are not the same") |
Assert if types are not the same. | |
#define | CALL_CLASS_CONST_METHOD_REMOVING_CONST(...) asMutable(std::as_const(*this).__VA_ARGS__) |
Call a const method removing any const qualifier. | |
#define | PROVIDE_ALSO_NON_CONST_METHOD(NAME) |
#define | STATIC_ASSERT_IS_BASE_OF(BASE, DERIVED) static_assert(isBaseOf<BASE,DERIVED>,"Error, type not derived from what expected") |
Static assert if DERIVED does not derive from BASE. | |
#define | STATIC_ASSERT_IS_NOT_BASE_OF(BASE, DERIVED) static_assert(not isBaseOf<BASE,DERIVED>,"Error, type derived from what not expected") |
Static assert if DERIVED does derive from BASE. | |
#define | STATIC_ASSERT_ARE_N_TYPES(N, UNEXP_PARPACK) static_assert(N==sizeof...(UNEXP_PARPACK),"Error, expecting a different number of types") |
Static assert if not passing exactly N types. | |
#define | STATIC_ASSERT_IS_FLOATING_POINT(T) static_assert(isFloatingPoint<T>,"Error, type is not a floating point") |
Static assert if the type T is not a floating-point. | |
#define | STATIC_ASSERT_IS_INTEGRAL(T) static_assert(isIntegral<T>,"Error, type is not an integral") |
Static assert if the type T is not an integer-like. | |
#define | STATIC_ASSERT_ARE_INTEGRALS(...) static_assert(areIntegrals<__VA_ARGS__>,"Error, types are not all an integral") |
Static assert if the types T are not an integer-like. | |
#define | PROVIDE_ENABLE_IF_FOR(TYPE, ...) |
#define | PROVIDE_ENABLE_IF_FOR_IS_TYPE(TYPE) |
Provides an EnableIf with the given name if isTYPE exists. More... | |
#define | PROVIDE_ENABLE_IF_FOR_TYPE(TYPE) |
Provides an EnableIf with the given type. More... | |
#define | DEFINE_BASE_TYPE(TYPE, ...) |
#define | STATIC_ASSERT_HAS_MEMBER(TAG, ...) static_assert(hasMember_ ## TAG<__VA_ARGS__>,"Type does not have member " #TAG) \ |
#define | DEFINE_HAS_MEMBER(TAG) |
#define | DEFINE_BINARY_OPERATOR_IMPLEMENTATION_CHECK(CHECK_NAME, STRUCT_NAME, OPERATOR) |
Check that the binary operator exists. More... | |
#define | DEFINE_IS_THE_TEMPLATED_CLASS(CLASS) |
Provides a check returning whether the class is of a given kind. More... | |
Typedefs | |
using | SUNphi::TrueType = std::true_type |
using | SUNphi::FalseType = std::false_type |
template<bool B, typename T = void> | |
using | SUNphi::EnableIf = typename _EnableIf< B, T >::type |
template<bool B> | |
using | SUNphi::VoidIf = EnableIf< B > |
template<bool B, typename T > | |
using | SUNphi::TypeIf = EnableIf< B, T > |
template<bool B, typename T , typename F > | |
using | SUNphi::Conditional = typename _Conditional< B, T, F >::type |
template<typename T > | |
using | SUNphi::RemRef = typename std::remove_reference< T >::type |
Returns the type T without any reference. | |
template<bool B, typename _T , typename T = RemRef<_T>> | |
using | SUNphi::RefIf = Conditional< B, T &, T > |
Returns reference of plain type depending on condition. | |
template<typename T > | |
using | SUNphi::RemoveCV = typename std::remove_cv< T >::type |
Returns the type T without any constant volatile qualification. | |
template<bool B, typename _T , typename T = RemoveCV<_T>> | |
using | SUNphi::ConstIf = Conditional< B, const T, T > |
Returns const or non const T depending on condition. | |
template<typename T > | |
using | SUNphi::Unqualified = RemoveCV< RemRef< T >> |
Returns the type T without any reference or qualifier. | |
template<typename T > | |
using | SUNphi::Fundamental = decltype(fundamentalHelper< T >()) |
Returns the type T without any reference or qualifier or pointer. | |
template<typename F > | |
using | SUNphi::AddPointer = std::add_pointer_t< F > |
Returns a pointer-version of F. | |
template<typename F > | |
using | SUNphi::AddPointerIfFunction = Conditional< isFunction< F >, AddPointer< F >, F > |
Returns F or F* if F is not a function. | |
template<typename T > | |
using | SUNphi::SignedOf = RefIf< isLvalue< T >, std::make_signed_t< RemRef< T >>> |
Returns the signed version of the passed type. | |
template<typename T > | |
using | SUNphi::UnsignedOf = RefIf< isLvalue< T >, std::make_unsigned_t< RemRef< T >>> |
Returns the unsigned version of the passed type. | |
Functions | |
template<typename T = void, typename... Tail> | |
constexpr bool | SUNphi::_areSame () |
template<typename T > | |
constexpr auto | SUNphi::fundamentalHelper () |
template<typename T > | |
constexpr T & | SUNphi::asMutable (const T &v) noexcept |
template<typename Type > | |
constexpr bool | SUNphi::hasMember_beginHelper () |
template<typename Type > | |
constexpr bool | SUNphi::hasMember_sizeHelper () |
template<typename Type > | |
constexpr bool | SUNphi::hasMember_resizeHelper () |
template<typename Type > | |
constexpr bool | SUNphi::hasMember_endHelper () |
template<typename T > | |
constexpr bool | SUNphi::canBeGet () |
Check if the class T can be get. | |
Variables | |
template<typename T > | |
static constexpr bool | SUNphi::isClass |
Checks if a type is a class. More... | |
template<typename From , typename To > | |
static constexpr bool | SUNphi::canBeConverted |
Checks if a type can be cast into another one. More... | |
template<typename T > | |
static constexpr bool | SUNphi::isTriviallyCopyable |
Checks if an object can be trivially copied. More... | |
template<typename T1 , typename T2 > | |
static constexpr bool | SUNphi::isSame |
template<typename T > | |
static constexpr bool | SUNphi::isSame< T, T > |
template<typename... Ts> | |
constexpr bool | SUNphi::areSame |
template<typename T > | |
constexpr bool | SUNphi::isLvalue |
Check if the type is lvalue reference. More... | |
template<typename T > | |
constexpr bool | SUNphi::isRvalue |
Check if the type is rvalue reference. More... | |
template<typename _T , typename T = RemRef<_T>> | |
constexpr bool | SUNphi::isConst |
template<typename T > | |
static constexpr bool | SUNphi::isPointer |
Checks if it is pointer. More... | |
template<typename Base , typename Derived > | |
constexpr bool | SUNphi::isBaseOf |
Identifies whether Base is a base class of Derived. More... | |
template<typename F > | |
constexpr bool | SUNphi::isFunction |
Returns whether the passed argument is a function. More... | |
template<typename T > | |
constexpr bool | SUNphi::isFloatingPoint =std::is_floating_point<T>::value |
Identifies whether a type is a floating-point. | |
template<typename T > | |
constexpr bool | SUNphi::isIntegral =std::is_integral<T>::value |
Identifies whether a type is an integer-like. | |
template<typename Head = int, typename... Tail> | |
constexpr bool | SUNphi::areIntegrals |
Identifies whether a set of types are a integer-like. More... | |
template<typename T > | |
constexpr bool | SUNphi::areIntegrals< T > |
Identifies whether a single types is integer-like. More... | |
template<typename S , typename T > | |
constexpr bool | SUNphi::canPrint = CanPrint <S,T>::res |
template<typename Type > | |
constexpr bool | SUNphi::hasMember_begin = hasMember_beginHelper<RemRef<Type>>() |
template<typename Type > | |
constexpr bool | SUNphi::hasMember_size = hasMember_sizeHelper<RemRef<Type>>() |
template<typename Type > | |
constexpr bool | SUNphi::hasMember_resize = hasMember_resizeHelper<RemRef<Type>>() |
template<typename Type > | |
constexpr bool | SUNphi::hasMember_end = hasMember_endHelper<RemRef<Type>>() |
template<typename T > | |
constexpr bool | SUNphi::isVectorLike |
Check if the class T is vector-like. More... | |
template<int , typename T > | |
FallTrhough | SUNphi::internal::get (T) |
Default getter. | |
template<typename T > | |
constexpr bool | SUNphi::isTupleLike |
Check if the class T is tuple-like. More... | |
Defines convenient adaptation of the std type_traits library, and extensions useful for the expression handling.
Definition in file TypeTraits.hpp.
#define DEFINE_BASE_TYPE | ( | TYPE, | |
... | |||
) |
Defines a "Base" identifier and checks for it
Given a TYPE, defines another empty type prefixing its name with "Base", and defines a check IsTYPE to probe wheter a certain type inherit from TYPE. All extra arguments can be used to specify inheritance from other classes
Definition at line 526 of file TypeTraits.hpp.
#define DEFINE_BINARY_OPERATOR_IMPLEMENTATION_CHECK | ( | CHECK_NAME, | |
STRUCT_NAME, | |||
OPERATOR | |||
) |
Check that the binary operator exists.
Definition at line 667 of file TypeTraits.hpp.
#define DEFINE_HAS_MEMBER | ( | TAG | ) |
Define a member detecter named hasMember_TAG
Example:
Definition at line 581 of file TypeTraits.hpp.
#define DEFINE_IS_THE_TEMPLATED_CLASS | ( | CLASS | ) |
Provides a check returning whether the class is of a given kind.
Definition at line 716 of file TypeTraits.hpp.
#define FORBID_CONSTRUCT_BY_COPY | ( | CLASS | ) |
Delete the copy-constructor.
Definition at line 55 of file TypeTraits.hpp.
#define PROVIDE_ALSO_NON_CONST_METHOD | ( | NAME | ) |
Provides also a non-const version of the method NAME
See https://stackoverflow.com/questions/123758/how-do-i-remove-code-duplication-between-similar-const-and-non-const-member-func A const method NAME must be already present Example
Definition at line 376 of file TypeTraits.hpp.
#define PROVIDE_ENABLE_IF_FOR | ( | TYPE, | |
... | |||
) |
Provides an EnableIf with the given name for a certain condition
Must be declared with deduced type to void template parameters that cannot be deduced
Definition at line 500 of file TypeTraits.hpp.
#define PROVIDE_ENABLE_IF_FOR_IS_TYPE | ( | TYPE | ) |
Provides an EnableIf with the given name if isTYPE exists.
Definition at line 509 of file TypeTraits.hpp.
#define PROVIDE_ENABLE_IF_FOR_TYPE | ( | TYPE | ) |
Provides an EnableIf with the given type.
Definition at line 514 of file TypeTraits.hpp.
#define STATIC_ASSERT_HAS_MEMBER | ( | TAG, | |
... | |||
) | static_assert(hasMember_ ## TAG<__VA_ARGS__>,"Type does not have member " #TAG) \ |
Assert type T to have member TAG
Note that you need to have defined DEFINE_HAS_MEMBER before
Definition at line 560 of file TypeTraits.hpp.
using SUNphi::Conditional = typedef typename _Conditional<B,T,F>::type |
Provides type T if B is true, or F if is false
Wraps the internal implementation
Definition at line 217 of file TypeTraits.hpp.
using SUNphi::EnableIf = typedef typename _EnableIf<B,T>::type |
Defines type T (default to void) if parameter B is true
Gives visibility to the internal implementation
Definition at line 88 of file TypeTraits.hpp.
using SUNphi::FalseType = typedef std::false_type |
A bool constant type holding value "false"
Useful to create SFINAE tests
Definition at line 30 of file TypeTraits.hpp.
using SUNphi::TrueType = typedef std::true_type |
A bool constant type holding value "true"
Useful to create SFINAE tests
Definition at line 24 of file TypeTraits.hpp.
using SUNphi::TypeIf = typedef EnableIf<B,T> |
Defines type T if parameter B is true
Explicit specialization of EnableIf
forcing an explicit type.
Definition at line 103 of file TypeTraits.hpp.
using SUNphi::VoidIf = typedef EnableIf<B> |
Defines void
if parameter B is true
Explicit specialization of EnableIf
for T=void
.
Definition at line 95 of file TypeTraits.hpp.
constexpr bool SUNphi::_areSame | ( | ) |
Returns true if all types Ts are the same
Internal implementation
Definition at line 151 of file TypeTraits.hpp.
|
noexcept |
Remove const
qualifier from anything
Definition at line 342 of file TypeTraits.hpp.
constexpr auto SUNphi::fundamentalHelper | ( | ) |
Returns the type T without any reference or qualifier or pointer
Helper to the actual implementation
Definition at line 287 of file TypeTraits.hpp.
constexpr bool SUNphi::hasMember_beginHelper | ( | ) |
Intemediate function to distinguish the non-class case
Definition at line 749 of file TypeTraits.hpp.
constexpr bool SUNphi::hasMember_endHelper | ( | ) |
Intemediate function to distinguish the non-class case
Definition at line 752 of file TypeTraits.hpp.
constexpr bool SUNphi::hasMember_resizeHelper | ( | ) |
Intemediate function to distinguish the non-class case
Definition at line 751 of file TypeTraits.hpp.
constexpr bool SUNphi::hasMember_sizeHelper | ( | ) |
Intemediate function to distinguish the non-class case
Definition at line 750 of file TypeTraits.hpp.
constexpr bool SUNphi::areIntegrals |
Identifies whether a set of types are a integer-like.
Definition at line 475 of file TypeTraits.hpp.
constexpr bool SUNphi::areIntegrals< T > |
Identifies whether a single types is integer-like.
Definition at line 480 of file TypeTraits.hpp.
constexpr bool SUNphi::areSame |
Returns true if all Ts are the same type
Gives visibility to internal representation
Definition at line 164 of file TypeTraits.hpp.
|
static |
Checks if a type can be cast into another one.
Definition at line 117 of file TypeTraits.hpp.
constexpr bool SUNphi::canPrint = CanPrint <S,T>::res |
Check that operator << is implemented
Definition at line 699 of file TypeTraits.hpp.
constexpr bool SUNphi::hasMember_begin = hasMember_beginHelper<RemRef<Type>>() |
Detect if Type
has member (variable or method) begin
Uses SFINAE to induce ambiguity in the detection of the member
Definition at line 749 of file TypeTraits.hpp.
constexpr bool SUNphi::hasMember_end = hasMember_endHelper<RemRef<Type>>() |
Detect if Type
has member (variable or method) end
Uses SFINAE to induce ambiguity in the detection of the member
Definition at line 752 of file TypeTraits.hpp.
constexpr bool SUNphi::hasMember_resize = hasMember_resizeHelper<RemRef<Type>>() |
Detect if Type
has member (variable or method) resize
Uses SFINAE to induce ambiguity in the detection of the member
Definition at line 751 of file TypeTraits.hpp.
constexpr bool SUNphi::hasMember_size = hasMember_sizeHelper<RemRef<Type>>() |
Detect if Type
has member (variable or method) size
Uses SFINAE to induce ambiguity in the detection of the member
Definition at line 750 of file TypeTraits.hpp.
constexpr bool SUNphi::isBaseOf |
Identifies whether Base is a base class of Derived.
Definition at line 312 of file TypeTraits.hpp.
|
static |
Checks if a type is a class.
Definition at line 110 of file TypeTraits.hpp.
constexpr bool SUNphi::isConst |
Returns whether T is const or not
Warning!!! This is not the same than asking std::is_const
Definition at line 258 of file TypeTraits.hpp.
constexpr bool SUNphi::isFunction |
Returns whether the passed argument is a function.
Definition at line 320 of file TypeTraits.hpp.
constexpr bool SUNphi::isLvalue |
Check if the type is lvalue reference.
Definition at line 229 of file TypeTraits.hpp.
|
static |
Checks if it is pointer.
Definition at line 278 of file TypeTraits.hpp.
constexpr bool SUNphi::isRvalue |
Check if the type is rvalue reference.
Definition at line 235 of file TypeTraits.hpp.
|
static |
Checks if two types are the same
Default (false) case
Definition at line 134 of file TypeTraits.hpp.
|
static |
Checks if two types are the same
True case
Definition at line 141 of file TypeTraits.hpp.
|
static |
Checks if an object can be trivially copied.
Definition at line 123 of file TypeTraits.hpp.
constexpr bool SUNphi::isTupleLike |
Check if the class T is tuple-like.
Definition at line 793 of file TypeTraits.hpp.
constexpr bool SUNphi::isVectorLike |
Check if the class T is vector-like.
Definition at line 757 of file TypeTraits.hpp.