Title
repeat_view's piecewise constructor is missing Postconditions
Status
c++23
Section
[range.repeat.view]
Submitter
Hewill Kang

Created on 2022-09-12.00:00:00 last changed 12 months ago

Messages

Date: 2023-02-13.11:31:32

Proposed resolution:

This wording is relative to N4917.

  1. Modify [range.repeat.view] as shown:

    template<class... TArgs, class... BoundArgs>
      requires constructible_from<T, TArgs...> &&
               constructible_from<Bound, BoundArgs...>
    constexpr explicit repeat_view(piecewise_construct_t,
      tuple<Targs...> value_args, tuple<BoundArgs...> bound_args = tuple<>{});
    

    -5- Effects: Initializes value_ with arguments of types TArgs... obtained by forwarding the elements of value_args make_from_tuple<T>(std::move(value_args)) and initializes bound_ with arguments of types BoundArgs... obtained by forwarding the elements of bound_args. (Here, forwarding an element x of type U within a tuple object means calling std::forward<U>(x).) make_from_tuple<Bound>(std::move(bound_args)). The behavior is undefined if Bound is not unreachable_sentinel_t and bound_ is negative.

Date: 2023-02-13.00:00:00

[ 2023-02-13 Approved at February 2023 meeting in Issaquah. Status changed: Immediate → WP. ]

Date: 2023-02-09.02:35:59

[ Issaquah 2023-02-07; LWG ]

Move to Immediate for C++23

Date: 2023-01-15.00:00:00

[ 2023-01-11; Jonathan provides new wording requested by LWG ]

Date: 2022-09-15.00:00:00

[ 2022-09-23; Jonathan provides improved wording ]

Previous resolution [SUPERSEDED]:

This wording is relative to N4917.

  1. Modify [range.repeat.view] as shown:

    template<class... WArgs, class... BoundArgs>
      requires constructible_from<W, WArgs...> &&
               constructible_from<Bound, BoundArgs...>
    constexpr explicit repeat_view(piecewise_construct_t,
      tuple<Wargs...> value_args, tuple<BoundArgs...> bound_args = tuple<>{});
    

    -?- Preconditions: Bound is unreachable_sentinel_t, or the initialization of bound_ yields a non-negative value.

    -5- Effects: Initializes value_ with arguments of types WArgs... obtained by forwarding the elements of value_args and initializes bound_ with arguments of types BoundArgs... obtained by forwarding the elements of bound_args. (Here, forwarding an element x of type U within a tuple object means calling std::forward<U>(x).)

Date: 2022-09-15.00:00:00

[ 2022-09-23; Reflector poll ]

Set priority to 2 after reflector poll.

This is trying to state a requirement on users, but that's not what Postconditions: means. Should be something more like:
Precondition: If Bound is not unreachable_sentinel_t, the bound_ ≥ 0 after its initialization from bound_args.

Previous resolution [SUPERSEDED]:

This wording is relative to n4917.

  1. Modify [range.repeat.view] as shown:

    template<class... WArgs, class... BoundArgs>
      requires constructible_from<W, WArgs...> &&
               constructible_from<Bound, BoundArgs...>
    constexpr explicit repeat_view(piecewise_construct_t,
      tuple<Wargs...> value_args, tuple<BoundArgs...> bound_args = tuple<>{});
    

    -5- Effects: Initializes value_ with arguments of types WArgs... obtained by forwarding the elements of value_args and initializes bound_ with arguments of types BoundArgs... obtained by forwarding the elements of bound_args. (Here, forwarding an element x of type U within a tuple object means calling std::forward<U>(x).)

    -?- Postconditions: If Bound is not unreachable_sentinel_t, bound_ ≥ 0.

Date: 2022-09-12.00:00:00

The first two value-bound pair constructors of repeat_view have the Preconditions that the integer-like object bound must be non-negative. However, the piecewise constructor does not mention the valid values for bound_args. It would be nice to add a Postconditions that the initialized bound_ must be greater than or equal to 0 here.

History
Date User Action Args
2023-11-22 15:47:43adminsetstatus: wp -> c++23
2023-02-13 11:31:32adminsetmessages: + msg13384
2023-02-13 11:31:32adminsetstatus: immediate -> wp
2023-02-09 02:35:59adminsetmessages: + msg13304
2023-02-09 02:35:59adminsetstatus: new -> immediate
2023-01-11 18:22:42adminsetmessages: + msg13203
2022-09-23 22:31:18adminsetmessages: + msg12805
2022-09-23 15:44:07adminsetmessages: + msg12804
2022-09-12 10:20:23adminsetmessages: + msg12759
2022-09-12 00:00:00admincreate