Struct move_union

Synopsis

#include <include/type_safe/tagged_union.hpp>

template <class Union>
struct move_union

Description

No description yet.

Structures

visitor

Methods

move

Source

Lines 397-419 in include/type_safe/tagged_union.hpp.

template <class Union>
struct move_union
{
    struct visitor
    {
        template <typename T>
        void operator()(T&& value, Union& dest)
        {
            dest.emplace(union_type<typename std::decay<T>::type>{}, std::move(value));
        }
    };
    static void move(Union& dest, Union&& org)
    {
        if (Union::trivial::value)
        {
            dest.storage_  = org.storage_;
            dest.cur_type_ = org.cur_type_;
        }
        else
            with(std::move(org), visitor{}, dest);
    }
};





Add Discussion as Guest

Log in