2476. scoped_allocator_adaptor is not assignable

Section: 20.5.1 [allocator.adaptor.syn] Status: C++17 Submitter: Jonathan Wakely Opened: 2015-03-02 Last modified: 2017-07-30

Priority: 0

View all issues with C++17 status.

Discussion:

The class definition in 20.5.1 [allocator.adaptor.syn] declares a move constructor, which means that the copy assignment operator is defined as deleted, and no move assignment operator is declared.

This means a scoped_allocator_adaptor is not assignable, and a container using scoped_allocator_adaptor<A...> may not be CopyAssignable or MoveAssignable (depending on the propagate_on_container_xxxx_assignment traits of the outer and inner allocator types).

[2015-04-03 Howard comments]

If the contained allocators are not assignable, I think we need the ability of = default to automagically become = delete. My concern is that is_copy_assignable<scoped_allocator_adaptor<CustomAllocator>>::value get the right answer for both cases:

  1. is_copy_assignable<CustomAllocator>::value is true.

  2. is_copy_assignable<CustomAllocator>::value is false.

If we allow the vendor to declare and provide the copy assignment operator, the chance of getting #2 correct goes to zero.

Previous resolution [SUPERSEDED]:

This wording is relative to N4296.

  1. Add to the synopsis in 20.5.1 [allocator.adaptor.syn]/1 [Editorial remark: The proposed wording does not explicitly specify the semantics of the added copy/move assignment operators, based on 16.3.3.4 [functions.within.classes] p1, which says:

    "For the sake of exposition, Clauses 18 through 30 and Annex D do not describe copy/move constructors, assignment operators, or (non-virtual) destructors with the same apparent semantics as those that can be generated by default (12.1, 12.4, 12.8)."

    end remark]:

    […]
    template <class OuterA2>
      scoped_allocator_adaptor(
        scoped_allocator_adaptor<OuterA2, InnerAllocs...>&& other) noexcept;
    
    scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&);
    scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&);
    
    ~scoped_allocator_adaptor();
    […]
    

[2015-05, Lenexa]

Move to Immediate.

Proposed resolution:

This wording is relative to N4296.

  1. Add to the synopsis in 20.5.1 [allocator.adaptor.syn]/1:

    […]
    template <class OuterA2>
      scoped_allocator_adaptor(
        scoped_allocator_adaptor<OuterA2, InnerAllocs...>&& other) noexcept;
    
    scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default;
    scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default;
    
    ~scoped_allocator_adaptor();
    […]