Movatterモバイル変換


[0]ホーム

URL:



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

3151.ConvertibleTo rejects conversions from array and function types

Section: 18.4.4[concept.convertible]Status:ResolvedSubmitter: Casey CarterOpened: 2018-08-09Last modified: 2020-11-09

Priority:3

View otheractive issues in [concept.convertible].

View all otherissues in [concept.convertible].

View all issues withResolved status.

Discussion:

In the definition ofConvertibleTo in 18.4.4[concept.convertible]:

template<class From, class To>  concept ConvertibleTo =    is_convertible_v<From, To> &&    requires(From (&f)()) {      static_cast<To>(f());    };

f is an arbitrary function that returns typeFrom. Sincefunctions cannot return array or function types (9.3.4.6[dcl.fct]paragraph 11),ConvertibleTocannot be satisfied whenFrom is an array or function type regardlessof the type ofTo. This is incompatibility withis_convertible_vwas not an intentional design feature, so it should be corrected. (Note that anychange made here must take care to avoid breaking theConvertibleTo<T, void> cases.)

[2018-08-20 Priority set to 3 after reflector discussion]

Previous resolution [SUPERSEDED]:

[Drafting Note: I've useddeclval here, despite that "Conceptsmean we never have to usedeclval again!" because the alternativeis less readable:]

requires(add_rvalue_reference_t<From> (&f)()) {  static_cast<To>(f());};

This wording is relative toN4762.

  1. Modify 18.4.4[concept.convertible] as follows:

    template<class From, class To>  concept ConvertibleTo =    is_convertible_v<From, To> &&    requires(From (&f)()) {      static_cast<To>(f()declval<From>());    };

[2020-11-09 Resolved for C++20. Status changed: Tentatively Resolved → Resolved.]

Proposed resolution:

This issue is resolved by the resolution of issue3194(i).


[8]ページ先頭

©2009-2026 Movatter.jp