Title
is_assignable<Incomplete&, Incomplete&>
Status
open
Section
[meta.type.synop]
Submitter
Casey Carter

Created on 2018-04-10.00:00:00 last changed 4 months ago

Messages

Date: 2024-08-21.17:23:40

Proposed resolution:

This wording is relative to N4988.

  1. In [meta.unary.prop] Table 51, change the Precondition text for is_assignable, is_trivially_assignable, and is_nothrow_assignable as follows:
    remove_cvref_t<T> and U shall be complete types, cv void, or arrays of unknown bound.
  2. In [meta.unary.prop] Table 51, change the Precondition text for is_copy_assignable, is_move_assignable, is_trivially_copy_assignable, is_trivially_move_assignable, is_nothrow_copy_assignable, and is_nothrow_move_assignable as follows:
    remove_cvref_t<T> shall be a complete type, cv void, or an array of unknown bound.
Date: 2024-08-15.00:00:00

[ 2024-08-21; Jonathan provides improved wording ]

During LWG telecon review Tomasz pointed out that we don't always require a complete type for the right operand of an assignment. Given T::operator=(U&) we should be able to give a correct answer for is_assignable<T&, U&> whether of not `U` is complete. This also affects e.g. is_constructible<T, U&> if T::T(U&) exists.

So for the examples above, remove_cvref_t<U> is not needed to give a correct answer. However, if T::operator=(U&) does not exist, then we do need `U` to be complete so we can tell if there is an implicit conversion sequence to `T` or another type that can be assigned to `T`. We do not know how to solve this problem, and it's broader than just `is_assignable`. It was suggested to make an incremental improvement to `is_assignable` and open a new issue for the broader issue.

Date: 2023-06-15.00:00:00

[ 2023-06-12; Varna ]

P1285R0 is related to this issue.

This wording is relative to N4741.

  1. In [meta.unary.prop] Table 42, change the Precondition text for is_assignable, is_trivially_assignable, and is_nothrow_assignable as follows:
    remove_cvref_t<T> and remove_cvref_t<U> shall be complete types, cv void, or arrays of unknown bound.
  2. In [meta.unary.prop] Table 42, change the Precondition text for is_copy_assignable, is_move_assignable, is_trivially_copy_assignable, is_trivially_move_assignable, is_nothrow_copy_assignable, and is_nothrow_move_assignable as follows:
    remove_cvref_t<T> shall be a complete type, cv void, or an array of unknown bound.
Date: 2020-02-15.00:00:00

[ 2020-02-14, Prague ]

LWG discussions. Set priority to 2.

Date: 2018-08-22.12:55:05

[ 2018-08 Batavia Monday issue discussion ]

Issues 2797, 2939, 3022, and 3099 are all closely related. Walter to write a paper resolving them.

Date: 2018-04-16.18:17:22

LWG 2939 suggests that the the preconditions of the type traits need reevaluation. This issue focuses specifically on is_assignable and, by extension, its variants:

  • is_copy_assignable<T>, equivalent to is_assignable<T&, const T&>,
  • is_move_assignable<T>, equivalent to is_assignable<T&, T>,
  • is_trivially_assignable<T, U>, equivalent to is_assignable<T, U> && /* magic */,
  • is_trivially_copy_assignable<T>, equivalent to is_assignable<T&, const T&> && /* magic */,
  • is_trivially_move_assignable<T>, equivalent to is_assignable<T&, T> && /* magic */,
  • is_nothrow_assignable<T, U>, equivalent to is_assignable<T, U> && noexcept(declval<T>() = declval<U>()),
  • is_nothrow_copy_assignable<T>, equivalent to is_assignable<T&, const T&> && noexcept(declval<T&>() = declval<const T&>()),
  • is_nothrow_move_assignable<T>, equivalent to is_assignable<T&, T> && noexcept(declval<T&>() = declval<T>()), and

We note a discrepancy: is_copy_assignable<T> requires T to be a complete type, but the equivalent form is_assignable<T&, const T&> does not. The requirement for is_copy_assignable<T> seems sensible, since there's no way to determine whether or not the assignment declval<T&>() = declval<const T&>() is well-formed when T is incomplete. It seems that the same argument should apply to all of the above "assignable" traits, and that they must require that the referent type is complete when given a reference type parameter to be implementable.

History
Date User Action Args
2024-08-21 21:45:32adminsetstatus: new -> open
2024-08-21 17:23:40adminsetmessages: + msg14334
2023-06-12 11:59:23adminsetmessages: + msg13621
2020-02-14 15:49:31adminsetmessages: + msg11130
2018-08-22 12:55:05adminsetmessages: + msg10096
2018-04-10 20:38:51adminsetmessages: + msg9815
2018-04-10 00:00:00admincreate