From Jason Turner

[array.overview]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp_rrxvtxo/{from.md → to.md} +40 -51
tmp/tmp_rrxvtxo/{from.md → to.md} RENAMED
@@ -1,23 +1,15 @@
1
  #### Class template `array` overview <a id="array.overview">[[array.overview]]</a>
2
 
3
  The header `<array>` defines a class template for storing fixed-size
4
- sequences of objects. An `array` supports random access iterators. An
5
- instance of `array<T, N>` stores `N` elements of type `T`, so that
6
- `size() == N` is an invariant. The elements of an `array` are stored
7
- contiguously, meaning that if `a` is an `array<T, N>` then it obeys the
8
- identity `&a[n] == &a[0] + n` for all `0 <= n < N`.
9
 
10
- An `array` is an aggregate ([[dcl.init.aggr]]) that can be initialized
11
- with the syntax
12
-
13
- ``` cpp
14
- array<T, N> a = { initializer-list };
15
- ```
16
-
17
- where *initializer-list* is a comma-separated list of up to `N` elements
18
- whose types are convertible to `T`.
19
 
20
  An `array` satisfies all of the requirements of a container and of a
21
  reversible container ([[container.requirements]]), except that a
22
  default constructed `array` object is not empty and that `swap` does not
23
  have constant complexity. An `array` satisfies some of the requirements
@@ -29,65 +21,62 @@ semantic information.
29
  ``` cpp
30
  namespace std {
31
  template <class T, size_t N>
32
  struct array {
33
  // types:
34
- typedef T& reference;
35
- typedef const T& const_reference;
36
- typedef implementation-defined // type of array::iterator iterator;
37
- typedef implementation-defined // type of array::const_iterator const_iterator;
38
- typedef size_t size_type;
39
- typedef ptrdiff_t difference_type;
40
- typedef T value_type;
41
- typedef T* pointer;
42
- typedef const T* const_pointer;
43
- typedef std::reverse_iterator<iterator> reverse_iterator;
44
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
45
-
46
- T elems[N]; // exposition only
47
 
48
  // no explicit construct/copy/destroy for aggregate type
49
 
50
  void fill(const T& u);
51
- void swap(array&) noexcept(noexcept(swap(declval<T&>(), declval<T&>())));
52
 
53
  // iterators:
54
- iterator begin() noexcept;
55
- const_iterator begin() const noexcept;
56
- iterator end() noexcept;
57
- const_iterator end() const noexcept;
58
 
59
- reverse_iterator rbegin() noexcept;
60
- const_reverse_iterator rbegin() const noexcept;
61
- reverse_iterator rend() noexcept;
62
- const_reverse_iterator rend() const noexcept;
63
 
64
- const_iterator cbegin() const noexcept;
65
- const_iterator cend() const noexcept;
66
- const_reverse_iterator crbegin() const noexcept;
67
- const_reverse_iterator crend() const noexcept;
68
 
69
  // capacity:
 
70
  constexpr size_type size() const noexcept;
71
  constexpr size_type max_size() const noexcept;
72
- constexpr bool empty() const noexcept;
73
 
74
  // element access:
75
- reference operator[](size_type n);
76
  constexpr const_reference operator[](size_type n) const;
77
- reference at(size_type n);
78
  constexpr const_reference at(size_type n) const;
79
- reference front();
80
  constexpr const_reference front() const;
81
- reference back();
82
  constexpr const_reference back() const;
83
 
84
- T * data() noexcept;
85
- const T * data() const noexcept;
86
  };
 
 
 
87
  }
88
  ```
89
 
90
- The member variable `elems` is shown for exposition only, to emphasize
91
- that `array` is a class aggregate. The name `elems` is not part of
92
- `array`’s interface.
93
-
 
1
  #### Class template `array` overview <a id="array.overview">[[array.overview]]</a>
2
 
3
  The header `<array>` defines a class template for storing fixed-size
4
+ sequences of objects. An `array` is a contiguous container (
5
+ [[container.requirements.general]]). An instance of `array<T, N>` stores
6
+ `N` elements of type `T`, so that `size() == N` is an invariant.
 
 
7
 
8
+ An `array` is an aggregate ([[dcl.init.aggr]]) that can be
9
+ list-initialized with up to `N` elements whose types are convertible to
10
+ `T`.
 
 
 
 
 
 
11
 
12
  An `array` satisfies all of the requirements of a container and of a
13
  reversible container ([[container.requirements]]), except that a
14
  default constructed `array` object is not empty and that `swap` does not
15
  have constant complexity. An `array` satisfies some of the requirements
 
21
  ``` cpp
22
  namespace std {
23
  template <class T, size_t N>
24
  struct array {
25
  // types:
26
+ using value_type = T;
27
+ using pointer = T*;
28
+ using const_pointer = const T*;
29
+ using reference = T&;
30
+ using const_reference = const T&;
31
+ using size_type = size_t;
32
+ using difference_type = ptrdiff_t;
33
+ using iterator = implementation-defined // type of array::iterator; // see [container.requirements]
34
+ using const_iterator = implementation-defined // type of array::const_iterator; // see [container.requirements]
35
+ using reverse_iterator = std::reverse_iterator<iterator>;
36
+ using const_reverse_iterator = std::reverse_iterator<const_iterator>;
 
 
37
 
38
  // no explicit construct/copy/destroy for aggregate type
39
 
40
  void fill(const T& u);
41
+ void swap(array&) noexcept(is_nothrow_swappable_v<T>);
42
 
43
  // iterators:
44
+ constexpr iterator begin() noexcept;
45
+ constexpr const_iterator begin() const noexcept;
46
+ constexpr iterator end() noexcept;
47
+ constexpr const_iterator end() const noexcept;
48
 
49
+ constexpr reverse_iterator rbegin() noexcept;
50
+ constexpr const_reverse_iterator rbegin() const noexcept;
51
+ constexpr reverse_iterator rend() noexcept;
52
+ constexpr const_reverse_iterator rend() const noexcept;
53
 
54
+ constexpr const_iterator cbegin() const noexcept;
55
+ constexpr const_iterator cend() const noexcept;
56
+ constexpr const_reverse_iterator crbegin() const noexcept;
57
+ constexpr const_reverse_iterator crend() const noexcept;
58
 
59
  // capacity:
60
+ constexpr bool empty() const noexcept;
61
  constexpr size_type size() const noexcept;
62
  constexpr size_type max_size() const noexcept;
 
63
 
64
  // element access:
65
+ constexpr reference operator[](size_type n);
66
  constexpr const_reference operator[](size_type n) const;
67
+ constexpr reference at(size_type n);
68
  constexpr const_reference at(size_type n) const;
69
+ constexpr reference front();
70
  constexpr const_reference front() const;
71
+ constexpr reference back();
72
  constexpr const_reference back() const;
73
 
74
+ constexpr T * data() noexcept;
75
+ constexpr const T * data() const noexcept;
76
  };
77
+
78
+ template<class T, class... U>
79
+ array(T, U...) -> array<T, 1 + sizeof...(U)>;
80
  }
81
  ```
82