1 #ifndef __COMPILE_TIME_HPP_INCLUDED__
2 #define __COMPILE_TIME_HPP_INCLUDED__
40 #ifdef NCBI_HAVE_CXX17
52 template<
typename _Key,
typename _Ty,
typename _Traits,
typename _Multi=tag_DuplicatesNo,
typename _Backend =
void>
63 using key_type =
typename value_type::first_type;
66 using _MyBase::_MyBase;
70 auto it = _MyBase::find(_key);
71 if (it == _MyBase::end())
72 throw std::out_of_range(
"invalid const_map<K, T> key");
82 template<
size_t N,
typename _Enabled = std::enable_if<!_MyBase::is_presorted, init_type>>
87 template<
size_t N,
typename _Enabled = std::enable_if<!_MyBase::is_presorted, init_type>>
90 auto backend=_MyBase::make_backend(
init);
91 return const_map_impl<_Key, _Ty, _Traits, _Multi, decltype(backend)>{backend};
93 template<
typename _Enabled = std::enable_if<_MyBase::is_presorted, _MyType>>
96 auto backend=_MyBase::presorted(
init);
97 return const_map_impl<_Key, _Ty, _Traits, _Multi, decltype(backend)>{backend};
102 template<
typename _Key,
typename _Ty>
105 template<
typename _Key,
typename _Ty>
108 template<
typename _Key,
typename _Ty>
114 template<
typename _Ty,
typename _Backend=
void>
126 using _MyBase::_MyBase;
136 auto backend=_MyBase::make_backend(
init);
137 return const_set<_Ty, decltype(backend)>{backend};
141 template<
typename T1,
typename T2>
162 return std::make_pair(
163 map_type1::construct(
init),
164 map_type2::construct(
init)
169 template<
typename _Ty>
172 template<
typename _Key,
typename _Ty>
175 template<
typename T1,
typename T2>
178 template<
typename _Init,
typename _Elem=array_elem_t<_Init>>
195 #ifndef DEBUG_MAKE_CONST_MAP
196 # define DEBUG_MAKE_CONST_MAP(name)
198 #ifndef DEBUG_MAKE_TWOWAY_CONST_MAP
199 # define DEBUG_MAKE_TWOWAY_CONST_MAP(name)
201 #ifndef DEBUG_MAKE_CONST_SET
202 # define DEBUG_MAKE_CONST_SET(name)
209 #define MAKE_CONST_MAP(name, type1, type2, ...) \
210 static constexpr auto name = ct::const_map<type1, type2>::construct(__VA_ARGS__); \
211 DEBUG_MAKE_CONST_MAP(name)
213 #define MAKE_TWOWAY_CONST_MAP(name, type1, type2, ...) \
214 static constexpr auto name = ct::const_map_twoway<type1, type2>::construct(__VA_ARGS__); \
215 DEBUG_MAKE_TWOWAY_CONST_MAP(name)
217 #define MAKE_CONST_SET(name, type, ...) \
218 static constexpr ct::const_set<type>::init_type name ## _init [] = __VA_ARGS__; \
219 static constexpr auto name = ct::const_set<type>::construct(name ## _init); \
220 DEBUG_MAKE_CONST_SET(name)
222 #define MAKE_CONST_SET1(name, type, ...) \
223 static constexpr auto name = ct::const_set<type>::construct(__VA_ARGS__); \
224 DEBUG_MAKE_CONST_SET(name)
226 #ifdef CT_USE_STD_MAP
227 # define MAKE_CONST_MAP_COMPAT(name, type1, type2, ...) static const std::map<type1, type2> name = __VA_ARGS__;
229 # 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
constexpr auto make_array(T &&a)
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])