Movatterモバイル変換


[0]ホーム

URL:



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

2748.swappable traits foroptionals

Section: 22.5.3.5[optional.swap], 22.5.10[optional.specalg]Status:C++17Submitter: Agustín K-ballo BergéOpened: 2016-07-19Last modified: 2017-07-30

Priority:0

View all issues withC++17 status.

Discussion:

optional didn't benefit from the wording modifications by P0185 "Adding [nothrow_]swappable traits"; as such, it suffers from LWG2456(i), and does not play nice with swappable traits.

[2016-07 Chicago]

Monday: P0 - tentatively ready

Proposed resolution:

This wording is relative to N4606.

  1. Modify [optional.object.swap] as indicated:

    void swap(optional<T>& rhs) noexcept(see below);

    […]

    -4-Remarks: The expression insidenoexcept is equivalent to:

    is_nothrow_move_constructible_v<T> &&is_nothrow_swappable_v<T>noexcept(swap(declval<T&>(), declval<T&>()))
  2. Modify 22.5.10[optional.specalg] as indicated:

    template <class T> void swap(optional<T>& x, optional<T>& y) noexcept(noexcept(x.swap(y)));

    -1-Effects: Callsx.swap(y).

    -?-Remarks: This function shall not participate in overload resolution unlessis_move_constructible_v<T> istrue andis_swappable_v<T> istrue.


[8]ページ先頭

©2009-2026 Movatter.jp