This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++20 status.

3364. Initialize data members of ranges and their iterators

Section: 25.7.11.2 [range.take.while.view], 25.7.12.2 [range.drop.view], 25.7.13.2 [range.drop.while.view], 25.7.23.3 [range.elements.iterator] Status: C++20 Submitter: Johel Ernesto Guerrero Peña Opened: 2020-01-07 Last modified: 2021-02-25

Priority: 0

View all other issues in [range.take.while.view].

View all issues with C++20 status.

Discussion:

Before P1035 was accepted, no data member in [ranges] whose type could potentially be an aggregate or fundamental type was left without initializer. P1035 left some such data members without initializer, so it is possible to have them have indeterminate values. We propose restoring consistency.

[2020-01-14 Status set to Tentatively Ready after five positive votes on the reflector.]

Proposed resolution:

This wording is relative to N4842.

  1. Modify 25.7.11.2 [range.take.while.view] as follows:

    class take_while_view : public view_interface<take_while_view<V, Pred>> {
      template<bool> class sentinel;                      // exposition only
    
      V base_ = V();                                      // exposition only
      semiregular-box<Pred> pred_;                        // exposition only
    
    public:
    
  2. Modify 25.7.12.2 [range.drop.view] as follows:

    private:
      V base_ = V();                                     // exposition only
      range_difference_t<V> count_ = 0;                  // exposition only
    };
    
  3. Modify 25.7.13.2 [range.drop.while.view] as follows:

    private:
      V base_ = V();                                     // exposition only
      semiregular-box<Pred> pred_;                       // exposition only
    };
    
  4. Modify 25.7.23.3 [range.elements.iterator] as follows:

    class elements_view<V, N>::iterator {                // exposition only
      using base-t = conditional_t<Const, const V, V>;
      friend iterator<!Const>;
    
      iterator_t<base-t> current_ = iterator_t<base-t>();
    public: