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

3035. std::allocator's constructors should be constexpr

Section: 19.10.10 [default.allocator] Status: WP Submitter: Geoffrey Romer Opened: 2017-11-11 Last modified: 2018-03-24

Priority: 0

View all other issues in [default.allocator].

View all issues with WP status.


std::allocator's constructors should be constexpr. It's expected to be an empty class as far as I know, so this should impose no implementation burden, and it would be useful to permit guaranteed static initialization of objects that need to hold a std::allocator, but don't have to actually use it until after construction.

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

[2018-3-17 Adopted in Jacksonville]

Proposed resolution:

This wording is relative to N4700.

  1. Change in 19.10.10 [default.allocator] as indicated:

    namespace std {
      template <class T> class allocator {
        using value_type = T;
        using propagate_on_container_move_assignment = true_type;
        using is_always_equal = true_type;
        constexpr allocator() noexcept;
        constexpr allocator(const allocator&) noexcept;
        constexpr template <class U> allocator(const allocator<U>&) noexcept;
        T* allocate(size_t n);
        void deallocate(T* p, size_t n);