25.6 Stream iterators [stream.iterators] C++N4910:2022 (648) p1019.cpp

# はじめに(Introduction)

N4910  Working Draft, Standard for Programming Language C++

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/n4910.pdf

n4910は、ISO/IEC JTC1 SC22 WG21の作業原案(Working Draft)です。
公式のISO/IEC 14882原本ではありません。
ISO/IEC JTC1 SC22 WG21では、可能な限り作業文書を公開し、幅広い意見を求めています。
一連の記事はコード断片をコンパイルできる形にする方法を検討してコンパイル、リンク、実行して、規格案の原文と処理系(g++, Clang++)との違いを確認し、技術内容を検討し、ISO/IEC JTC1 SC22 WG21にフィードバックするために用います。
また、CERT C++, MISRA C++等のコーディング標準のコード断片をコンパイルする際の参考にさせていただこうと考えています。CERT C++, MISRA C++が標準化の動きとの時間的なずれがあれば確認できれば幸いです。また、boostライブラリとの関連、Linux OS, TOPPERSカーネル、g++(GCC), clang++(LLVM）との関係も調査中です。
何か、抜け漏れ、耳より情報がありましたらおしらせくださると幸いです。

 <この項は書きかけです。順次追記します。>

## 背景(back ground)
C/C++でコンパイルエラーが出ると、途方にくれることがしばしばあります。
何回かに１回は、該当するエラーが検索できます。
ただ、条件が違っていて、そこでの修正方法では目的を達成しないこともしばしばです。いろいろな条件のコンパイルエラーとその対応方法について、広く記録することによって、いつか同じエラーに遭遇した時にやくに立つことを目指しています。

この半年の間で、三度、自分のネットでの記録に助けられたことがあります。
また過去に解決できなかった記録を１０種類以上、最近になって解決できたことがあります。それは、主に次の３つの情報に基づいています。

https://stackoverflow.com

http://ja.cppreference.com/

cpprefjp - C++日本語リファレンス

https://cpprefjp.github.io/

コンパイラの実装状況

https://cpprefjp.github.io/implementation-status.html

また
https://researchmap.jp/joub9b3my-1797580/#_1797580
に記載したサイトのお世話になっています。

## 作業方針(sequence)
Clang++では-std=c++03, C++2bの2種類
g++では-std=c++03, c++2bの２種類
でコンパイルし、

１）コンパイルエラーを収集する。
２）コンパイルエラーをなくす方法を検討する。
コンパイルエラーになる例を示すだけが目的のコードは、コンパイルエラーをなくすのではなく、コンパイルエラーの種類を収集するだけにする。
文法を示すのが目的のコード場合に、コンパイルエラーをなくすのに手間がかかる場合は、順次作業します。
３）リンクエラーをなくす方法を検討する。
文法を示すのが目的のコード場合に、リンクエラーをなくすのに手間がかかる場合は、順次作業します。
４）意味のある出力を作る。
コンパイル、リンクが通っても、意味のある出力を示そうとすると、コンパイル・リンクエラーが出て収拾できそうにない場合がある。順次作業します。

１）だけのものから４）まで進んだものと色々ある状態です。一歩でも前に進むご助言をお待ちしています。「検討事項」の欄に現状を記録するようにしています。

### C++N4910:2022 Standard Working Draft on ISO/IEC 14882(0) sample code compile list  

https://qiita.com/kaizen_nagoya/items/fc957ddddd402004bb91

### C++N4741, 2018 Standard Working Draft on ISO/IEC 14882 sample code compile list
https://qiita.com/kaizen_nagoya/items/3294c014044550896010

### C++N4606, 2016符号断片編纂一覧(example code compile list)
C++N4606, 2016 Working Draft 2016, ISO/IEC 14882, C++ standard(1) Example code compile list
https://qiita.com/kaizen_nagoya/items/df5d62c35bd6ed1c3d43/

### C++N3242, 2011 sample code compile list on clang++ and g++
https://qiita.com/kaizen_nagoya/items/685b5c1a2c17c1bf1318

## 編纂器(Compiler)
### clang++ --version
> Debian clang version 14.0.5-++20220610033153+c12386ae247c-1~exp1~20220610153237.151
Target: x86_64-pc-linux-gnu, Thread model: posix, InstalledDir: /usr/bin

### g++- --version
> g++ (GCC) 12.1.0  Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# 25.6 Stream iterators [stream.iterators] C++N4910:2022 (648) p1019.cpp

## 算譜(source code)

```c++:p1019.cpp
// C++N4910 Committee Draft, Standard for Programming Language C++
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/n4910.pdf
const char * n4910 = "25.6 Stream iterators [stream.iterators] C++N4910:2022 (648) p1019.cpp";
// Debian clang version 14.0.5-++20220610033153+c12386ae247c-
// g++ (GCC) 12.1.0 Copyright (C) 2022 Free Software Foundation, Inc.
// Edited by Dr. OGAWA Kiyoshi. Compile procedure and results record.
// C++N4910:2022 Standard Working Draft on ISO/IEC 14882(0) sample code compile list
// https://qiita.com/kaizen_nagoya/items/fc957ddddd402004bb91

#include "N4910.h"

using namespace std;

//  25.6.1 General [stream.iterators.general]
//  To make it possible for algorithmic templates to work directly with input/output streams, appropriate iterator-like class templates are provided.
// [Example 1:
partial_sum(istream_iterator<double, char>(cin),
            istream_iterator<double, char>(),
            ostream_iterator<double, char>(cout, "\n"));
// reads a file containing floating-point numbers from cin, and prints the partial sums onto cout.
// 25.6.2 Class template istream_iterator [istream.iterator]
// 25.6.2.1 General [istream.iterator.general]
//  The class template istream_iterator is an input iterator (25.3.5.3) that reads successive elements from the input stream for which it was constructed.
namespace std {
template<class T, class charT = char, class traits = char_traits<charT>,
         class Distance = ptrdiff_t>
class istream_iterator {
public:
    using iterator_category = input_iterator_tag;
    using value_type =T;
    using difference_type = Distance;
    using pointer = const T*;
    using reference = const T&;
    using char_type = charT;
    using traits_type = traits;
    using istream_type = basic_istream<charT,traits>;
    constexpr istream_iterator();
    constexpr istream_iterator(default_sentinel_t);
    istream_iterator(istream_type& s);
    istream_iterator(const istream_iterator& x) = default;
    ~istream_iterator()
        = default;
    istream_iterator& operator=(const istream_iterator&) = default;
    const T& operator*() const;
    const T* operator->() const;
    istream_iterator& operator++();
    istream_iterator  operator++(int);
    friend bool operator==(const istream_iterator& i, default_sentinel_t);
private:
    basic_istream<charT,traits>* in_stream; // exposition only T value; // exposition only
};
}
// The type T shall meet the Cpp17DefaultConstructible, Cpp17CopyConstructible, and Cpp17CopyAssignable requirements.
// 25.6.2.2 Constructors and destructor [istream.iterator.cons]
constexpr istream_iterator();
constexpr istream_iterator(default_sentinel_t);
// Effects: Constructs the end-of-stream iterator, value-initializing value. Postconditions: in_stream == nullptr is true.
// Remarks: If the initializer T() in the declaration auto x = T(); is a constant initializer (7.7), then these constructors are constexpr constructors.
istream_iterator(istream_type& s);
// Effects: Initializes in_stream with addressof(s), value-initializes value, and then calls operator++().
istream_iterator(const istream_iterator& x) = default;
// Postconditions: in_stream == x.in_stream is true.
// Remarks: If is_trivially_copy_constructible_v<T> is true, then this constructor is trivial.
~istream_iterator() = default;
// Remarks: If is_trivially_destructible_v<T> is true, then this destructor is trivial.
// 25.6.2.3 Operations [istream.iterator.ops]
const T& operator*() const;
// Preconditions: in_stream != nullptr is true. Returns: value.
const T* operator->() const;
// Preconditions: in_stream != nullptr is true. Returns: addressof(value).
istream_iterator& operator++();
// Preconditions: in_stream != nullptr is true. Effects: Equivalent to:
if (!(*in_stream >> value))
    in_stream = nullptr;
// Returns: *this.
istream_iterator operator++(int);
// Preconditions: in_stream != nullptr is true. Effects: Equivalent to:
istream_iterator tmp = *this;
++*this;
return tmp;
template<class T, class charT, class traits, class Distance>
bool operator==(const istream_iterator<T,charT,traits,Distance>& x,
                const istream_iterator<T,charT,traits,Distance>& y);
// Returns: x.in_stream == y.in_stream.
friend bool operator==(const istream_iterator& i, default_sentinel_t);
// Returns: !i.in_stream.
// 25.6.3 Class template ostream_iterator [ostream.iterator]
// 25.6.3.1 General [ostream.iterator.general]
// ostream_iterator writes (using operator<<) successive elements onto the output stream from which it was constructed. If it was constructed with charT* as a constructor argument, this string, called a delimiter string, is written to the stream after every T is written.
// ffects: Initializes out_stream with addressof(s) and delim with nullptr.
namespace std {
template<class T, class charT = char, class traits = char_traits<charT>>
class ostream_iterator {
public:
    using iterator_category = output_iterator_tag;
    using value_type = void;
    using difference_type = ptrdiff_t;
    using pointer  = void;
    using reference = void;
    using char_type  = charT;
    using traits_type = traits;
    using ostream_type = basic_ostream<charT,traits>;
    ostream_iterator(ostream_type& s);
    ostream_iterator(ostream_type& s, const charT* delimiter);
    ostream_iterator(const ostream_iterator& x);
    ~ostream_iterator();
    ostream_iterator& operator=(const ostream_iterator&) = default;
    ostream_iterator& operator=(const T& value);
    ostream_iterator& operator*();
    ostream_iterator& operator++();
    ostream_iterator& operator++(int);
private:
    basic_ostream<charT,traits>* out_stream;
    const charT* delim;
};
}
// 25.6.3.2 Constructors and destructor [ostream.iterator.cons.des]
ostream_iterator(ostream_type& s);
// exposition only // exposition only
ostream_iterator(ostream_type& s, const charT* delimiter);
// Effects: Initializes out_stream with addressof(s) and delim with delimiter.
// 25.6.3.3 Operations [ostream.iterator.ops]
ostream_iterator& operator=(const T& value);
// Effects: As if by:
*out_stream << value;
if (delim)
    *out_stream << delim;
return *this;
ostream_iterator& operator*();
// Returns: *this. ostream_iterator& operator++();
ostream_iterator& operator++(int);
// Returns: *this.
// 25.6.4 Class template istreambuf_iterator [istreambuf.iterator]
// 25.6.4.1 General [istreambuf.iterator.general]
//  The class template istreambuf_iterator defines an input iterator (25.3.5.3) that reads successive characters from the streambuf for which it was constructed. operator* provides access to the current input character, if any. Each time operator++ is evaluated, the iterator advances to the next input character. If the end of stream is reached (streambuf_type::sgetc() returns traits::eof()), the iterator becomes equal to the end-of-stream iterator value. The default constructor istreambuf_iterator() and the constructor istreambuf_iterator(nullptr) both construct an end-of-stream iterator object suitable for use as an end-of-range. All specializations of istreambuf_iterator shall have a trivial copy constructor, a constexpr default constructor, and a trivial destructor.
// The result of operator*() on an end-of-stream iterator is undefined. For any other iterator value a char_type value is returned. It is impossible to assign a character via an input iterator.
namespace std {
template<class charT, class traits = char_traits<charT>>
class istreambuf_iterator {
public:
    using iterator_category = input_iterator_tag;
    using value_type = charT;
    using difference_type = typename traits::off_type;
    using pointer = unspecified;
    using reference  = charT;
    using char_type = charT;
    using traits_type  = traits;
    using int_type = typename traits::int_type;
    using streambuf_type = basic_streambuf<charT,traits>;
    using istream_type = basic_istream<charT,traits>;
    class proxy ;
// exposition only
    constexpr istreambuf_iterator() noexcept;
    constexpr istreambuf_iterator(default_sentinel_t) noexcept;
    istreambuf_iterator(const istreambuf_iterator&) noexcept = default;
    ~istreambuf_iterator() = default;
    istreambuf_iterator(istream_type& s) noexcept;
    istreambuf_iterator(streambuf_type* s) noexcept;
    istreambuf_iterator(const proxy& p) noexcept;
    istreambuf_iterator& operator=(const istreambuf_iterator&) noexcept = default;
    charT operator*() const;
    istreambuf_iterator& operator++();
    proxy operator++(int);
    bool equal(const istreambuf_iterator& b) const;
    friend bool operator==(const istreambuf_iterator& i, default_sentinel_t s);
private:
    streambuf_type* sbuf_; // exposition only
};
}
// 25.6.4.2 Class istreambuf_iterator::proxy [istreambuf.iterator.proxy]
//  Class istreambuf_iterator<charT,traits>::proxy is for exposition only. An implementation is per- mitted to provide equivalent functionality without providing a class with this name. Class istreambuf_- iterator<charT, traits>::proxy provides a temporary placeholder as the return value of the post- increment operator (operator++). It keeps the character pointed to by the previous value of the iterator for some possible future access to get the character.
namespace std {
template<class charT, class traits>
class istreambuf_iterator<charT, traits>::proxy { // exposition only
    charT keep_;
    basic_streambuf<charT,traits>* sbuf_;
    proxy(charT c, basic_streambuf<charT,traits>* sbuf)
        : keep_(c), sbuf_(sbuf) { }
public:
    charT operator*() {
        return keep_;
    }
};
}
// 25.6.4.3 Constructors [istreambuf.iterator.cons]
// For each istreambuf_iterator constructor in this subclause, an end-of-stream iterator is constructed if and only if the exposition-only member sbuf_ is initialized with a null pointer value.
constexpr istreambuf_iterator() noexcept;
constexpr istreambuf_iterator(default_sentinel_t) noexcept;
// Effects: Initializes sbuf_ with nullptr. istreambuf_iterator(istream_type& s) noexcept;
// Effects: Initializes sbuf_ with s.rdbuf(). istreambuf_iterator(streambuf_type* s) noexcept;
// Effects: Initializes sbuf_ with s. istreambuf_iterator(const proxy& p) noexcept;
//  The class template ostreambuf_iterator writes successive characters onto the output stream from which it was constructed.
namespace std {
template<class charT, class traits = char_traits<charT>>
class ostreambuf_iterator {
public:
    using iterator_category = output_iterator_tag;
// Effects: Initializes sbuf_ with p.sbuf_.
// 25.6.4.4 Operations [istreambuf.iterator.ops]
    charT operator*() const;
// Returns: The character obtained via the streambuf member sbuf_->sgetc().
    istreambuf_iterator& operator++();
// Effects: As if by sbuf_->sbumpc(). Returns: *this.
    proxy operator++(int);
// Returns: proxy(sbuf_->sbumpc(), sbuf_).
    bool equal(const istreambuf_iterator& b) const;
// Returns: true if and only if both iterators are at end-of-stream, or neither is at end-of-stream, regardless of what streambuf object they use.
    template<class charT, class traits>
    bool operator==(const istreambuf_iterator<charT,traits>& a,
                    const istreambuf_iterator<charT,traits>& b);
// Returns: a.equal(b).
    friend bool operator==(const istreambuf_iterator& i, default_sentinel_t s);
// Returns: i.equal(s).
// 25.6.5 Class template ostreambuf_iterator [ostreambuf.iterator]
// 25.6.5.1 General [ostreambuf.iterator.general]
    using value_type = void;
    using difference_type = ptrdiff_t;
    using pointer  = void;
    using reference = void;
    using char_type  = charT;
    using traits_type   = traits;
    using streambuf_type = basic_streambuf<charT,traits>;
    using ostream_type = basic_ostream<charT,traits>;
    ostreambuf_iterator(ostream_type& s) noexcept;
    ostreambuf_iterator(streambuf_type* s) noexcept;
    ostreambuf_iterator& operator=(charT c);
    ostreambuf_iterator& operator*();
    ostreambuf_iterator& operator++();
    ostreambuf_iterator& operator++(int);
    bool failed() const noexcept;
private:
    streambuf_type* sbuf_;
};
}
// 25.6.5.2 Constructors
// exposition only
ostreambuf_iterator(ostream_type& s) noexcept;
// Preconditions: s.rdbuf() is not a null pointer. Effects: Initializes sbuf_ with s.rdbuf().
ostreambuf_iterator(streambuf_type* s) noexcept;
//Preconditions: s is not a null pointer. Effects: Initializes sbuf_ with s.
// 25.6.5.3 Operations
ostreambuf_iterator& operator=(charT c);
// Effects: If failed() yields false, calls sbuf_->sputc(c); otherwise has no effect. Returns: *this.
ostreambuf_iterator& operator*();
// Returns: *this. ostreambuf_iterator& operator++();
ostreambuf_iterator& operator++(int);
// Returns: *this.
bool failed() const noexcept;
// Returns: true if in any prior use of member operator=, the call to sbuf_->sputc() returned traits::eof(); or false otherwise.
int main() {
    cout  <<  n4910 << endl;
    return EXIT_SUCCESS;
}
```

## 編纂・実行結果(compile and go)

```ubuntu:bash
$ clang++ p1019.cpp -std=03 -o p1019l -I. -Wall
In file included from p1019.cpp:10:
In file included from ./N4910.h:11:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/atomic:38:
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/c++0x_warning.h:32:2: error: This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support \
 ^
p1019.cpp:17:6: error: C++ requires a type specifier for all declarations
     partial_sum(istream_iterator<double, char>(cin),
     ^
p1019.cpp:17:18: error: use of undeclared identifier 'istream_iterator'; did you mean 'istreambuf_iterator'?
     partial_sum(istream_iterator<double, char>(cin),
                 ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/streambuf_iterator.h:50:11: note: 'istreambuf_iterator' declared here
    class istreambuf_iterator
          ^
p1019.cpp:18:8: error: use of undeclared identifier 'istream_iterator'; did you mean 'istreambuf_iterator'?
       istream_iterator<double, char>(),
       ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/streambuf_iterator.h:50:11: note: 'istreambuf_iterator' declared here
    class istreambuf_iterator
          ^
p1019.cpp:19:8: error: use of undeclared identifier 'ostream_iterator'; did you mean 'ostreambuf_iterator'?
       ostream_iterator<double, char>(cout, "\n"));
       ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/streambuf_iterator.h:239:11: note: 'ostreambuf_iterator' declared here
    class ostreambuf_iterator
          ^
p1019.cpp:29:36: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
         using iterator_category = input_iterator_tag;
                                   ^
p1019.cpp:30:19: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using value_type =T;
                  ^
p1019.cpp:31:25: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using difference_type = Distance;
                        ^
p1019.cpp:32:17: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using pointer = const T*;
                ^
p1019.cpp:33:19: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using reference = const T&;
                  ^
p1019.cpp:34:19: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using char_type = charT;
                  ^
p1019.cpp:35:21: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using traits_type = traits;
                    ^
p1019.cpp:36:22: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using istream_type = basic_istream<charT,traits>;
                     ^
p1019.cpp:37:1: error: unknown type name 'constexpr'
constexpr istream_iterator();
^
p1019.cpp:37:11: error: constructor cannot have a return type
constexpr istream_iterator();
          ^~~~~~~~~~~~~~~~
p1019.cpp:38:1: error: unknown type name 'constexpr'
constexpr istream_iterator(default_sentinel_t); istream_iterator(istream_type& s);
^
p1019.cpp:38:28: error: unknown type name 'default_sentinel_t'
constexpr istream_iterator(default_sentinel_t); istream_iterator(istream_type& s);
                           ^
p1019.cpp:38:11: error: constructor cannot have a return type
constexpr istream_iterator(default_sentinel_t); istream_iterator(istream_type& s);
          ^~~~~~~~~~~~~~~~
p1019.cpp:39:47: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
istream_iterator(const istream_iterator& x) = default; ~istream_iterator() 
                                              ^
p1019.cpp:40:3: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
= default;
  ^
p1019.cpp:41:56: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
istream_iterator& operator=(const istream_iterator&) = default;
                                                       ^
p1019.cpp:46:60: error: unknown type name 'default_sentinel_t'
         friend bool operator==(const istream_iterator& i, default_sentinel_t);
                                                           ^
p1019.cpp:52:4: error: unknown type name 'constexpr'
   constexpr istream_iterator();
   ^
p1019.cpp:53:4: error: unknown type name 'constexpr'
   constexpr istream_iterator(default_sentinel_t);
   ^
p1019.cpp:53:31: error: unknown type name 'default_sentinel_t'
   constexpr istream_iterator(default_sentinel_t);
                              ^
p1019.cpp:56:18: error: unknown type name 'istream_type'
istream_iterator(istream_type& s);
                 ^
p1019.cpp:56:1: error: C++ requires a type specifier for all declarations
istream_iterator(istream_type& s);
^
p1019.cpp:58:24: error: use of class template 'istream_iterator' requires template arguments
istream_iterator(const istream_iterator& x) = default;
                       ^
p1019.cpp:27:14: note: template is declared here
       class istream_iterator {
             ^
p1019.cpp:58:1: error: C++ requires a type specifier for all declarations
istream_iterator(const istream_iterator& x) = default;
^
p1019.cpp:58:47: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
istream_iterator(const istream_iterator& x) = default;
                                              ^
p1019.cpp:61:2: error: identifier 'istream_iterator' after '~' in destructor name does not name a type
~istream_iterator() = default;
 ^
p1019.cpp:27:14: note: non-type declaration found by destructor name lookup
       class istream_iterator {
             ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
12 warnings and 20 errors generated.
$ clang++ p1019.cpp -std=2b -o p1019l -I. -Wall
p1019.cpp:17:6: error: no template named 'partial_sum'; did you mean 'partial_sort'?
     partial_sum(istream_iterator<double, char>(cin),
     ^~~~~~~~~~~
     partial_sort
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_algo.h:4697:5: note: 'partial_sort' declared here
    partial_sort(_RandomAccessIterator __first,
    ^
p1019.cpp:17:6: error: C++ requires a type specifier for all declarations
     partial_sum(istream_iterator<double, char>(cin),
     ^
p1019.cpp:27:14: error: redefinition of 'istream_iterator'
       class istream_iterator {
             ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stream_iterator.h:49:11: note: previous definition is here
    class istream_iterator
          ^
p1019.cpp:52:14: error: deduction guide must be declared in the same scope as template 'std::istream_iterator'
   constexpr istream_iterator();
             ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stream_iterator.h:49:11: note: template is declared here
    class istream_iterator
          ^
p1019.cpp:52:14: error: deduction guide cannot be declared 'constexpr'
   constexpr istream_iterator();
   ~~~~~~~~~ ^
p1019.cpp:52:14: error: deduction guide declaration without trailing return type
p1019.cpp:53:14: error: deduction guide must be declared in the same scope as template 'std::istream_iterator'
   constexpr istream_iterator(default_sentinel_t);
             ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stream_iterator.h:49:11: note: template is declared here
    class istream_iterator
          ^
p1019.cpp:53:14: error: deduction guide cannot be declared 'constexpr'
   constexpr istream_iterator(default_sentinel_t);
   ~~~~~~~~~ ^
p1019.cpp:53:14: error: deduction guide declaration without trailing return type
p1019.cpp:56:18: error: unknown type name 'istream_type'
istream_iterator(istream_type& s);
                 ^
p1019.cpp:56:1: error: deduction guide must be declared in the same scope as template 'std::istream_iterator'
istream_iterator(istream_type& s);
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stream_iterator.h:49:11: note: template is declared here
    class istream_iterator
          ^
p1019.cpp:56:1: error: deduction guide declaration without trailing return type
istream_iterator(istream_type& s);
^
p1019.cpp:58:24: error: use of class template 'istream_iterator' requires template arguments; argument deduction not allowed in function prototype
istream_iterator(const istream_iterator& x) = default;
                       ^~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stream_iterator.h:49:11: note: template is declared here
    class istream_iterator
          ^
p1019.cpp:58:1: error: deduction guide must be declared in the same scope as template 'std::istream_iterator'
istream_iterator(const istream_iterator& x) = default;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stream_iterator.h:49:11: note: template is declared here
    class istream_iterator
          ^
p1019.cpp:58:1: error: deduction guide declaration without trailing return type
istream_iterator(const istream_iterator& x) = default;
^
p1019.cpp:58:1: error: deduction guide cannot have a function definition
p1019.cpp:61:2: error: identifier 'istream_iterator' after '~' in destructor name does not name a type
~istream_iterator() = default;
 ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stream_iterator.h:49:11: note: non-type declaration found by destructor name lookup
    class istream_iterator
          ^
p1019.cpp:64:7: error: unknown type name 'T'
const T& operator*() const;
      ^
p1019.cpp:64:22: error: non-member function cannot have 'const' qualifier
const T& operator*() const;
                     ^~~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

$ g++ p1019.cpp -std=03 -o p1019g -I. -Wall
In file included from /usr/local/include/c++/12.1.0/atomic:38,
                 from N4910.h:11,
                 from p1019.cpp:10:
/usr/local/include/c++/12.1.0/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
   32 | #error This file requires compiler and library support \
      |  ^~~~~
p1019.cpp:37:1: warning: identifier 'constexpr' is a keyword in C++11 [-Wc++11-compat]
   37 | constexpr istream_iterator();
      | ^~~~~~~~~
p1019.cpp:71:17: warning: identifier 'nullptr' is a keyword in C++11 [-Wc++11-compat]
   71 |     in_stream = nullptr;
      |                 ^~~~~~~
p1019.cpp:145:33: warning: identifier 'noexcept' is a keyword in C++11 [-Wc++11-compat]
  145 | constexpr istreambuf_iterator() noexcept;
      |                                 ^~~~~~~~
p1019.cpp:17:17: error: expected constructor, destructor, or type conversion before '(' token
   17 |      partial_sum(istream_iterator<double, char>(cin),
      |                 ^
p1019.cpp:29:16: error: expected nested-name-specifier before 'iterator_category'
   29 |          using iterator_category = input_iterator_tag;
      |                ^~~~~~~~~~~~~~~~~
p1019.cpp:30:7: error: expected nested-name-specifier before 'value_type'
   30 | using value_type =T;
      |       ^~~~~~~~~~
p1019.cpp:31:7: error: expected nested-name-specifier before 'difference_type'
   31 | using difference_type = Distance;
      |       ^~~~~~~~~~~~~~~
p1019.cpp:32:7: error: expected nested-name-specifier before 'pointer'
   32 | using pointer = const T*;
      |       ^~~~~~~
p1019.cpp:33:7: error: expected nested-name-specifier before 'reference'
   33 | using reference = const T&;
      |       ^~~~~~~~~
p1019.cpp:34:7: error: expected nested-name-specifier before 'char_type'
   34 | using char_type = charT;
      |       ^~~~~~~~~
p1019.cpp:35:7: error: expected nested-name-specifier before 'traits_type'
   35 | using traits_type = traits;
      |       ^~~~~~~~~~~
p1019.cpp:36:7: error: expected nested-name-specifier before 'istream_type'
   36 | using istream_type = basic_istream<charT,traits>;
      |       ^~~~~~~~~~~~
p1019.cpp:37:1: error: 'constexpr' does not name a type
   37 | constexpr istream_iterator();
      | ^~~~~~~~~
p1019.cpp:37:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1019.cpp:38:1: error: 'constexpr' does not name a type
   38 | constexpr istream_iterator(default_sentinel_t); istream_iterator(istream_type& s);
      | ^~~~~~~~~
p1019.cpp:38:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1019.cpp:38:78: error: expected ')' before '&' token
   38 | constexpr istream_iterator(default_sentinel_t); istream_iterator(istream_type& s);
      |                                                                 ~            ^
      |                                                                              )
p1019.cpp:39:47: warning: defaulted and deleted functions only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
   39 | istream_iterator(const istream_iterator& x) = default; ~istream_iterator()
      |                                               ^~~~~~~
p1019.cpp:40:3: warning: defaulted and deleted functions only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
   40 | = default;
      |   ^~~~~~~
p1019.cpp:41:56: warning: defaulted and deleted functions only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
   41 | istream_iterator& operator=(const istream_iterator&) = default;
      |                                                        ^~~~~~~
p1019.cpp:46:60: error: 'default_sentinel_t' has not been declared
   46 |          friend bool operator==(const istream_iterator& i, default_sentinel_t);
      |                                                            ^~~~~~~~~~~~~~~~~~
p1019.cpp:46:78: warning: friend declaration 'bool std::operator==(const istream_iterator<T, charT, traits, Distance>&, int)' declares a non-template function [-Wnon-template-friend]
   46 |          friend bool operator==(const istream_iterator& i, default_sentinel_t);
      |                                                                              ^
p1019.cpp:46:78: note: (if this is not what you intended, make sure the function template has already been declared and add '<>' after the function name here)
p1019.cpp:52:4: error: 'constexpr' does not name a type
   52 |    constexpr istream_iterator();
      |    ^~~~~~~~~
p1019.cpp:52:4: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1019.cpp:53:4: error: 'constexpr' does not name a type
   53 |    constexpr istream_iterator(default_sentinel_t);
      |    ^~~~~~~~~
p1019.cpp:53:4: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1019.cpp:56:17: error: expected constructor, destructor, or type conversion before '(' token
   56 | istream_iterator(istream_type& s);
      |                 ^
p1019.cpp:58:24: error: invalid use of template-name 'std::istream_iterator' without an argument list
   58 | istream_iterator(const istream_iterator& x) = default;
      |                        ^~~~~~~~~~~~~~~~
p1019.cpp:58:24: note: class template argument deduction is only available with '-std=c++17' or '-std=gnu++17'
p1019.cpp:27:14: note: 'template<class T, class charT, class traits, class Distance> class std::istream_iterator' declared here
   27 |        class istream_iterator {
      |              ^~~~~~~~~~~~~~~~
p1019.cpp:58:45: error: expected constructor, destructor, or type conversion before '=' token
   58 | istream_iterator(const istream_iterator& x) = default;
      |                                             ^
p1019.cpp:61:18: error: expected class-name before '(' token
   61 | ~istream_iterator() = default;
      |                  ^
p1019.cpp:64:7: error: 'T' does not name a type
   64 | const T& operator*() const;
      |       ^
p1019.cpp:66:7: error: 'T' does not name a type
   66 | const T* operator->() const;
      |       ^
p1019.cpp:68:1: error: invalid use of template-name 'std::istream_iterator' without an argument list
   68 | istream_iterator& operator++();
      | ^~~~~~~~~~~~~~~~
p1019.cpp:68:1: note: class template argument deduction is only available with '-std=c++17' or '-std=gnu++1'
p1019.cpp:27:14: note: 'template<class T, class charT, class traits, class Distance> class std::istream_iterator' declared here
   27 |        class istream_iterator {
      |              ^~~~~~~~~~~~~~~~
p1019.cpp:70:3: error: expected unqualified-id before 'if'
   70 |   if (!(*in_stream >> value))
      |   ^~
p1019.cpp:73:1: error: invalid use of template-name 'std::istream_iterator' without an argument list
   73 | istream_iterator operator++(int);
      | ^~~~~~~~~~~~~~~~
p1019.cpp:73:1: note: class template argument deduction is only available with '-std=c++17' or '-std=gnu++1'
p1019.cpp:27:14: note: 'template<class T, class charT, class traits, class Distance> class std::istream_iterator' declared here
   27 |        class istream_iterator {
      |              ^~~~~~~~~~~~~~~~
p1019.cpp:75:3: error: invalid use of template-name 'std::istream_iterator' without an argument list
   75 |   istream_iterator tmp = *this;
      |   ^~~~~~~~~~~~~~~~
p1019.cpp:75:3: note: class template argument deduction is only available with '-std=c++17' or '-std=gnu++1'
p1019.cpp:27:14: note: 'template<class T, class charT, class traits, class Distance> class std::istream_iterator' declared here
   27 |        class istream_iterator {
      |              ^~~~~~~~~~~~~~~~
p1019.cpp:76:3: error: expected unqualified-id before '++' token
   76 |   ++*this;
      |   ^~
p1019.cpp:77:3: error: expected unqualified-id before 'return'
   77 |   return tmp;
      |   ^~~~~~
p1019.cpp:82:1: error: 'friend' used outside of class
   82 | friend bool operator==(const istream_iterator& i, default_sentinel_t);
      | ^~~~~~
      | ------
p1019.cpp:82:30: error: invalid use of template-name 'std::istream_iterator' without an argument list
   82 | friend bool operator==(const istream_iterator& i, default_sentinel_t);
      |                              ^~~~~~~~~~~~~~~~
p1019.cpp:82:30: note: class template argument deduction is only available with '-std=c++17' or '-std=gnu++17'
p1019.cpp:27:14: note: 'template<class T, class charT, class traits, class Distance> class std::istream_iterator' declared here
   27 |        class istream_iterator {
      |              ^~~~~~~~~~~~~~~~
p1019.cpp:82:51: error: 'default_sentinel_t' has not been declared
   82 | friend bool operator==(const istream_iterator& i, default_sentinel_t);
      |                                                   ^~~~~~~~~~~~~~~~~~
p1019.cpp:82:13: error: 'bool operator==(const int&, int)' must have an argument of class or enumerated type
   82 | friend bool operator==(const istream_iterator& i, default_sentinel_t);
      |             ^~~~~~~~
p1019.cpp:89:73: error: spurious '>>', use '>' to terminate a template argument list
   89 |   template<class T, class charT = char, class traits = char_traits<charT>>
      |                                                                         ^~
p1019.cpp:90:26: error: definition of 'class std::ostream_iterator' inside template parameter list
   90 |   class ostream_iterator {
      |                          ^
p1019.cpp:89:56: error: two or more data types in declaration of 'type name'
   89 |   template<class T, class charT = char, class traits = char_traits<charT>>
      |                                                        ^~~~~~~~~~~~~~~~~~~
p1019.cpp:108:2: error: expected '>' before ';' token
  108 | }; }
      |  ^
p1019.cpp:108:2: error: expected unqualified-id before ';' token
p1019.cpp:110:17: error: expected constructor, destructor, or type conversion before '(' token
  110 | ostream_iterator(ostream_type& s);
      |                 ^
p1019.cpp:112:17: error: expected constructor, destructor, or type conversion before '(' token
  112 | ostream_iterator(ostream_type& s, const charT* delimiter);
      |                 ^
p1019.cpp:115:1: error: 'ostream_iterator' does not name a type
  115 | ostream_iterator& operator=(const T& value);
      | ^~~~~~~~~~~~~~~~
p1019.cpp:117:15: error: expected constructor, destructor, or type conversion before '<<' token
  117 |   *out_stream << value;
      |               ^~
p1019.cpp:118:3: error: expected unqualified-id before 'if'
  118 |   if (delim)
      |   ^~
p1019.cpp:120:3: error: expected unqualified-id before 'return'
  120 |   return *this;
      |   ^~~~~~
p1019.cpp:121:1: error: 'ostream_iterator' does not name a type
  121 | ostream_iterator& operator*();
      | ^~~~~~~~~~~~~~~~
p1019.cpp:123:1: error: 'ostream_iterator' does not name a type
  123 | ostream_iterator& operator++(int);
      | ^~~~~~~~~~~~~~~~
p1019.cpp:130:62: error: spurious '>>', use '>' to terminate a template argument list
  130 |        template<class charT, class traits = char_traits<charT>>
      |                                                              ^~
p1019.cpp:131:14: error: class template 'istreambuf_iterator' redeclared as non-template
  131 |        class istreambuf_iterator {
      |              ^~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/c++/12.1.0/ios:38,
                 from /usr/local/include/c++/12.1.0/ostream:38,
                 from /usr/local/include/c++/12.1.0/iostream:39,
                 from N4910.h:2:
/usr/local/include/c++/12.1.0/iosfwd:125:11: note: previous declaration here
  125 |     class istreambuf_iterator;
      |           ^~~~~~~~~~~~~~~~~~~
p1019.cpp:130:45: error: two or more data types in declaration of 'type name'
  130 |        template<class charT, class traits = char_traits<charT>>
      |                                             ^~~~~~~~~~~~~~~~~~~
p1019.cpp:156:2: error: expected '>' before ';' token
  156 | }; }
      |  ^
p1019.cpp:156:2: error: expected unqualified-id before ';' token
p1019.cpp:161:43: error: invalid class name in declaration of 'class std::istreambuf_iterator<_CharT, _Traits>::proxy'
  161 | class istreambuf_iterator<charT, traits>::proxy { // exposition only
      |                                           ^~~~~
p1019.cpp:172:1: error: 'constexpr' does not name a type
  172 | constexpr istreambuf_iterator() noexcept;
      | ^~~~~~~~~
p1019.cpp:172:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1019.cpp:173:1: error: 'constexpr' does not name a type
  173 | constexpr istreambuf_iterator(default_sentinel_t) noexcept;
      | ^~~~~~~~~
p1019.cpp:173:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1019.cpp:179:62: error: spurious '>>', use '>' to terminate a template argument list
  179 |        template<class charT, class traits = char_traits<charT>>
      |                                                              ^~
p1019.cpp:180:14: error: class template 'ostreambuf_iterator' redeclared as non-template
  180 |        class ostreambuf_iterator {
      |              ^~~~~~~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/iosfwd:128:11: note: previous declaration here
  128 |     class ostreambuf_iterator;
      |           ^~~~~~~~~~~~~~~~~~~
p1019.cpp:179:45: error: two or more data types in declaration of 'type name'
  179 |        template<class charT, class traits = char_traits<charT>>
      |                                             ^~~~~~~~~~~~~~~~~~~
p1019.cpp:218:2: error: expected '>' before ';' token
  218 | }; }
      |  ^
p1019.cpp:218:2: error: expected unqualified-id before ';' token
p1019.cpp:221:23: error: expected constructor, destructor, or type conversion before '(' token
  221 |    ostreambuf_iterator(ostream_type& s) noexcept;
      |                       ^
p1019.cpp:223:20: error: expected constructor, destructor, or type conversion before '(' token
  223 | ostreambuf_iterator(streambuf_type* s) noexcept;
      |                    ^
p1019.cpp:226:1: error: invalid use of template-name 'std::ostreambuf_iterator' without an argument list
  226 | ostreambuf_iterator& operator=(charT c);
      | ^~~~~~~~~~~~~~~~~~~
p1019.cpp:226:1: note: class template argument deduction is only available with '-std=c++17' or '-std=gnu++17'
/usr/local/include/c++/12.1.0/iosfwd:128:11: note: 'template<class _CharT, class _Traits> class std::ostreambuf_iterator' declared here
  128 |     class ostreambuf_iterator;
      |           ^~~~~~~~~~~~~~~~~~~
p1019.cpp:228:1: error: invalid use of template-name 'std::ostreambuf_iterator' without an argument list
  228 | ostreambuf_iterator& operator*();
      | ^~~~~~~~~~~~~~~~~~~
p1019.cpp:228:1: note: class template argument deduction is only available with '-std=c++17' or '-std=gnu++17'
/usr/local/include/c++/12.1.0/iosfwd:128:11: note: 'template<class _CharT, class _Traits> class std::ostreambuf_iterator' declared here
  128 |     class ostreambuf_iterator;
      |           ^~~~~~~~~~~~~~~~~~~
p1019.cpp:230:1: error: invalid use of template-name 'std::ostreambuf_iterator' without an argument list
  230 | ostreambuf_iterator& operator++(int);
      | ^~~~~~~~~~~~~~~~~~~
p1019.cpp:230:1: note: class template argument deduction is only available with '-std=c++17' or '-std=gnu++17'
/usr/local/include/c++/12.1.0/iosfwd:128:11: note: 'template<class _CharT, class _Traits> class std::ostreambuf_iterator' declared here
  128 |     class ostreambuf_iterator;
      |           ^~~~~~~~~~~~~~~~~~~
p1019.cpp:232:21: error: expected initializer before 'noexcept'
  232 | bool failed() const noexcept;
      |                     ^~~~~~~~

$ g++ p1019.cpp -std=2b -o p1019g -I. -Wall
p1019.cpp:17:17: error: expected constructor, destructor, or type conversion before '(' token
   17 |      partial_sum(istream_iterator<double, char>(cin),
      |                 ^
p1019.cpp:46:78: warning: friend declaration 'bool std::operator==(const istream_iterator<T, charT, traits, Distance>&, default_sentinel_t)' declares a non-template function [-Wnon-template-friend]
   46 |          friend bool operator==(const istream_iterator& i, default_sentinel_t);
      |                                                                              ^
p1019.cpp:46:78: note: (if this is not what you intended, make sure the function template has already been declared and add '<>' after the function name here)
p1019.cpp:52:4: error: 'decl-specifier' in declaration of deduction guide
   52 |    constexpr istream_iterator();
      |    ^~~~~~~~~
p1019.cpp:52:14: error: deduction guide for 'std::istream_iterator<T, charT, traits, Distance>' must have trailing return type
   52 |    constexpr istream_iterator();
      |              ^~~~~~~~~~~~~~~~
p1019.cpp:27:14: note: 'template<class T, class charT, class traits, class Distance> class std::istream_iterator' declared here
   27 |        class istream_iterator {
      |              ^~~~~~~~~~~~~~~~
p1019.cpp:53:4: error: 'decl-specifier' in declaration of deduction guide
   53 |    constexpr istream_iterator(default_sentinel_t);
      |    ^~~~~~~~~
p1019.cpp:53:14: error: deduction guide for 'std::istream_iterator<T, charT, traits, Distance>' must have trailing return type
   53 |    constexpr istream_iterator(default_sentinel_t);
      |              ^~~~~~~~~~~~~~~~
p1019.cpp:27:14: note: 'template<class T, class charT, class traits, class Distance> class std::istream_iterator' declared here
   27 |        class istream_iterator {
      |              ^~~~~~~~~~~~~~~~
p1019.cpp:56:30: error: expected ')' before '&' token
   56 | istream_iterator(istream_type& s);
      |                 ~            ^
      |                              )
p1019.cpp:58:18: error: template placeholder type 'const istream_iterator<...auto...>' must be followed by a simple declarator-id
   58 | istream_iterator(const istream_iterator& x) = default;
      |                  ^~~~~
p1019.cpp:27:14: note: 'template<class T, class charT, class traits, class Distance> class std::istream_iterator' declared here
   27 |        class istream_iterator {
      |              ^~~~~~~~~~~~~~~~
p1019.cpp:58:1: error: deduction guide for 'std::istream_iterator<T, charT, traits, Distance>' must have trailing return type
   58 | istream_iterator(const istream_iterator& x) = default;
      | ^~~~~~~~~~~~~~~~
p1019.cpp:27:14: note: 'template<class T, class charT, class traits, class Distance> class std::istream_iterator' declared here
   27 |        class istream_iterator {
      |              ^~~~~~~~~~~~~~~~
p1019.cpp:61:18: error: expected class-name before '(' token
   61 | ~istream_iterator() = default;
      |                  ^
p1019.cpp:64:7: error: 'T' does not name a type
   64 | const T& operator*() const;
      |       ^
p1019.cpp:66:7: error: 'T' does not name a type
   66 | const T* operator->() const;
      |       ^
p1019.cpp:68:1: error: deduced class type 'istream_iterator' in function return type
   68 | istream_iterator& operator++();
      | ^~~~~~~~~~~~~~~~
p1019.cpp:27:14: note: 'template<class T, class charT, class traits, class Distance> class std::istream_iterator' declared here
   27 |        class istream_iterator {
      |              ^~~~~~~~~~~~~~~~
p1019.cpp:70:3: error: expected unqualified-id before 'if'
   70 |   if (!(*in_stream >> value))
      |   ^~
p1019.cpp:73:1: error: deduced class type 'istream_iterator' in function return type
   73 | istream_iterator operator++(int);
      | ^~~~~~~~~~~~~~~~
p1019.cpp:27:14: note: 'template<class T, class charT, class traits, class Distance> class std::istream_iterator' declared here
   27 |        class istream_iterator {
      |              ^~~~~~~~~~~~~~~~
p1019.cpp:75:27: error: invalid use of 'this' at top level
   75 |   istream_iterator tmp = *this;
      |                           ^~~~
p1019.cpp:76:3: error: expected unqualified-id before '++' token
   76 |   ++*this;
      |   ^~
p1019.cpp:77:3: error: expected unqualified-id before 'return'
   77 |   return tmp;
      |   ^~~~~~
p1019.cpp:82:1: error: 'friend' used outside of class
   82 | friend bool operator==(const istream_iterator& i, default_sentinel_t);
      | ^~~~~~
      | ------
p1019.cpp:82:24: error: template placeholder type 'const istream_iterator<...auto...>' must be followed by a simple declarator-id
   82 | friend bool operator==(const istream_iterator& i, default_sentinel_t);
      |                        ^~~~~
p1019.cpp:27:14: note: 'template<class T, class charT, class traits, class Distance> class std::istream_iterator' declared here
   27 |        class istream_iterator {
      |              ^~~~~~~~~~~~~~~~
p1019.cpp:82:49: error: expected ')' before ',' token
   82 | friend bool operator==(const istream_iterator& i, default_sentinel_t);
      |                       ~                         ^
      |                                                 )
p1019.cpp:82:13: error: 'bool operator==(...)' must have an argument of class or enumerated type
   82 | friend bool operator==(const istream_iterator& i, default_sentinel_t);
      |             ^~~~~~~~
p1019.cpp:82:69: error: expected initializer before ')' token
   82 | friend bool operator==(const istream_iterator& i, default_sentinel_t);
      |                                                                     ^
p1019.cpp:110:30: error: expected ')' before '&' token
  110 | ostream_iterator(ostream_type& s);
      |                 ~            ^
      |                              )
p1019.cpp:112:30: error: expected ')' before '&' token
  112 | ostream_iterator(ostream_type& s, const charT* delimiter);
      |                 ~            ^
      |                              )
p1019.cpp:115:35: error: 'T' does not name a type
  115 | ostream_iterator& operator=(const T& value);
      |                                   ^
p1019.cpp:115:1: error: deduced class type 'ostream_iterator' in function return type
  115 | ostream_iterator& operator=(const T& value);
      | ^~~~~~~~~~~~~~~~
p1019.cpp:90:9: note: 'template<class T, class charT, class traits> class std::ostream_iterator' declared here
   90 |   class ostream_iterator {
      |         ^~~~~~~~~~~~~~~~
p1019.cpp:117:15: error: expected constructor, destructor, or type conversion before '<<' token
  117 |   *out_stream << value;
      |               ^~
p1019.cpp:118:3: error: expected unqualified-id before 'if'
  118 |   if (delim)
      |   ^~
p1019.cpp:120:3: error: expected unqualified-id before 'return'
  120 |   return *this;
      |   ^~~~~~
p1019.cpp:121:1: error: deduced class type 'ostream_iterator' in function return type
  121 | ostream_iterator& operator*();
      | ^~~~~~~~~~~~~~~~
p1019.cpp:90:9: note: 'template<class T, class charT, class traits> class std::ostream_iterator' declared here
   90 |   class ostream_iterator {
      |         ^~~~~~~~~~~~~~~~
p1019.cpp:123:1: error: deduced class type 'ostream_iterator' in function return type
  123 | ostream_iterator& operator++(int);
      | ^~~~~~~~~~~~~~~~
p1019.cpp:90:9: note: 'template<class T, class charT, class traits> class std::ostream_iterator' declared here
   90 |   class ostream_iterator {
      |         ^~~~~~~~~~~~~~~~
p1019.cpp:130:30: error: redefinition of default argument for 'class traits'
  130 |        template<class charT, class traits = char_traits<charT>>
      |                              ^~~~~
In file included from /usr/local/include/c++/12.1.0/ios:38,
                 from /usr/local/include/c++/12.1.0/ostream:38,
                 from /usr/local/include/c++/12.1.0/iostream:39,
                 from N4910.h:2,
                 from p1019.cpp:10:
/usr/local/include/c++/12.1.0/iosfwd:124:29: note: original definition appeared here
  124 |   template<typename _CharT, typename _Traits = char_traits<_CharT> >
      |                             ^~~~~~~~
p1019.cpp:161:43: error: invalid class name in declaration of 'class std::istreambuf_iterator<_CharT, _Traits>::proxy'
  161 | class istreambuf_iterator<charT, traits>::proxy { // exposition only
      |                                           ^~~~~
p1019.cpp:172:1: error: 'decl-specifier' in declaration of deduction guide
  172 | constexpr istreambuf_iterator() noexcept;
      | ^~~~~~~~~
p1019.cpp:172:11: error: deduction guide for 'std::istreambuf_iterator<_CharT, _Traits>' must have trailing return type
  172 | constexpr istreambuf_iterator() noexcept;
      |           ^~~~~~~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/iosfwd:125:11: note: 'template<class _CharT, class _Traits> class std::istreambuf_iterator' declared here
  125 |     class istreambuf_iterator;
      |           ^~~~~~~~~~~~~~~~~~~
p1019.cpp:173:1: error: 'decl-specifier' in declaration of deduction guide
  173 | constexpr istreambuf_iterator(default_sentinel_t) noexcept;
      | ^~~~~~~~~
p1019.cpp:173:11: error: deduction guide for 'std::istreambuf_iterator<_CharT, _Traits>' must have trailing return type
  173 | constexpr istreambuf_iterator(default_sentinel_t) noexcept;
      |           ^~~~~~~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/iosfwd:125:11: note: 'template<class _CharT, class _Traits> class std::istreambuf_iterator' declared here
  125 |     class istreambuf_iterator;
      |           ^~~~~~~~~~~~~~~~~~~
p1019.cpp:179:30: error: redefinition of default argument for 'class traits'
  179 |        template<class charT, class traits = char_traits<charT>>
      |                              ^~~~~
/usr/local/include/c++/12.1.0/iosfwd:127:29: note: original definition appeared here
  127 |   template<typename _CharT, typename _Traits = char_traits<_CharT> >
      |                             ^~~~~~~~
p1019.cpp:221:36: error: expected ')' before '&' token
  221 |    ostreambuf_iterator(ostream_type& s) noexcept;
      |                       ~            ^
      |                                    )
p1019.cpp:223:35: error: expected ')' before '*' token
  223 | ostreambuf_iterator(streambuf_type* s) noexcept;
      |                    ~              ^
      |                                   )
p1019.cpp:226:1: error: template placeholder type 'ostreambuf_iterator<...auto...>' must be followed by a simple declarator-id
  226 | ostreambuf_iterator& operator=(charT c);
      | ^~~~~~~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/iosfwd:128:11: note: 'template<class _CharT, class _Traits> class std::ostreambuf_iterator' declared here
  128 |     class ostreambuf_iterator;
      |           ^~~~~~~~~~~~~~~~~~~
p1019.cpp:226:32: error: 'charT' was not declared in this scope; did you mean 'char'?
  226 | ostreambuf_iterator& operator=(charT c);
      |                                ^~~~~
      |                                char
p1019.cpp:228:1: error: deduced class type 'ostreambuf_iterator' in function return type
  228 | ostreambuf_iterator& operator*();
      | ^~~~~~~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/iosfwd:128:11: note: 'template<class _CharT, class _Traits> class std::ostreambuf_iterator' declared here
  128 |     class ostreambuf_iterator;
      |           ^~~~~~~~~~~~~~~~~~~
p1019.cpp:230:1: error: deduced class type 'ostreambuf_iterator' in function return type
  230 | ostreambuf_iterator& operator++(int);
      | ^~~~~~~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/iosfwd:128:11: note: 'template<class _CharT, class _Traits> class std::ostreambuf_iterator' declared here
  128 |     class ostreambuf_iterator;
      |           ^~~~~~~~~~~~~~~~~~~
p1019.cpp:232:21: error: non-member function 'bool failed()' cannot have cv-qualifier
  232 | bool failed() const noexcept;
      |                     ^~~~~~~~
```

## 検討事項(agenda)
コンパイルエラーを取るか、コンパイルエラーの理由を解説する。

<!-- リンクエラーの解説をする。clang++とg++の比較。意味のある出力。
コンパイルエラーを取るか、コンパイルエラーの理由を解説する。-->

# 参考資料(reference)


関連する自己参照以外は、こちらの先頭に移転。

C言語（C++)に対する誤解、曲解、無理解、爽快。

