Function copy

Summary

#include <include/type_safe/optional_ref.hpp>

(1) template <typename T>
    optional< typename std::remove_const< T >::type > copy(const optional_ref< T > &ref)

#include <include/type_safe/reference.hpp>

(2) template <typename T>
    constexpr std::remove_const< T >::type copy(const object_ref< T > &obj)

#include <include/type_safe/tagged_union.hpp>

(3) template <typename... Types>
    void copy(tagged_union< Types... > &dest, const tagged_union< Types... > &org)

Function overload

Synopsis

#include <include/type_safe/optional_ref.hpp>

template <typename T>
optional< typename std::remove_const< T >::type > copy(const optional_ref< T > &ref)

Description

Returns
A [ts::optional<T>]() containing a copy of the value of ref if there is any value. \requires T must be copyable. \module optional

Source

Lines 263-267 in include/type_safe/optional_ref.hpp.

template <typename T>
optional<typename std::remove_const<T>::type> copy(const optional_ref<T>& ref)
{
    return ref.has_value() ? type_safe::make_optional(ref.value()) : nullopt;
}

Synopsis

#include <include/type_safe/reference.hpp>

template <typename T>
constexpr std::remove_const< T >::type copy(const object_ref< T > &obj)

Description

Returns
A new object containing a copy of the referenced object. It will use the copy (1)/move constructor (2).
Exceptions

Anything - thrown by the copy (1)/move (2) constructor. \group object_ref_copy

Source

Lines 258-262 in include/type_safe/reference.hpp.

template <typename T>
constexpr typename std::remove_const<T>::type copy(const object_ref<T>& obj)
{
    return *obj;
}

Synopsis

#include <include/type_safe/tagged_union.hpp>

template <typename... Types>
void copy(tagged_union< Types... > &dest, const tagged_union< Types... > &org)

Description

\effects Copies the type currently stored in one [ts::tagged_union]() to another. This is equivalent to calling dest.emplace(union_type<T>{}, org.value(union_type<T>{})) (1)/ dest.emplace(union_type<T>{}, std::move(org).value(union_type<T>{})) (2), where T is the type currently stored in the union.

Exceptions

Anything - by the copy/move constructor in which case nothing has changed. \requires dest must not store a type, and all types must be copyable/moveable. \group union_copy_move \module variant \unique_name *copy_union

Source

Lines 441-446 in include/type_safe/tagged_union.hpp.

template <typename... Types>
void copy(tagged_union<Types...>& dest, const tagged_union<Types...>& org)
{
    DEBUG_ASSERT(!dest.has_value(), detail::precondition_error_handler{});
    detail::copy_union<tagged_union<Types...>>::copy(dest, org);
}





Add Discussion as Guest

Log in