From Jason Turner

[stream.iterators]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpjhdat1f9/{from.md → to.md} +20 -175
tmp/tmpjhdat1f9/{from.md → to.md} RENAMED
@@ -3,11 +3,11 @@
3
  To make it possible for algorithmic templates to work directly with
4
  input/output streams, appropriate iterator-like class templates are
5
  provided.
6
 
7
  ``` cpp
8
- partial_sum_copy(istream_iterator<double, char>(cin),
9
  istream_iterator<double, char>(),
10
  ostream_iterator<double, char>(cout, "\n"));
11
  ```
12
 
13
  reads a file containing floating point numbers from `cin`, and prints
@@ -194,11 +194,11 @@ namespace std {
194
  ostream_iterator<T,charT,traits>& operator*();
195
  ostream_iterator<T,charT,traits>& operator++();
196
  ostream_iterator<T,charT,traits>& operator++(int);
197
  private:
198
  basic_ostream<charT,traits>* out_stream; // exposition only
199
- const charT* delim; // exposition onlyr
200
  };
201
  }
202
  ```
203
 
204
  #### `ostream_iterator` constructors and destructor <a id="ostream.iterator.cons.des">[[ostream.iterator.cons.des]]</a>
@@ -238,11 +238,11 @@ ostream_iterator& operator=(const T& value);
238
 
239
  ``` cpp
240
  *out_stream << value;
241
  if (delim != 0)
242
  *out_stream << delim;
243
- return (*this);
244
  ```
245
 
246
  ``` cpp
247
  ostream_iterator& operator*();
248
  ```
@@ -262,17 +262,17 @@ The class template `istreambuf_iterator` defines an input iterator (
262
  [[input.iterators]]) that reads successive *characters* from the
263
  streambuf for which it was constructed. `operator*` provides access to
264
  the current input character, if any. `operator->` may return a proxy.
265
  Each time `operator++` is evaluated, the iterator advances to the next
266
  input character. If the end of stream is reached
267
- (streambuf_type::sgetc() returns `traits::eof()`), the iterator becomes
268
- equal to the *end-of-stream* iterator value. The default constructor
269
- `istreambuf_iterator()` and the constructor `istreambuf_iterator(0)`
270
- both construct an end-of-stream iterator object suitable for use as an
271
- end-of-range. All specializations of `istreambuf_iterator` shall have a
272
- trivial copy constructor, a `constexpr` default constructor, and a
273
- trivial destructor.
274
 
275
  The result of `operator*()` on an end-of-stream iterator is undefined.
276
  For any other iterator value a `char_type` value is returned. It is
277
  impossible to assign a character via an input iterator.
278
 
@@ -318,15 +318,14 @@ namespace std {
318
  #### Class template `istreambuf_iterator::proxy` <a id="istreambuf.iterator::proxy">[[istreambuf.iterator::proxy]]</a>
319
 
320
  ``` cpp
321
  namespace std {
322
  template <class charT, class traits = char_traits<charT> >
323
- class istreambuf_iterator<charT, traits>::proxy {
324
  charT keep_;
325
  basic_streambuf<charT,traits>* sbuf_;
326
- proxy(charT c,
327
- basic_streambuf<charT,traits>* sbuf)
328
  : keep_(c), sbuf_(sbuf) { }
329
  public:
330
  charT operator*() { return keep_; }
331
  };
332
  }
@@ -370,28 +369,28 @@ constructor argument `p`.
370
  ``` cpp
371
  charT operator*() const
372
  ```
373
 
374
  *Returns:* The character obtained via the `streambuf` member
375
- *`sbuf_`*`->sgetc()`.
376
 
377
  #### `istreambuf_iterator::operator++` <a id="istreambuf.iterator::op++">[[istreambuf.iterator::op++]]</a>
378
 
379
  ``` cpp
380
  istreambuf_iterator<charT,traits>&
381
  istreambuf_iterator<charT,traits>::operator++();
382
  ```
383
 
384
- *Effects:* *`sbuf_`*`->sbumpc()`.
385
 
386
  *Returns:* `*this`.
