SysTutorials

Linux Manual Pages › Section 3

stdassignable(3)

std::Assignable - std::Assignable

Synopsis

Defined in header<concepts>
    template <class LHS, class RHS>
    concept Assignable =
        std::is_lvalue_reference_v<LHS> &&
        std::CommonReference <
        const std::remove_reference_t<LHS>
&, (since C++ 20)
           const std::remove_reference_t<RHS> & > &&
                                                  requires(LHS lhs, RHS &&rhs)
{
    lhs = std::forward<RHS>(rhs);
    requires std::Same<decltype(lhs = std::forward<RHS>(rhs)), LHS>;
};

The concept Assignable<LHS, RHS> specifies that an expression of the type and value category specified by RHS can be assigned to an lvalue expression whose type is specified by LHS. Given

Equality preservation An expression is equality preserving if it results in equal outputs given equal inputs.

Notes

Assignment need not be a total function. In particular, if assigning to some object x can cause some other object y to be modified, then x = y is likely not in the domain of =. This typically happens if the right operand is owned directly or indirectly by the left operand (e.g., with smart pointers to nodes in an node-based data structure, or with something like std::vector<std::any>).

See also

is_assignable is_trivially_assignable is_nothrow_assignable checks if a type has a assignment operator for a specific argument                         (class template) (C++11) (C++11) (C++11)