This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of TS status.

2526. [fund.ts.v2] Incorrect precondition for experimental::function::swap

Section: 4.2.2 [fund.ts.v2::func.wrap.func.mod] Status: TS Submitter: Tim Song Opened: 2015-08-04 Last modified: 2017-07-30

Priority: 0

View all issues with TS status.

Discussion:

Addresses: fund.ts.v2

4.2.2 [fund.ts.v2::func.wrap.func.mod] says that the precondition of swap is

this->get_memory_resource() == other->get_memory_resource()

That compares two pointers and so requires the memory resource used by *this and other to be the exact same object. That doesn't seem correct (for one, it would essentially outlaw swapping all functions constructed with "plain" allocators, since they would each have their own resource_adaptor object and so the pointers will not compare equal). Presumably the intent is to compare the memory_resources for equality.

Also, other is a reference, not a pointer.

[2015-09-11, Telecon]

Move to Tentatively Ready

[2015-10-26]

Daniel adjusts wording to lib. fund. v2.

Proposed resolution:

This wording is relative to N4529.

  1. Edit 4.2.2 [fund.ts.v2::func.wrap.func.mod] as indicated:

    void swap(function& other);
    

    -2- Requires: *this->get_memory_resource() == *other->.get_memory_resource().

    -3- Effects: Interchanges the targets of *this and other.

    -4- Remarks: The allocators of *this and other are not interchanged.