387
 
388
  ``` cpp
389
  proxy istreambuf_iterator<charT,traits>::operator++(int);
390
  ```
391
 
392
- *Returns:* `proxy(`*`sbuf_`*`->sbumpc(), `*`sbuf_`*`)`.
393
 
394
  #### `istreambuf_iterator::equal` <a id="istreambuf.iterator::equal">[[istreambuf.iterator::equal]]</a>
395
 
396
  ``` cpp
397
  bool equal(const istreambuf_iterator<charT,traits>& b) const;
@@ -458,30 +457,30 @@ to get a character value out of the output iterator.
458
 
459
  ``` cpp
460
  ostreambuf_iterator(ostream_type& s) noexcept;
461
  ```
462
 
463
- *Requires:* `s.rdbuf()` shall not null pointer.
464
 
465
- *Effects:* `:sbuf_(s.rdbuf()) {}`.
466
 
467
  ``` cpp
468
  ostreambuf_iterator(streambuf_type* s) noexcept;
469
  ```
470
 
471
  *Requires:* `s` shall not be a null pointer.
472
 
473
- *Effects:* `: `*`sbuf_`*`(s) {}`.
474
 
475
  #### `ostreambuf_iterator` operations <a id="ostreambuf.iter.ops">[[ostreambuf.iter.ops]]</a>
476
 
477
  ``` cpp
478
  ostreambuf_iterator<charT,traits>&
479
  operator=(charT c);
480
  ```
481
 
482
- *Effects:* If `failed()` yields `false`, calls *`sbuf_`*`->sputc(c)`;
483
  otherwise has no effect.
484
 
485
  *Returns:* `*this`.
486
 
487
  ``` cpp
@@ -500,161 +499,7 @@ ostreambuf_iterator<charT,traits>& operator++(int);
500
  ``` cpp
501
  bool failed() const noexcept;
502
  ```
503
 
504
  *Returns:* `true` if in any prior use of member `operator=`, the call to
505
- *`sbuf_`*`->sputc()` returned `traits::eof()`; or `false` otherwise.
506
 
