std::allocator's constructors should be constexpr
Geoffrey Romer

Created on 2017-11-11.00:00:00 last changed 6 months ago


Date: 2018-03-18.16:03:30

Proposed resolution:

This wording is relative to N4700.

  1. Change in [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);
Date: 2018-03-17.00:00:00

[ 2018-3-17 Adopted in Jacksonville ]

Date: 2017-11-25.00:00:00

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

Date: 2017-11-11.00:00:00

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.

Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2018-03-18 16:03:30adminsetmessages: + msg9748
2018-03-18 16:03:30adminsetstatus: voting -> wp
2018-02-12 01:13:49adminsetstatus: ready -> voting
2017-11-25 11:20:28adminsetmessages: + msg9569
2017-11-25 11:20:28adminsetstatus: new -> ready
2017-11-13 20:01:20adminsetmessages: + msg9557
2017-11-11 00:00:00admincreate