| 12345678910111213141516171819202122232425262728293031323334353637 |
- #pragma once
- namespace variant { namespace detail {
- template <typename... Ts> struct helper;
- template <typename F, typename... Ts> struct helper<F, Ts...> {
- inline static void destroy(size_t id, void * data) {
- if (id == sizeof...(Ts)) {
- reinterpret_cast<F *>(data)->~F();
- } else {
- helper<Ts...>::destroy(id, data);
- }
- }
- inline static void move(size_t old_t, void * old_v, void * new_v) {
- if (old_t == sizeof...(Ts)) {
- new (new_v) F(std::move(*reinterpret_cast<F *>(old_v)));
- } else {
- helper<Ts...>::move(old_t, old_v, new_v);
- }
- }
- inline static void copy(size_t old_t, const void * old_v, void * new_v) {
- if (old_t == sizeof...(Ts)) {
- new (new_v) F(*reinterpret_cast<const F *>(old_v));
- } else {
- helper<Ts...>::copy(old_t, old_v, new_v);
- }
- }
- };
- template <> struct helper<> {
- inline static void destroy(size_t, void *) {}
- inline static void move(size_t, void *, void *) {}
- inline static void copy(size_t, const void *, void *) {}
- };
- }}
|