ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
tmp.hpp
Go to the documentation of this file.
1/** ************************************************************************************************
2 * \file
3 * This header file is part of the \aliblong. It does not belong to an \alibmod and is
4 * included in any \alibdist.
5 *
6 * \emoji :copyright: 2013-2024 A-Worx GmbH, Germany.
7 * Published under \ref mainpage_license "Boost Software License".
8 *
9 * \note
10 * To reduce complexity, this header is not shown in inclusion graphs of this documentation.
11 **************************************************************************************************/
12#ifndef HPP_ALIB_LANG_TMP
13#define HPP_ALIB_LANG_TMP 1
14
15#if !defined(HPP_ALIB) && !defined(ALIB_DOX)
16# include "alib/alib.hpp"
17#endif
18
19#if !defined(_GLIBCXX_TYPE_TRAITS) || !defined(_TYPE_TRAITS_)
20# include <type_traits>
21#endif
22
23
24// is/eq/isof
25#define ATMP_IS_CONST( T ) std::is_const <T>::value
26#define ATMP_IS_ENUM( T ) std::is_enum <T>::value
27#define ATMP_IS_PTR( T ) std::is_pointer <T>::value
28#define ATMP_IS_ARR( T ) std::is_array <T>::value
29#define ATMP_IS_INT( T ) std::is_integral<T>::value
30#define ATMP_IS_UINT( T ) (std::is_integral<T>::value && std::is_unsigned<T>::value)
31#define ATMP_IS_SINT( T ) (std::is_integral<T>::value && std::is_signed <T>::value)
32#define ATMP_EQ( T, TEqual) std::is_same <T, TEqual>::value
33#define ATMP_ISOF( T, TBase) std::is_base_of <TBase, T >::value
34
35// remove
36#define ATMP_RC( T ) typename std::remove_const <T>::type
37#define ATMP_RR( T ) typename std::remove_reference<T>::type
38#define ATMP_RP( T ) typename std::remove_pointer <T>::type
39#define ATMP_RE( T ) typename std::remove_extent <T>::type
40#define ATMP_RCV( T ) typename std::remove_cv <T>::type
41#define ATMP_RCVR( T ) typename std::remove_cv < \
42 typename std::remove_reference<T>::type>::type
43#define ATMP_RCVP( T ) typename std::remove_cv < \
44 typename std::remove_pointer < \
45 typename std::remove_reference<T>::type>::type>::type
46#define ATMP_RECVP( T ) typename std::remove_extent < \
47 typename std::remove_cv < \
48 typename std::remove_pointer < \
49 typename std::remove_reference<T>::type>::type>::type>::type
50
51// enable_if / conditional
52#define ATMP_VOID_IF( Cond ) typename std::enable_if<Cond >::type
53#define ATMP_T_IF( T, Cond ) typename std::enable_if<Cond,T>::type
54#define ATMP_IF_T_F( Cond, T, F ) typename std::conditional<Cond,T,F>::type
55
56// method selection
57#define ATMP_SELECT_IF_1TP( TParam, ... ) \
58 template <TParam, typename std::enable_if<__VA_ARGS__ ,int>::type = 0 > \
59 ALIB_FORCE_INLINE \
60
61#define ATMP_SELECT_IF_2TP( TParam1, TParam2, ... ) \
62 template <TParam1, TParam2, typename std::enable_if<__VA_ARGS__ ,int>::type = 0 > \
63 ALIB_FORCE_INLINE \
64
65#define ATMP_SELECT_IF_3TP( TParam1, TParam2, TParam3, ... ) \
66 template <TParam1, TParam2, TParam3, typename std::enable_if<__VA_ARGS__ ,int>::type = 0 > \
67 ALIB_FORCE_INLINE \
68
69#define ATMP_SELECT_IF_4TP( TParam1, TParam2, TParam3, TParam4, ... ) \
70 template <TParam1, TParam2, \
71 TParam3, TParam4, typename std::enable_if<__VA_ARGS__ ,int>::type = 0 > \
72 ALIB_FORCE_INLINE \
73
74
75// method selection using return type.
76#define ATMP_RETURN_IF_1TP( TReturn, TParam, ... ) \
77 template <TParam> \
78 ALIB_FORCE_INLINE \
79 ATMP_T_IF( TReturn, (__VA_ARGS__)) \
80
81#define ATMP_RETURN_IF_2TP( TReturn, TParam1, TParam2, ... ) \
82 template <TParam1, TParam2> \
83 ALIB_FORCE_INLINE \
84 ATMP_T_IF( TReturn, (__VA_ARGS__)) \
85
86
87// common type tags
88
89namespace alib::lang {
90
91/**
92 * This "TAG-type" denotes that initialization should be performed.
93 *
94 * For example, this type might be accepted by an alternative constructor of a type that has
95 * a defaulted constructor that does not initialize its members to default values.
96 * Such alternative constructor then would perform member initialization (and ignore the parameter
97 * otherwise).
98 *
99 * \see Tag type struct \alib{lang;TOmitInitialization}.
100 */
102
103/**
104 * This "TAG-type" denotes that initialization should not be performed.
105 *
106 * For example, this type might be accepted by an alternative constructor of a type that has
107 * a default constructor, initializing its members to default values.
108 * Such alternative constructor then would omit any member initialization (and ignore the parameter
109 * otherwise).
110 *
111 * \see Tag type struct \alib{lang;TInitializeDefaults}.
112 */
114
115} // namespace [alib::lang]
116
117#endif // HPP_ALIB_LANG_TMP