https://qiita.com/kaizen_nagoya/items/3f3992c9722c1cee2e3a

#include "N4910.h"

https://qiita.com/kaizen_nagoya/items/163a47cef7d6bb1c33a8

C++N4910資料の改善点

https://qiita.com/kaizen_nagoya/items/fb4ceb5d117a54641af3

dockerにclang

https://qiita.com/kaizen_nagoya/items/8829ffeee397eda50e80

docker gnu(gcc/g++) and llvm(clang/clang++)

https://qiita.com/drafts/059874ea39c4de64c0f7

コンパイル用shell script C版(clangとgcc)とC++版(clang++とg++)

https://qiita.com/kaizen_nagoya/items/74220c0577a512c2d7da


C++N4910:2022 tag follower 300人超えました。ありがとうございます。

https://qiita.com/kaizen_nagoya/items/a63fb96d351ac5c16ff7

astyle 使ってみた

https://qiita.com/kaizen_nagoya/items/3c9a87a781d53a1a23f3

DoCAP（ドゥーキャップ）って何ですか？

https://qiita.com/kaizen_nagoya/items/47e0e6509ab792c43327

小川メソッド　覚え（書きかけ）

https://qiita.com/kaizen_nagoya/items/3593d72eca551742df68

 ＜この記事は個人の過去の経験に基づく個人の感想です。現在所属する組織、業務とは関係がありません。＞

# 文書履歴(document history)
ver. 0.01 初稿 　20220809