16 #ifndef IOX_UTILS_CXX_VARIANT_INTERNAL_HPP
17 #define IOX_UTILS_CXX_VARIANT_INTERNAL_HPP
21 #include <type_traits>
30 using byte_t = uint8_t;
31 template <
typename TypeToCheck,
typename T,
typename... Targs>
34 static constexpr
bool value =
35 std::is_same<TypeToCheck, T>::value ||
does_contain_type<TypeToCheck, Targs...>::value;
38 template <
typename TypeToCheck,
typename T>
41 static constexpr
bool value = std::is_same<TypeToCheck, T>::value;
44 template <uint64_t N,
typename Type,
typename T,
typename... Targs>
47 static constexpr uint64_t index =
get_index_of_type<N + 1, Type, Targs...>::index;
50 template <uint64_t N,
typename Type,
typename... Targs>
53 static constexpr uint64_t index = N;
56 template <uint64_t N, uint64_t Index,
typename T,
typename... Targs>
62 template <uint64_t N,
typename T,
typename... Targs>
68 template <uint64_t N,
typename T,
typename... Targs>
71 static void destructor(
const uint64_t index, byte_t* ptr)
75 reinterpret_cast<T*
>(ptr)->~T();
83 static void move(
const uint64_t index, byte_t* source, byte_t* destination)
87 *
reinterpret_cast<T*
>(destination) = std::move(*
reinterpret_cast<T*
>(source));
95 static void moveConstructor(
const uint64_t index, byte_t* source, byte_t* destination)
99 new (destination) T(std::move(*
reinterpret_cast<T*
>(source)));
107 static void copy(
const uint64_t index, byte_t* source, byte_t* destination)
111 *
reinterpret_cast<T*
>(destination) = *
reinterpret_cast<T*
>(source);
119 static void copyConstructor(
const uint64_t index, byte_t* source, byte_t* destination)
123 new (destination) T(*
reinterpret_cast<T*
>(source));
132 template <u
int64_t N,
typename T>
135 static void destructor(
const uint64_t index, byte_t* ptr)
139 reinterpret_cast<T*
>(ptr)->~T();
143 assert(
false &&
"Could not call destructor for variant element");
147 static void move(
const uint64_t index, byte_t* source, byte_t* destination)
151 *
reinterpret_cast<T*
>(destination) = std::move(*
reinterpret_cast<T*
>(source));
155 assert(
false &&
"Could not call move assignment for variant element");
159 static void moveConstructor(
const uint64_t index, byte_t* source, byte_t* destination)
163 new (destination) T(std::move(*
reinterpret_cast<T*
>(source)));
167 assert(
false &&
"Could not call move constructor for variant element");
171 static void copy(
const uint64_t index, byte_t* source, byte_t* destination)
175 *
reinterpret_cast<T*
>(destination) = *
reinterpret_cast<T*
>(source);
179 assert(
false &&
"Could not call copy assignment for variant element");
183 static void copyConstructor(
const uint64_t index, byte_t* source, byte_t* destination)
187 new (destination) T(*
reinterpret_cast<T*
>(source));
191 assert(
false &&
"Could not call copy constructor for variant element");
building block to easily create free function for logging in a library context
Definition: lockfree_queue.hpp:28
Definition: variant_internal.hpp:70
Definition: variant_internal.hpp:33
Definition: variant_internal.hpp:46
Definition: variant_internal.hpp:58