507
- ### range access <a id="iterator.range">[[iterator.range]]</a>
508
-
509
- In addition to being available via inclusion of the `<iterator>` header,
510
- the function templates in [[iterator.range]] are available when any of
511
- the following headers are included: `<array>`, `<deque>`,
512
- `<forward_list>`, `<list>`, `<map>`, `<regex>`, `<set>`, `<string>`,
513
- `<unordered_map>`, `<unordered_set>`, and `<vector>`.
514
-
515
- ``` cpp
516
- template <class C> auto begin(C& c) -> decltype(c.begin());
517
- template <class C> auto begin(const C& c) -> decltype(c.begin());
518
- ```
519
-
520
- *Returns:* `c.begin()`.
521
-
522
- ``` cpp
523
- template <class C> auto end(C& c) -> decltype(c.end());
524
- template <class C> auto end(const C& c) -> decltype(c.end());
525
- ```
526
-
527
- *Returns:* `c.end()`.
528
-
529
- ``` cpp
530
- template <class T, size_t N> T* begin(T (&array)[N]);
531
- ```
532
-
533
- *Returns:* `array`.
534
-
535
- ``` cpp
536
- template <class T, size_t N> T* end(T (&array)[N]);
537
- ```
538
-
539
- *Returns:* `array + N`.
540
-
541
- <!-- Link reference definitions -->
542
- [back.insert.iter.cons]: #back.insert.iter.cons
543
- [back.insert.iter.op*]: #back.insert.iter.op*
544
- [back.insert.iter.op++]: #back.insert.iter.op++
545
- [back.insert.iter.op=]: #back.insert.iter.op=
546
- [back.insert.iter.ops]: #back.insert.iter.ops
547
- [back.insert.iterator]: #back.insert.iterator
548
- [back.inserter]: #back.inserter
549
- [bidirectional.iterators]: #bidirectional.iterators
550
- [containers]: containers.md#containers
551
- [copyassignable]: #copyassignable
552
- [equalitycomparable]: #equalitycomparable
553
- [forward.iterators]: #forward.iterators
554
- [front.insert.iter.cons]: #front.insert.iter.cons
555
- [front.insert.iter.op*]: #front.insert.iter.op*
556
- [front.insert.iter.op++]: #front.insert.iter.op++
557
- [front.insert.iter.op=]: #front.insert.iter.op=
558
- [front.insert.iter.ops]: #front.insert.iter.ops
559
- [front.insert.iterator]: #front.insert.iterator
560
- [front.inserter]: #front.inserter
561
- [input.iterators]: #input.iterators
562
- [insert.iter.cons]: #insert.iter.cons
563
- [insert.iter.op*]: #insert.iter.op*
564
- [insert.iter.op++]: #insert.iter.op++
565
- [insert.iter.op=]: #insert.iter.op=
566
- [insert.iter.ops]: #insert.iter.ops
567
- [insert.iterator]: #insert.iterator
568
- [insert.iterators]: #insert.iterators
569
- [inserter]: #inserter
570
- [iostream.format]: input.md#iostream.format
571
- [istream.iterator]: #istream.iterator
572
- [istream.iterator.cons]: #istream.iterator.cons
573
- [istream.iterator.ops]: #istream.iterator.ops
574
- [istreambuf.iterator]: #istreambuf.iterator
575
- [istreambuf.iterator.cons]: #istreambuf.iterator.cons
576
- [istreambuf.iterator::equal]: #istreambuf.iterator::equal
577
- [istreambuf.iterator::op!=]: #istreambuf.iterator::op!=
578
- [istreambuf.iterator::op*]: #istreambuf.iterator::op*
579
- [istreambuf.iterator::op++]: #istreambuf.iterator::op++
580
- [istreambuf.iterator::op==]: #istreambuf.iterator::op==
581
- [istreambuf.iterator::proxy]: #istreambuf.iterator::proxy
582
- [iterator.basic]: #iterator.basic
583
- [iterator.iterators]: #iterator.iterators
584
- [iterator.operations]: #iterator.operations
585
- [iterator.primitives]: #iterator.primitives
586
- [iterator.range]: #iterator.range
587
- [iterator.requirements]: #iterator.requirements
588
- [iterator.requirements.general]: #iterator.requirements.general
589
- [iterator.synopsis]: #iterator.synopsis
590
- [iterator.traits]: #iterator.traits
591
- [iterators]: #iterators
592
- [iterators.general]: #iterators.general
593
- [move.iter.nonmember]: #move.iter.nonmember
594
- [move.iter.op.+]: #move.iter.op.+
595
- [move.iter.op.+=]: #move.iter.op.+=
596
- [move.iter.op.-]: #move.iter.op.-
597
- [move.iter.op.-=]: #move.iter.op.-=
598
- [move.iter.op.comp]: #move.iter.op.comp
599
- [move.iter.op.const]: #move.iter.op.const
600
- [move.iter.op.conv]: #move.iter.op.conv
601
- [move.iter.op.decr]: #move.iter.op.decr
602
- [move.iter.op.incr]: #move.iter.op.incr
603
- [move.iter.op.index]: #move.iter.op.index
604
- [move.iter.op.ref]: #move.iter.op.ref
605
- [move.iter.op.star]: #move.iter.op.star
606
- [move.iter.op=]: #move.iter.op=
607
- [move.iter.ops]: #move.iter.ops
608
- [move.iter.requirements]: #move.iter.requirements
609
- [move.iterator]: #move.iterator
610
- [move.iterators]: #move.iterators
611
- [ostream.iterator]: #ostream.iterator
612
- [ostream.iterator.cons.des]: #ostream.iterator.cons.des
613
- [ostream.iterator.ops]: #ostream.iterator.ops
614
- [ostreambuf.iter.cons]: #ostreambuf.iter.cons
615
- [ostreambuf.iter.ops]: #ostreambuf.iter.ops
616
- [ostreambuf.iterator]: #ostreambuf.iterator
617
- [output.iterators]: #output.iterators
618
- [predef.iterators]: #predef.iterators
619
- [random.access.iterators]: #random.access.iterators
620
- [reverse.iter.cons]: #reverse.iter.cons
621
- [reverse.iter.conv]: #reverse.iter.conv
622
- [reverse.iter.op!=]: #reverse.iter.op!=
623
- [reverse.iter.op+]: #reverse.iter.op+
624
- [reverse.iter.op++]: #reverse.iter.op++
625
- [reverse.iter.op+=]: #reverse.iter.op+=
626
- [reverse.iter.op-]: #reverse.iter.op-
627
- [reverse.iter.op-=]: #reverse.iter.op-=
628
- [reverse.iter.op.star]: #reverse.iter.op.star
629
- [reverse.iter.op<]: #reverse.iter.op<
630
- [reverse.iter.op<=]: #reverse.iter.op<=
631
- [reverse.iter.op=]: #reverse.iter.op=
632
- [reverse.iter.op==]: #reverse.iter.op==
633
- [reverse.iter.op>]: #reverse.iter.op>
634
- [reverse.iter.op>=]: #reverse.iter.op>=
635
- [reverse.iter.opdiff]: #reverse.iter.opdiff
636
- [reverse.iter.opindex]: #reverse.iter.opindex
637
- [reverse.iter.opref]: #reverse.iter.opref
638
- [reverse.iter.ops]: #reverse.iter.ops
639
- [reverse.iter.opsum]: #reverse.iter.opsum
640
- [reverse.iter.requirements]: #reverse.iter.requirements
641
- [reverse.iterator]: #reverse.iterator
642
- [reverse.iterators]: #reverse.iterators
643
- [std.iterator.tags]: #std.iterator.tags
644
- [stream.buffers]: input.md#stream.buffers
645
- [stream.iterators]: #stream.iterators
646
- [swappable.requirements]: library.md#swappable.requirements
647
- [tab:iterator.bidirectional.requirements]: #tab:iterator.bidirectional.requirements
648
- [tab:iterator.forward.requirements]: #tab:iterator.forward.requirements
649
- [tab:iterator.input.requirements]: #tab:iterator.input.requirements
650
- [tab:iterator.output.requirements]: #tab:iterator.output.requirements
651
- [tab:iterator.random.access.requirements]: #tab:iterator.random.access.requirements
652
- [tab:iterator.requirements]: #tab:iterator.requirements
653
- [tab:iterators.lib.summary]: #tab:iterators.lib.summary
654
- [tab:iterators.relations]: #tab:iterators.relations
655
- [temp.inst]: temp.md#temp.inst
656
- [utility.arg.requirements]: library.md#utility.arg.requirements
657
-
658
- [^1]: This definition applies to pointers, since pointers are iterators.
659
- The effect of dereferencing an iterator that has been invalidated is
660
- undefined.
 
