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.

3036. polymorphic_allocator::destroy is extraneous

Section: 20.12.3 [mem.poly.allocator.class] Status: WP Submitter: Casey Carter Opened: 2017-11-15 Last modified: 2020-11-15

Priority: 3

View all other issues in [mem.poly.allocator.class].

View all issues with WP status.

Discussion:

polymorphic_allocator's member function destroy is exactly equivalent to the default implementation of destroy in allocator_traits (20.10.8.3 [allocator.traits.members] para 6). It should be struck from polymorphic_allocator as it provides no value.

[28-Nov-2017 Mailing list discussion - set priority to P3]

PJ says that Dinkumware is shipping an implementation of polymorphic_allocator with destroy, so removing it would be a breaking change for him.

[2019-02; Kona Wednesday night issue processing]

Status to Open; revisit once P0339 lands. Poll taken was 5-3-2 in favor of removal.

[2020-10-05; Jonathan provides new wording]

Previous resolution [SUPERSEDED]:

Wording relative to N4700.

  1. Strike the declaration of destroy from the synopsis of class polymorphic_allocator in 20.12.3 [mem.poly.allocator.class]:

    template <class T1, class T2, class U, class V>
      void construct(pair<T1,T2>* p, pair<U, V>&& pr);
    
    template <class T>
      void destroy(T* p);
    
    polymorphic_allocator select_on_container_copy_construction() const;
    
  2. Strike the specification of destroy in 20.12.3.3 [mem.poly.allocator.mem]:

    […]
    template <class T>
      void destroy(T* p);
    

    14 Effects: As if by p->~T().

    […]

[2020-10-11; Reflector poll]

Moved to Tentatively Ready after seven votes in favour.

[2020-11-09 Approved In November virtual meeting. Status changed: Tentatively Ready → WP.]

Proposed resolution:

Wording relative to N4861.

  1. Strike the declaration of destroy from the synopsis of class polymorphic_allocator in 20.12.3 [mem.poly.allocator.class]:

    template <class T1, class T2, class U, class V>
      void construct(pair<T1,T2>* p, pair<U, V>&& pr);
    
    template <class T>
      void destroy(T* p);
    
    polymorphic_allocator select_on_container_copy_construction() const;
    
  2. Adjust the specification of delete_object in 20.12.3.3 [mem.poly.allocator.mem]:

    template <class T>
      void delete_object(T* p);
    

    -13- Effects: Equivalent to:

      allocator_traits<polymorphic_allocator>::destroy(*this, p);
      deallocate_object(p);
    
  3. Strike the specification of destroy in 20.12.3.3 [mem.poly.allocator.mem]:

    […]
    template <class T>
      void destroy(T* p);
    

    -17- Effects: As if by p->~T().

    […]
  4. Add a new subclause to Annex D:

    D.?? Deprecated polymorphic_allocator member function

    -1- The following member is declared in addition to those members specified in 20.12.3.3 [mem.poly.allocator.mem]:

    
    namespace std::pmr {
      template<class Tp = byte>
      class polymorphic_allocator {
      public:
        template <class T>
          void destroy(T* p);
      };
    }
    
    
    template <class T>
      void destroy(T* p);
    

    -1- Effects: As if by p->~T().