Title
Non-array ssize overload is underconstrained
Status
new
Section
[iterator.range]
Submitter
Casey Carter

Created on 2019-09-27.00:00:00, last changed 2019-10-09.18:10:13.

Messages

Date: 2019-10-09.18:10:13

Proposed resolution:

This wording is relative to N4830.

  1. Modify [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: decltype(c.size()) is a (possibly cv-qualified) integral or enumeration type but not a bool type.

    -18- Returns:

    static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(c.size())>>>(c.size())
    

Date: 2019-09-27.00:00:00

The overload of ssize specified in [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 ([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.

History
Date User Action Args
2019-10-09 18:10:13adminsetmessages: + msg10690
2019-09-27 00:00:00admincreate