1 #ifndef __COMPILE_TIME_HPP_INCLUDED__
2 #define __COMPILE_TIME_HPP_INCLUDED__
46 template<
typename _Key,
typename _Ty,
typename _Traits,
typename _Multi=tag_DuplicatesNo,
typename _Backend =
void>
57 using key_type =
typename value_type::first_type;
60 using _MyBase::_MyBase;
64 auto it = _MyBase::find(_key);
65 if (it == _MyBase::end())
66 throw std::out_of_range(
"invalid const_map<K, T> key");
76 template<
size_t N,
typename _Enabled = std::enable_if<!_MyBase::is_presorted, init_type>>
79 return construct(std::to_array(
init));
81 template<
size_t N,
typename _Enabled = std::enable_if<!_MyBase::is_presorted, init_type>>
82 static constexpr
auto construct(
const const_array<typename _Enabled::type, N>&
init)
84 auto backend=_MyBase::make_backend(
init);
85 return const_map_impl<_Key, _Ty, _Traits, _Multi, decltype(backend)>{backend};
87 template<
typename _Enabled = std::enable_if<_MyBase::is_presorted, _MyType>>
90 auto backend=_MyBase::presorted(
init);
91 return const_map_impl<_Key, _Ty, _Traits, _Multi, decltype(backend)>{backend};
96 template<
typename _Key,
typename _Ty>
99 template<
typename _Key,
typename _Ty>
102 template<
typename _Key,
typename _Ty>
108 template<
typename _Ty,
typename _Backend=
void>
120 using _MyBase::_MyBase;
125 return construct(std::to_array(
init));
130 auto backend=_MyBase::make_backend(
init);
131 return const_set<_Ty, decltype(backend)>{backend};
135 template<
typename T1,
typename T2>
151 return construct(std::to_array(
init));
156 return std::make_pair(
157 map_type1::construct(
init),
158 map_type2::construct(
init)
163 template<
typename _Ty>
166 template<
typename _Key,
typename _Ty>
169 template<
typename T1,
typename T2>
172 template<
typename _Init,
typename _Elem=array_elem_t<_Init>>
189 #ifndef DEBUG_MAKE_CONST_MAP
190 # define DEBUG_MAKE_CONST_MAP(name)
192 #ifndef DEBUG_MAKE_TWOWAY_CONST_MAP
193 # define DEBUG_MAKE_TWOWAY_CONST_MAP(name)
195 #ifndef DEBUG_MAKE_CONST_SET
196 # define DEBUG_MAKE_CONST_SET(name)
203 #define MAKE_CONST_MAP(name, type1, type2, ...) \
204 static constexpr auto name = ct::const_map<type1, type2>::construct(__VA_ARGS__); \
205 DEBUG_MAKE_CONST_MAP(name)
207 #define MAKE_TWOWAY_CONST_MAP(name, type1, type2, ...) \
208 static constexpr auto name = ct::const_map_twoway<type1, type2>::construct(__VA_ARGS__); \
209 DEBUG_MAKE_TWOWAY_CONST_MAP(name)
211 #define MAKE_CONST_SET(name, type, ...) \
212 static constexpr ct::const_set<type>::init_type name ## _init [] = __VA_ARGS__; \
213 static constexpr auto name = ct::const_set<type>::construct(name ## _init); \
214 DEBUG_MAKE_CONST_SET(name)
216 #define MAKE_CONST_SET1(name, type, ...) \
217 static constexpr auto name = ct::const_set<type>::construct(__VA_ARGS__); \
218 DEBUG_MAKE_CONST_SET(name)
220 #ifdef CT_USE_STD_MAP
221 # define MAKE_CONST_MAP_COMPAT(name, type1, type2, ...) static const std::map<type1, type2> name = __VA_ARGS__;
223 # define MAKE_CONST_MAP_COMPAT MAKE_CONST_MAP
typename _Traits::init_type init_type
typename _Traits::key_type intermediate
static constexpr auto construct(typename _Enabled::type const (&init)[N])
typename value_type::second_type mapped_type
typename _MyBase::intermediate intermediate
typename value_type::first_type key_type
const mapped_type & at(intermediate _key) const
typename _MyBase::value_type value_type
const mapped_type & operator[](intermediate _key) const
typename _Traits::init_type init_type
static constexpr auto construct(const std::array< typename _Enabled::type, N > &init)
static constexpr _Enabled::type construct(const const_vector< init_type > &init)
typename _MyBase::value_type value_type
static constexpr auto construct(const std::array< init_type, N > &init)
typename _MyBase::init_type init_type
static constexpr auto construct(init_type const (&init)[N])
static void DLIST_NAME() init(DLIST_LIST_TYPE *list)
std::false_type tag_DuplicatesNo
std::true_type tag_DuplicatesYes
std::false_type tag_SortByValues
constexpr auto sort(_Init &&init)
double value_type
The numeric datatype used by the parser.
typename pair_type::init_type init_type
typename straight_traits::init_type init_type
static constexpr auto construct(const std::array< init_type, N > &init)
static constexpr auto construct(init_type const (&init)[N])