Title
Constexpr allocation for literal types
Status
ready
Section
7.7 [expr.const]
Submitter
Jiang An

Created on 2025-11-01.00:00:00 last changed 1 month ago

Messages

Date: 2025-11-05.12:07:23

Proposed resolution (approved by CWG 2025-11-04):

Change in 7.7 [expr.const] paragraph 14 as follows:

For the purposes of determining whether an expression E is a core constant expression, the evaluation of the body of a member function of std::allocator<T> as defined in 20.2.10.2 [allocator.members], where T is a literal type, is ignored.
Date: 2025-11-05.12:07:23

(From submission #792.)

Consider:

  #include <locale>
  #include <memory>

  static_assert([]{
   auto a = std::allocator<std::locale>{};
   a.deallocate(a.allocate(42), 42);
   return true;
  }());

The type std::locale is not a literal type, yet this is accepted by all implementations.

History
Date User Action Args
2025-11-07 22:16:49adminsetstatus: tentatively ready -> ready
2025-11-05 12:07:23adminsetmessages: + msg8216
2025-11-05 12:07:23adminsetstatus: open -> tentatively ready
2025-11-01 00:00:00admincreate