Title
[arrays.ts] std::dynarray defines its initializer-list constructor in terms of a non-existent constructor
Status
open
Section
[dynarray] [container.requirements]
Submitter
Povilas Kanapickas

Created on 2013-05-22.00:00:00 last changed 128 months ago

Messages

Date: 2014-06-06.21:18:30

Proposed resolution:

  1. Add the following to the std::dynarray synopsis at [dynarray.overview]:

    namespace std {
      template <class T>
      class dynarray {
        […]
        // 23.3.4.2 construct/copy/destroy:
        […]
        template <class ForwardIterator>
        dynarray(ForwardIterator first, ForwardIterator last);
        template <class ForwardIterator, class Alloc>
        dynarray(ForwardIterator first, ForwardIterator last, const Alloc& alloc);
        […]
      };
    }
    
  2. Add the following to [dynarray.cons] after p. 8:

    template <class ForwardIterator>
    dynarray(ForwardIterator first, ForwardIterator last);
    

    -?- Requires: T shall meet the CopyConstructible requirements.

    -?- Effects: Allocates storage for distance(first, last) elements. The distance(first, last) elements of the dynarray are direct-initialized ([dcl.init]) with the corresponding elements from the range [first,last). May or may not invoke the global operator new.

    -?- Complexity: distance(first, last).

    -?- Throws: std::bad_array_length when the size requested is larger than implementable, std::bad_alloc when there is insufficient memory.

  3. Add the following to the list of constructors at [dynarray.cons] before p. 9:

    template <class Alloc>
    dynarray(size_type c, const Alloc& alloc);
    template <class Alloc>
    dynarray(size_type c, const T& v, const Alloc& alloc);
    template <class Alloc>
    dynarray(const dynarray& d, const Alloc& alloc);
    template <class Alloc>
    dynarray(initializer_list<T>, const Alloc& alloc);
    template <class ForwardIterator, class Alloc>
    dynarray(ForwardIterator first, ForwardIterator last, const Alloc& alloc);
    
Date: 2014-06-06.00:00:00

[ 2014-06-06 pre-Rapperswill ]

This issue has been reopened as arrays-ts.

Date: 2014-06-06.21:18:30

[ 2013-09 Chicago: ]

Move to Deferred. This feature will ship after C++14 and should be revisited then.

Date: 2014-06-07.16:56:56

Addresses: arrays.ts

std::dynarray member listing at [dynarray.overview] includes this constructor:

dynarray(initializer_list<T>);

Also, [dynarray.overview] p. 2 says:

Unless otherwise specified, all dynarray operations have the same requirements and semantics as specified in 23.2.

The constructor in question isn't mentioned in [dynarray.cons] or anywhere else. This means requirements from [container.requirements] apply. However, Table 100 in [sequence.reqmts] says:

X(il)               Equivalent to X(il.begin(), il.end())

std::dynarray does not provide this constructor.

The proposed resolution below adds the missing constructor and a complementary constructor with an allocator parameter. The new constructors, differently from the rest of containers, accept iterators that have forward iterator category. This is needed because the size requirements must be known in order to allocate appropriately-sized storage.

An alternative resolution could be to properly specify the initializer-list constructor.

History
Date User Action Args
2014-06-06 21:18:30adminsetmessages: + msg6992
2014-06-06 21:18:30adminsetstatus: deferred -> open
2013-09-26 11:12:18adminsetmessages: + msg6628
2013-09-26 11:12:18adminsetstatus: new -> deferred
2013-06-30 15:53:15adminsetmessages: + msg6538
2013-05-22 00:00:00admincreate