8 #include <hilti/rt/exception.h> 9 #include <hilti/rt/logging.h> 10 #include <hilti/rt/type-info.h> 24 bool has_label(
const T& t,
const TypeInfo* ti) {
25 if ( ti->tag != TypeInfo::Enum )
28 for (
const auto& l : ti->enum_->labels() ) {
29 if ( l.value != -1 && static_cast<int64_t>(t) == l.value )
46 T from_int(int64_t n) {
47 static_assert(std::is_enum<T>::value && std::is_same_v<std::underlying_type_t<T>, int64_t>);
48 return static_cast<T
>(n);
64 T from_uint(uint64_t n) {
65 static_assert(std::is_enum<T>::value && std::is_same_v<std::underlying_type_t<T>, int64_t>);
67 if ( n > static_cast<uint64_t>(std::numeric_limits<int64_t>::max()) )
68 throw InvalidValue(
"enum value exceeds range");
70 return static_cast<T
>(n);
void internalError(const std::string &msg) __attribute__((noreturn))
Definition: logging.cc:17