3
  To make it possible for algorithmic templates to work directly with
4
  input/output streams, appropriate iterator-like class templates are
5
  provided.
6
 
7
  ``` cpp
8
+ partial_sum(istream_iterator<double, char>(cin),
9
  istream_iterator<double, char>(),
10
  ostream_iterator<double, char>(cout, "\n"));
11
  ```
12
 
13
  reads a file containing floating point numbers from `cin`, and prints
 
194
  ostream_iterator<T,charT,traits>& operator*();
195
  ostream_iterator<T,charT,traits>& operator++();
196
  ostream_iterator<T,charT,traits>& operator++(int);
197
  private:
198
  basic_ostream<charT,traits>* out_stream; // exposition only
199
+ const charT* delim; // exposition only
200
  };
201
  }
202
  ```
203
 
204
  #### `ostream_iterator` constructors and destructor <a id="ostream.iterator.cons.des">[[ostream.iterator.cons.des]]</a>
 
238
 
239
  ``` cpp
240
  *out_stream << value;
241
  if (delim != 0)
242
  *out_stream << delim;
243
+ return *this;
244
  ```
245
 
246
  ``` cpp
247
  ostream_iterator& operator*();
248
  ```
 
262
  [[input.iterators]]) that reads successive *characters* from the
263
  streambuf for which it was constructed. `operator*` provides access to
264
  the current input character, if any. `operator->` may return a proxy.
265
  Each time `operator++` is evaluated, the iterator advances to the next
266
  input character. If the end of stream is reached
267
+ (`streambuf_type::sgetc()` returns `traits::eof()`), the iterator
268
+ becomes equal to the *end-of-stream* iterator value. The default
269
+ constructor `istreambuf_iterator()` and the constructor
270
+ `istreambuf_iterator(0)` both construct an end-of-stream iterator object
271
+ suitable for use as an end-of-range. All specializations of
272
+ `istreambuf_iterator` shall have a trivial copy constructor, a
273
+ `constexpr` default constructor, and a trivial destructor.
274
 
275
  The result of `operator*()` on an end-of-stream iterator is undefined.
276
  For any other iterator value a `char_type` value is returned. It is
277
  impossible to assign a character via an input iterator.
278
 
 
318
  #### Class template `istreambuf_iterator::proxy` <a id="istreambuf.iterator::proxy">[[istreambuf.iterator::proxy]]</a>
319
 
320
  ``` cpp
