Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Unreference tuple for raw memory copy.
- // Primary template for non referenced elements.
- template <class T, class = void>
- struct tuple_unref {
- tuple_unref(T& t) noexcept : value(t) { }
- T& value;
- };
- // A specialization for tuple containing
- // at least one reference type.
- template <class... Ts>
- struct tuple_unref<std::tuple<Ts...>,
- std::enable_if_t<(std::is_reference_v<Ts> || ...)>> {
- private:
- using T = std::tuple<std::remove_reference_t<Ts>...>;
- T value_;
- std::tuple<Ts...>& ref_;
- public:
- tuple_unref(std::tuple<Ts...>& t) noexcept : ref_(t) { }
- ~tuple_unref() { ref_ = std::move(value_); }
- T& value = value_;
- };
Add Comment
Please, Sign In to add comment