Title
scoped_allocator_adaptor is not assignable
Status
c++17
Section
[allocator.adaptor.syn]
Submitter
Jonathan Wakely

Created on 2015-03-02.00:00:00 last changed 89 months ago

Messages

Date: 2015-05-07.19:30:46

Proposed resolution:

This wording is relative to N4296.

  1. Add to the synopsis in [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();
    […]
    
Date: 2015-05-07.19:30:46

[ 2015-05, Lenexa ]

Move to Immediate.

Date: 2015-04-03.00:00:00

[ 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 [allocator.adaptor.syn]/1 [Editorial remark: The proposed wording does not explicitly specify the semantics of the added copy/move assignment operators, based on [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();
    […]
    
Date: 2015-03-31.21:33:45

The class definition in [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).

History
Date User Action Args
2017-07-30 20:15:43adminsetstatus: wp -> c++17
2015-10-27 16:52:45adminsetstatus: ready -> wp
2015-05-20 14:24:57adminsetstatus: immediate -> ready
2015-05-07 19:30:46adminsetmessages: + msg7368
2015-05-07 19:30:46adminsetstatus: new -> immediate
2015-04-03 11:59:01adminsetstatus: ready -> new
2015-04-02 17:06:48adminsetmessages: + msg7306
2015-04-02 17:06:48adminsetstatus: new -> ready
2015-03-31 21:28:07adminsetmessages: + msg7293
2015-03-02 00:00:00admincreate