321
  namespace std {
322
  template <class charT, class traits = char_traits<charT> >
323
+ class istreambuf_iterator<charT, traits>::proxy { // exposition only
324
  charT keep_;
325
  basic_streambuf<charT,traits>* sbuf_;
326
+ proxy(charT c, basic_streambuf<charT,traits>* sbuf)
 
327
  : keep_(c), sbuf_(sbuf) { }
328
  public:
329
  charT operator*() { return keep_; }
330
  };
331
  }
 
369
  ``` cpp
370
  charT operator*() const
371
  ```
372
 
373
  *Returns:* The character obtained via the `streambuf` member
374
+ `sbuf_->sgetc()`.
375
 
376
  #### `istreambuf_iterator::operator++` <a id="istreambuf.iterator::op++">[[istreambuf.iterator::op++]]</a>
377
 
378
  ``` cpp
379
  istreambuf_iterator<charT,traits>&
380
  istreambuf_iterator<charT,traits>::operator++();
381
  ```
382
 
383
+ *Effects:* `sbuf_->sbumpc()`.
384
 
385
  *Returns:* `*this`.
386
 
387
  ``` cpp
388
  proxy istreambuf_iterator<charT,traits>::operator++(int);
389
  ```
390
 
391
+ *Returns:* `proxy(sbuf_->sbumpc(), sbuf_)`.
392
 
393
  #### `istreambuf_iterator::equal` <a id="istreambuf.iterator::equal">[[istreambuf.iterator::equal]]</a>
394
 
395
  ``` cpp
396
  bool equal(const istreambuf_iterator<charT,traits>& b) const;
 
457
 
458
  ``` cpp
459
  ostreambuf_iterator(ostream_type& s) noexcept;
460
  ```
461
 
462
+ *Requires:* `s.rdbuf()` shall not be a null pointer.
463
 
464
+ *Effects:* Initializes `sbuf_` with `s.rdbuf()`.
465
 
466
  ``` cpp
467
  ostreambuf_iterator(streambuf_type* s) noexcept;
468
  ```
469
 
470
  *Requires:* `s` shall not be a null pointer.
471
 
472
+ *Effects:* Initializes `sbuf_` with `s`.
473
 
474
  #### `ostreambuf_iterator` operations <a id="ostreambuf.iter.ops">[[ostreambuf.iter.ops]]</a>
475
 
476
  ``` cpp
477
  ostreambuf_iterator<charT,traits>&
478
  operator=(charT c);
479
  ```
480
 
481
+ *Effects:* If `failed()` yields `false`, calls `sbuf_->sputc(c)`;
482
  otherwise has no effect.
483
 
484
  *Returns:* `*this`.
485
 
486
  ``` cpp
 
499
  ``` cpp
500
  bool failed() const noexcept;
501
  ```
502
 
503
  *Returns:* `true` if in any prior use of member `operator=`, the call to
504
+ `sbuf_->sputc()` returned `traits::eof()`; or `false` otherwise.
505