Namespaces
Variants
Actions

std::assignable_from

From cppreference.com
< cpp‎ | concepts
Defined in header <concepts>
template< class LHS, class RHS >

concept assignable_from =
    std::is_lvalue_reference_v<LHS> &&
    std::common_reference_with<
        const std::remove_reference_t<LHS>&,
        const std::remove_reference_t<RHS>&> &&
    requires(LHS lhs, RHS&& rhs) {
        { lhs = std::forward<RHS>(rhs) } -> std::same_as<LHS>;

    };
(since C++20)

The concept assignable_from<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.

Contents

[edit] Semantic requirements

Given

  • lhs, an lvalue that refers to an object lcopy such that decltype((lhs)) is LHS,
  • rhs, an expression such that decltype((rhs)) is RHS,
  • rcopy, a distinct object that is equal to rhs,

assignable_from<LHS, RHS> is modeled only if