29 #ifndef AURORA_NAMEDTUPLE_HPP
30 #define AURORA_NAMEDTUPLE_HPP
45 #define AURORA_DETAIL_PARAM_TV(Type, var) Type const& var
46 #define AURORA_DETAIL_PARAM_P(pair) AURORA_DETAIL_PARAM_TV pair
47 #define AURORA_DETAIL_PARAM(pair, index) AURORA_PP_COMMA_IF(index) AURORA_DETAIL_PARAM_P(pair)
50 #define AURORA_DETAIL_INIT_TV(Type, var) var(var)
51 #define AURORA_DETAIL_INIT_P(pair) AURORA_DETAIL_INIT_TV pair
52 #define AURORA_DETAIL_INIT(pair, index) AURORA_PP_COMMA_IF(index) AURORA_DETAIL_INIT_P(pair)
55 #define AURORA_DETAIL_INITDEFAULT_TV(Type, var) var()
56 #define AURORA_DETAIL_INITDEFAULT_P(pair) AURORA_DETAIL_INITDEFAULT_TV pair
57 #define AURORA_DETAIL_INITDEFAULT(pair, index) AURORA_PP_COMMA_IF(index) AURORA_DETAIL_INITDEFAULT_P(pair)
60 #define AURORA_DETAIL_MEMDECL_TV(Type, var) Type var;
61 #define AURORA_DETAIL_MEMDECL_P(pair) AURORA_DETAIL_MEMDECL_TV pair
62 #define AURORA_DETAIL_MEMDECL(pair, index) AURORA_DETAIL_MEMDECL_P(pair)
65 #define AURORA_DETAIL_VAR_TV(Type, var) var
66 #define AURORA_DETAIL_VAR_P(pair) AURORA_DETAIL_VAR_TV pair
67 #define AURORA_DETAIL_VAR(pair, index) AURORA_PP_COMMA_IF(index) AURORA_DETAIL_VAR_P(pair)
70 #define AURORA_DETAIL_TYPE_TV(Type, var) Type
71 #define AURORA_DETAIL_TYPE_P(pair) AURORA_DETAIL_TYPE_TV pair
72 #define AURORA_DETAIL_TYPE(pair, index) AURORA_PP_COMMA_IF(index) AURORA_DETAIL_TYPE_P(pair)
75 #define AURORA_DETAIL_HASHCOMBINE_TV(Type, var) aurora::hashCombine(h, t.var);
76 #define AURORA_DETAIL_HASHCOMBINE_P(pair) AURORA_DETAIL_HASHCOMBINE_TV pair
77 #define AURORA_DETAIL_HASHCOMBINE(pair, index) AURORA_DETAIL_HASHCOMBINE_P(pair)
80 #define AURORA_DETAIL_EXTENSION(macro, index, args) macro args
83 #define AURORA_DETAIL_DEFAULT_CTOR(TupleName, typeVarPairs) \
85 : AURORA_PP_FOREACH(AURORA_DETAIL_INITDEFAULT, typeVarPairs) \
90 #define AURORA_DETAIL_TOSTDTUPLE(typeVarPairs) \
91 std::tuple<AURORA_PP_FOREACH(AURORA_DETAIL_TYPE, typeVarPairs)> toStdTuple() const \
93 return std::make_tuple(AURORA_PP_FOREACH(AURORA_DETAIL_VAR, typeVarPairs)); \
97 #define AURORA_DETAIL_BASE_TUPLE(TupleName, typeVarPairs, extensions) \
99 AURORA_PP_FOREACH(AURORA_DETAIL_MEMDECL, typeVarPairs) \
102 explicit TupleName(AURORA_PP_FOREACH(AURORA_DETAIL_PARAM, typeVarPairs)) \
103 AURORA_PP_IF(AURORA_PP_SIZE(typeVarPairs), :, AURORA_PP_NOTHING) \
104 AURORA_PP_FOREACH(AURORA_DETAIL_INIT, typeVarPairs) \
109 AURORA_DETAIL_TOSTDTUPLE(typeVarPairs) \
118 #define AURORA_NT_EQUAL(TupleName, typeVarPairs) \
119 friend bool operator== (const TupleName& lhs, const TupleName& rhs) \
121 return lhs.toStdTuple() == rhs.toStdTuple(); \
124 #define AURORA_NT_LESS(TupleName, typeVarPairs) \
129 friend bool operator< (const TupleName& lhs, const TupleName& rhs) \
131 return lhs.toStdTuple() < rhs.toStdTuple(); \
134 #define AURORA_NT_HASHER(TupleName, typeVarPairs) \
141 std::size_t operator() (const TupleName& t) const \
144 AURORA_PP_FOREACH(AURORA_DETAIL_HASHCOMBINE, typeVarPairs) \
149 #define AURORA_NT_DEFAULT_CTOR(TupleName, typeVarPairs) \
154 AURORA_PP_IF(AURORA_PP_SIZE(typeVarPairs), \
155 AURORA_DETAIL_DEFAULT_CTOR, AURORA_PP_VA_CONSUME)(TupleName, typeVarPairs) \
188 #define AURORA_NAMED_TUPLE(TupleName, typeVarPairs) \
191 AURORA_DETAIL_BASE_TUPLE(TupleName, typeVarPairs, extensions) \
194 #define AURORA_NAMED_TUPLE_EXT(TupleName, typeVarPairs, extensions) \
225 AURORA_DETAIL_BASE_TUPLE(TupleName, typeVarPairs, extensions) \
228 AURORA_PP_FOREACH_DATA_SIZED(AURORA_DETAIL_EXTENSION, AURORA_PP_POSITIVE_SIZE(extensions), \
229 extensions, (TupleName, typeVarPairs)) \
234 #endif // AURORA_NAMEDTUPLE_HPP
Utilities for preprocessor metaprogramming.