This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

4503. Use of std::common_reference_with in std::assignable_from seems incorrect

Section: 18.4.8 [concept.assignable] Status: New Submitter: Jiang An Opened: 2025-12-24 Last modified: 2026-01-17

Priority: Not Prioritized

View all issues with New status.

Discussion:

Currently, std::assignable_from<std::unique_ptr<int>&, std::nullptr_t> is false, because the common reference type of unique_ptr<int>& and nullptr_t is unique_ptr<int>, and a const unique_ptr<int> lvalue can't be converted to the common reference type.

Such design seems counter-intuitive and valueless. When common_reference_with is modeled, one can use the common reference type in some non-generic, homogeneous interfaces. However, it should be clear enough that the type isn't expected to be used in assignment.

The earliest form of the design can be found in ericniebler/stl2#150, where cases involving move-only types didn't seem analyzed. In any case, if we want ranges::advance to perform assignment only when I and S are common enough, we should just limit the common_reference_with requirements to ranges::advance.

Proposed resolution:

This wording is relative to N5032.

  1. Modify 18.4.8 [concept.assignable] as indicated:

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