Wildmeshing Toolkit
AttributeType.hpp
Go to the documentation of this file.
1 #pragma once
3 
4 namespace wmtk::attribute {
5 enum class AttributeType { Char = 0, Int64 = 1, Double = 2, Rational = 3 };
6 
7 template <AttributeType AT>
9 {
10 };
11 template <>
13 {
14  using type = char;
15 };
16 template <>
18 {
19  using type = double;
20 };
21 template <>
23 {
24  using type = int64_t;
25 };
26 template <>
28 {
30 };
31 
32 template <AttributeType AT>
34 
35 template <typename T>
36 inline constexpr auto attribute_type_enum_from_type() -> AttributeType
37 {
38  if constexpr (std::is_same_v<T, char>) {
39  return AttributeType::Char;
40  } else if constexpr (std::is_same_v<T, double>) {
41  return AttributeType::Double;
42  } else if constexpr (std::is_same_v<T, int64_t>) {
43  return AttributeType::Int64;
44  } else if constexpr (std::is_same_v<T, wmtk::Rational>) {
46  }
47  // If a compiler complains about the potentiality of no return value then a type accepted by the
48  // HAndleVariant is not being represented properly. If the comppiler is simply unhappy to not
49  // see a return then we should hack a default return value in an else statement with an asswert
50  // :(.
51  else {
52  static_assert(std::is_same_v<T, char>);
53  return AttributeType::Char;
54  }
55 }
56 } // namespace wmtk::attribute
typename type_from_attribute_type_enum< AT >::type type_from_attribute_type_enum_t
constexpr auto attribute_type_enum_from_type() -> AttributeType