Title
regex_token_iterator should use initializer_list
Status
c++11
Section
[re.tokiter]
Submitter
Daniel Krügler

Created on 2008-09-26.00:00:00 last changed 161 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

  1. […]

    1. In [re.tokiter]/6 and the list [re.tokiter.cnstr]/10-11 insert the following constructor declaration between the already existing ones accepting a std::vector and a C array of int, resp.:

      regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
                           const regex_type& re,
                           initializer_list<int> submatches,
                           regex_constants::match_flag_type m =
                             regex_constants::match_default);
      
    2. In [re.tokiter.cnstr]/12 change the last sentence

      The third and fourth constructor initializes the member subs to hold a copy of the sequence of integer values pointed to by the iterator range [&submatches,&submatches + N) and [submatches.begin(),submatches.end()), respectively.

Date: 2010-10-21.18:28:33

[ Batavia (2009-05): ]

We strongly recommend alternative B of the proposed resolution in order that existing code not be broken. With that understanding, move to Tentatively Ready.

Original proposed wording:


    1. In [re.tokiter]/6 and the list [re.tokiter.cnstr]/10-11 change the constructor declaration:

      template <std::size_t N>
      regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
                           const regex_type& re,
                           const int (&submatches)[N] initializer_list<int> submatches,
                           regex_constants::match_flag_type m =
                             regex_constants::match_default);
      
    2. In [re.tokiter.cnstr]/12 change the last sentence

      The third constructor initializes the member subs to hold a copy of the sequence of integer values pointed to by the iterator range [&submatches.begin(), &submatches.end() + N).


    1. In [re.tokiter]/6 and the list [re.tokiter.cnstr]/10-11 insert the following constructor declaration between the already existing ones accepting a std::vector and a C array of int, resp.:

      regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
                           const regex_type& re,
                           initializer_list<int> submatches,
                           regex_constants::match_flag_type m =
                             regex_constants::match_default);
      
    2. In [re.tokiter.cnstr]/12 change the last sentence

      The third and fourth constructor initializes the member subs to hold a copy of the sequence of integer values pointed to by the iterator range [&submatches,&submatches + N) and [submatches.begin(),submatches.end()), respectively.

Date: 2008-09-26.00:00:00

Addresses UK 319

Construction of a regex_token_iterator ([re.tokiter]/6+) usually requires the provision of a sequence of integer values, which can currently be done via a std::vector<int> or a C array of int. Since the introduction of initializer_list in the standard it seems much more reasonable to provide a corresponding constructor that accepts an initializer_list<int> instead. This could be done as a pure addition or one could even consider replacement. The author suggests the replacement strategy (A), but provides an alternative additive proposal (B) as a fall-back, because of the handiness of this range type:

History
Date User Action Args
2011-08-23 20:07:26adminsetstatus: wp -> c++11
2010-10-21 18:28:33adminsetmessages: + msg4315
2010-10-21 18:28:33adminsetmessages: + msg4314
2008-09-26 00:00:00admincreate