Title
[fund.ts.v3] propagate_const's swap's noexcept specification needs to be constrained and use a trait
Status
new
Section
[propagate_const.modifiers][propagate_const.algorithms]
Submitter
Thomas Köppe

Created on 2020-02-29.00:00:00 last changed 4 days ago

Messages

Date: 2020-03-30.17:15:09

Proposed resolution:

This wording is relative to N4840.

  1. Modify [propagate_const.overview], class template propagate_const synopsis, as indicated:

    // [propagate_const.modifiers], propagate_const modifiers
    constexpr void swap(propagate_const& pt) noexcept(see belowis_nothrow_swappable_v<T>);
    
  2. Modify [propagate_const.modifiers] as indicated:

    constexpr void swap(propagate_const& pt) noexcept(see belowis_nothrow_swappable_v<T>);
    

    -2- The constant-expression in the exception-specification is noexcept(swap(t_, pt.t_)).

    -3- Effects: swap(t_, pt.t_).

  3. Modify [propagate_const.algorithms] as indicated:

    template <class T>
      constexpr void swap(propagate_const<T>& pt1, propagate_const<T>& pt2) noexcept(see below);
    

    -?- Constraints: is_swappable_v<T> is true.

    -2- The constant-expression in the exception-specification is noexcept(pt1.swap(pt2)).

    -3- Effects: pt1.swap(pt2).

    -?- Remarks: The expression inside noexcept is equivalent to:

    noexcept(pt1.swap(pt2))
    

Date: 2020-03-15.00:00:00

[ 2020-03-30; Reflector discussion ]

This issue has very much overlap with LWG 2561, especially now that the library fundamentals has been rebased to C++20 the there reported problem for the corresponding swap problem for optional is now moot. During the reflector discussion of this issue here it was also observed that the free swap template for propagate_const needs to be constrained. This has been done below in the revised wording which also attempts to use a similar style as the IS.

Date: 2020-03-30.16:14:06

Addresses: fund.ts.v3

In the Fundamentals TS, the noexcept specifications of both the member and non-member swap functions for propagate_const are using the old, ill-formed pattern of attempting to use "noexcept(swap(...))" as the boolean predicate. According to LWG 2456, this is ill-formed, and a resolution such as in P0185R1 is required.

Previous resolution [SUPERSEDED]:

This wording is relative to N4840.

  1. Modify [propagate_const.syn], header <experimental/propagate_const> synopsis, as indicated:

    // [propagate_const.algorithms], propagate_const specialized algorithms
    template <class T>
      constexpr void swap(propagate_const<T>& pt, propagate_const<T>& pt2) noexcept(see belowis_nothrow_swappable_v<T>);
    
  2. Modify [propagate_const.overview], class template propagate_const synopsis, as indicated:

    // [propagate_const.modifiers], propagate_const modifiers
    constexpr void swap(propagate_const& pt) noexcept(see belowis_nothrow_swappable_v<T>);
    
  3. Modify [propagate_const.modifiers] as indicated:

    constexpr void swap(propagate_const& pt) noexcept(see belowis_nothrow_swappable_v<T>);
    

    -2- The constant-expression in the exception-specification is noexcept(swap(t_, pt.t_)).

    -3- Effects: swap(t_, pt.t_).

  4. Modify [propagate_const.algorithms] as indicated:

    template <class T>
      constexpr void swap(propagate_const<T>& pt1, propagate_const<T>& pt2) noexcept(see belowis_nothrow_swappable_v<T>);
    

    -2- The constant-expression in the exception-specification is noexcept(pt1.swap(pt2)).

    -3- Effects: pt1.swap(pt2).

History
Date User Action Args
2020-03-30 16:14:06adminsetmessages: + msg11183
2020-03-01 13:23:26adminsetmessages: + msg11158
2020-02-29 00:00:00admincreate