12 #ifndef META_NUMERIC_IDENTIFIER_H_
13 #define META_NUMERIC_IDENTIFIER_H_
34 template <
template <
class>
class Wrapped>
37 using Wrapped<hash_wrapper>::Wrapped;
38 using Wrapped<hash_wrapper>::operator=;
52 template <
class Derived,
class T>
122 operator const T&()
const
148 return static_cast<T
>(lhs) < static_cast<T>(rhs);
160 return stream << static_cast<T>(ident);
172 return stream >> ident.
id_;
181 template <
class Derived,
class T>
256 friend inline Derived
operator+(Derived lhs,
const Derived& rhs)
258 lhs +=
static_cast<T
>(rhs);
268 friend inline Derived
operator-(Derived lhs,
const Derived& rhs)
270 lhs -=
static_cast<T
>(rhs);
281 return static_cast<Derived*
>(
this);
294 template <
template <
class>
class Wrapped>
295 struct hash<
meta::util::hash_wrapper<Wrapped>>
307 return hash<T>{}(
static_cast<T
>(to_hash));
312 #define MAKE_USER_DEFINED_LITERAL(ident_name, base_type, suffix) \
313 inline ident_name operator"" suffix(const char* str, std::size_t len) \
315 return ident_name{base_type{str, len}}; \
318 #define MAKE_USER_DEFINED_NUMERIC_LITERAL(ident_name, base_type, suffix) \
319 inline ident_name operator"" suffix(unsigned long long int val) \
321 return ident_name{base_type(val)}; \
324 #define MAKE_OPAQUE_IDENTIFIER(ident_name, base_type) \
325 template <class Wrapper> \
326 struct ident_name##_dummy \
327 : public meta::util::identifier<Wrapper, base_type> \
329 using meta::util::identifier<Wrapper, base_type>::identifier; \
330 using meta::util::identifier<Wrapper, base_type>::operator=; \
332 using ident_name = meta::util::hash_wrapper<ident_name##_dummy>;
334 #define MAKE_OPAQUE_NUMERIC_IDENTIFIER(ident_name, base_type) \
335 template <class Wrapper> \
336 struct ident_name##_dummy \
337 : public meta::util::numerical_identifier<Wrapper, base_type> \
339 using meta::util::numerical_identifier<Wrapper, base_type>:: \
340 numerical_identifier; \
341 using meta::util::numerical_identifier<Wrapper, base_type>::operator=; \
343 using ident_name = meta::util::hash_wrapper<ident_name##_dummy>;
345 #if !defined NDEBUG && !defined NUSE_OPAQUE_IDENTIFIERS
346 #define MAKE_IDENTIFIER(ident_name, base_type) \
347 MAKE_OPAQUE_IDENTIFIER(ident_name, base_type)
349 #define MAKE_IDENTIFIER(ident_name, base_type) using ident_name = base_type;
352 #if !defined NDEBUG && !defined NUSE_OPAQUE_IDENTIFIERS
353 #define MAKE_NUMERIC_IDENTIFIER(ident_name, base_type) \
354 MAKE_OPAQUE_NUMERIC_IDENTIFIER(ident_name, base_type)
356 #define MAKE_NUMERIC_IDENTIFIER(ident_name, base_type) \
357 using ident_name = base_type;
360 #if !defined NDEBUG && !defined NUSE_OPAQUE_IDENTIFIERS
361 #define MAKE_IDENTIFIER_UDL(ident_name, base_type, suffix) \
362 MAKE_OPAQUE_IDENTIFIER(ident_name, base_type) \
363 MAKE_USER_DEFINED_LITERAL(ident_name, base_type, suffix)
365 #define MAKE_IDENTIFIER_UDL(ident_name, base_type, suffix) \
366 using ident_name = base_type; \
367 MAKE_USER_DEFINED_LITERAL(ident_name, base_type, suffix)
370 #if !defined NDEBUG && !defined NUSE_OPAQUE_IDENTIFIERS
371 #define MAKE_NUMERIC_IDENTIFIER_UDL(ident_name, base_type, suffix) \
372 MAKE_OPAQUE_NUMERIC_IDENTIFIER(ident_name, base_type) \
373 MAKE_USER_DEFINED_NUMERIC_LITERAL(ident_name, base_type, suffix)
375 #define MAKE_NUMERIC_IDENTIFIER_UDL(ident_name, base_type, suffix) \
376 using ident_name = base_type; \
377 MAKE_USER_DEFINED_NUMERIC_LITERAL(ident_name, base_type, suffix)