This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++20 status.
3300. Non-arrayssize
overload is underconstrained
Section: 24.7 [iterator.range] Status: C++20 Submitter: Casey Carter Opened: 2019-09-27 Last modified: 2021-02-25
Priority: 3
View other active issues in [iterator.range].
View all other issues in [iterator.range].
View all issues with C++20 status.
Discussion:
The overload of ssize
specified in 24.7 [iterator.range]/18 has no constraints, yet it specializes make_signed_t
which has a precondition that its type parameter is an integral type or enumeration but not bool
(21.3.9.4 [meta.trans.sign]). This precondition needs to be propagated to ssize
as "Mandates [or Constraints]: decltype(c.size())
[meets the requirements for the type argument to make_signed
]". "Mandates" seems to be more in line with LWG guidance since there are no traits nor concepts that observe ssize
.
[2019-11-16 Issue Prioritization]
Priority to 3 after reflector discussion.
Previous resolution [SUPERSEDED]:
This wording is relative to N4830.
Modify 24.7 [iterator.range] as indicated:
template<class C> constexpr auto ssize(const C& c) -> common_type_t<ptrdiff_t, make_signed_t<decltype(c.size())>>;-?- Mandates:
-18- Returns:decltype(c.size())
is a (possibly cv-qualified) integral or enumeration type but not abool
type.static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(c.size())>>>(c.size())
[2019-10-28; Tim provides improved wording]
Previous resolution [SUPERSEDED]:
This wording is relative to N4835.
Modify 24.7 [iterator.range] as indicated:
template<class C> constexpr auto ssize(const C& c) -> common_type_t<ptrdiff_t, make_signed_t<decltype(c.size())>>;-?- Mandates:
-18- Returns:decltype(c.size())
is an integral or enumeration type other thanbool
.static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(c.size())>>>(c.size())
[2019-11-18; Casey comments and improves wording]
It would be better to provided the Mandates: guarantee in [tab:meta.trans.sign] instead of one special place where the make_signed
template is used. The wording below attempts to realize that.
[2019-11-23 Issue Prioritization]
Status to Tentatively Ready after five positive votes on the reflector.
Proposed resolution:
This wording is relative to N4835.
Change Table 52 — "Sign modifications" in [tab:meta.trans.sign] as indicated:
Table 52 — Sign modifications [tab:meta.trans.sign] Template Commentstemplate <class T>
struct make_signed;
If T
names a (possibly cv-qualified) signed integer type (6.9.2 [basic.fundamental]) thentype
names the type T
; otherwise, if T
names atype
names theT
;type
names the signed integer type with smallestsizeof(T) == sizeof(type)
, with the sameT
.T
shall be is a n (possibly cv-qualified) integral type or enumeration type other than cv but not abool
type. template <class T>
struct make_unsigned;
If T
names a (possibly cv-qualified) unsigned integer type (6.9.2 [basic.fundamental]) thentype
names the type T
; otherwise, if T
names atype
names theT
;type
names the unsigned integer type with smallestsizeof(T) == sizeof(type)
, with the sameT
.T
shall be is a n (possibly cv-qualified) integral type or enumeration type other than cv but not abool
type.Change 24.7 [iterator.range] as indicated:
template<class C> constexpr auto ssize(const C& c) -> common_type_t<ptrdiff_t, make_signed_t<decltype(c.size())>>;-18- Returns Effects: Equivalent to:
return static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(c.size())>>>(c.size());
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4