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

3000. monotonic_memory_resource::do_is_equal uses dynamic_cast unnecessarily

Section: 20.4.6.3 [mem.res.monotonic.buffer.mem] Status: C++20 Submitter: Pablo Halpern Opened: 2017-07-14 Last modified: 2021-02-25

Priority: 0

View all other issues in [mem.res.monotonic.buffer.mem].

View all issues with C++20 status.

Discussion:

Section [mem.res.monotonic.buffer.mem], paragraph 11 says

bool do_is_equal(const memory_resource& other) const noexcept override;

Returns: this == dynamic_cast<const monotonic_buffer_resource*>(&other).

The dynamic_cast adds nothing of value. It is an incorrect cut-and-paste from an example do_is_equal for a more complex resource.

[2017-07-16, Tim Song comments]

The pool resource classes appear to also have this issue.

[2017-09-18, Casey Carter expands PR to cover the pool resources.]

Previous resolution: [SUPERSEDED]
  1. Edit 20.4.6.3 [mem.res.monotonic.buffer.mem] as indicated:

    bool do_is_equal(const memory_resource& other) const noexcept override;
    

    Returns: this == dynamic_cast<const monotonic_buffer_resource*>(&other).

[ 2017-11-01 Moved to Tentatively Ready after 7 positive votes for P0 on c++std-lib. ]

[2018-3-17 Adopted in Jacksonville]

Proposed resolution:

This resolution is relative to N4687.

  1. Edit 20.4.5.4 [mem.res.pool.mem] as indicated:

    bool synchronized_pool_resource::do_is_equal(const memory_resource& other) const noexcept override;
        const memory_resource& other) const noexcept override;
    

    Returns: this == dynamic_cast<const synchronized_pool_resource*>(&other).

  2. Strike 20.4.5.4 [mem.res.pool.mem] paragraph 10, and the immediately preceding declaration of unsynchronized_pool_resource::do_is_equal.

  3. Edit 20.4.6.3 [mem.res.monotonic.buffer.mem] as indicated:

    bool do_is_equal(const memory_resource& other) const noexcept override;
    

    Returns: this == dynamic_cast<const monotonic_buffer_resource*>(&other).