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.

3303. Bad "constexpr" marker for destroy/destroy_n

Section: 20.2.2 [memory.syn] Status: C++20 Submitter: Jens Maurer Opened: 2019-10-10 Last modified: 2021-02-25

Priority: 0

View all other issues in [memory.syn].

View all issues with C++20 status.


This issue was submitted as editorial issue cplusplus/draft#3181 but is considered non-editorial.

P0784R7, approved in Cologne, added "constexpr" markers to the overloads of destroy and destroy_n taking an ExecutionPolicy parameter. This seems to be in error; parallel algorithms should not be marked "constexpr". (None of the parallel algorithms in <algorithm> is marked "constexpr".)

[2019-11 Marked as 'Ready' during Monday issue prioritization in Belfast]

Proposed resolution:

This wording is relative to N4830.

  1. Modify 20.2.2 [memory.syn], header <memory> synopsis, as indicated:

    namespace std {
      // 27.11.9 [specialized.destroy], destroy
      template<class T>
        constexpr void destroy_at(T* location);
      template<class ForwardIterator>
        constexpr void destroy(ForwardIterator first, ForwardIterator last);
      template<class ExecutionPolicy, class ForwardIterator>
        constexpr void destroy(ExecutionPolicy&& exec, // see 27.3.5 [algorithms.parallel.overloads]
                               ForwardIterator first, ForwardIterator last);
      template<class ForwardIterator, class Size>
        constexpr ForwardIterator destroy_n(ForwardIterator first, Size n);
      template<class ExecutionPolicy, class ForwardIterator, class Size>
        constexpr ForwardIterator destroy_n(ExecutionPolicy&& exec, // see 27.3.5 [algorithms.parallel.overloads]
                                            ForwardIterator first, Size n);