31.6 Stream buffers [stream.buffers] C++N4910:2022 (689) p1507.cpp

# はじめに(Introduction)
N4910  Working Draft, Standard for Programming Language C++
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/n4910.pdf

C++ n4910は、ISO/IEC JTC1 SC22 WG21の作業原案(Working Draft)です。
公式のISO/IEC 14882原本ではありません。
ISO/IEC JTC1 SC22 のWG21を含むいくつかのWGでは、可能な限り作業文書を公開し、幅広い意見を求めています。

ISO/IEC JTC1 SC7からISO/IEC JTC1 SC22リエゾンとして、2000年頃、C/C++の品質向上に貢献しようとした活動をしていたことがあります。その頃は、まだISO/IEC TS 17961の原案が出る前です。Cの精神が優勢で、セキュリティ対策は補助的な位置付けでした。ISO/IEC TS 17961の制定と、C/C++のライブラリ類の見直しと、C++の進化はどんどん進んでいきます。　

進化の具合が、どちらに行こうとしているかは、コンパイルて実行させてみないとわかりません。C/C++の規格案の電子ファイルは、そのままコンパイルできる形式であるとよいと主張してきました。MISRA-C/C++, CERTC/C++でも同様です。MISRA-C/C++は、Example Suiteという形で、コード断片をコンパイルできる形で提供するようになりました。

一連の記事はコード断片をコンパイルできる形にする方法を検討してコンパイル、リンク、実行して、規格案の原文と処理系(g++, Clang++)との違いを確認し、技術内容を検討し、ISO/IEC JTC1 SC22 WG21にフィードバックするために用います。
また、CERT C++, MISRA C++等のコーディング標準のコード断片をコンパイルする際の参考にさせていただこうと考えています。CERT C++, MISRA C++が標準化の動きとの時間的なずれがあれば確認できれば幸いです。また、boostライブラリとの関連、Linux OS, 箱庭プロジェクト、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.

# 31.6 Stream buffers [stream.buffers] C++N4910:2022 (689) p1507.cpp

## 算譜(source code)

```c++:p1507.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 = "31.6 Stream buffers [stream.buffers] C++N4910:2022 (689) p1507.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;

// 31.6.1 Header <streambuf> synopsis [streambuf.syn]
namespace std {
template<class charT, class traits = char_traits<charT>>
class basic_streambuf;
using streambuf  = basic_streambuf<char>;
using wstreambuf = basic_streambuf<wchar_t>;
}
//  The header <streambuf> defines types that control input from and output to character sequences.
// 31.6.2 Stream buffer requirements [streambuf.reqts]
//  Stream buffers can impose various constraints on the sequences they control. Some constraints are:
//  Each sequence is characterized by three pointers which, if non-null, all point into the same charT array object. The array object represents, at any moment, a (sub)sequence of characters from the sequence. Operations performed on a sequence alter the values stored in these pointers, perform reads and writes directly to or from associated sequences, and alter “the stream position” and conversion state as needed to maintain this subsequence relationship. The three pointers are:
//  The following semantic constraints shall always apply for any set of three pointers for a sequence, using the array, as described above; otherwise, xbeg and xend shall also be null.
// — If xnext is not a null pointer and xnext < xend for an output sequence, then a write position is available. In this case, *xnext shall be assignable as the next element to write (to put, or to store a character value, into the sequence).
// — If xnext is not a null pointer and xbeg < xnext for an input sequence, then a putback position is available. In this case, xnext[-1] shall have a defined value and is the next (preceding) element to store a character that is put back into the input sequence.
// — If xnext is not a null pointer and xnext < xend for an input sequence, then a read position is available. In this case, *xnext shall have a defined value and is the next element to read (to get, or to obtain a character value, from the sequence).
// 31.6.3 Class template basic_streambuf  [streambuf]
// 31.6.3.1 General [streambuf.general]
namespace std {
template<class charT, class traits = char_traits<charT>>
class basic_streambuf {
public:
    using char_type = charT;
    using int_type = typename traits::int_type;
    using pos_type = typename traits::pos_type;
    using off_type = typename traits::off_type;
    using traits_type = traits;
    void gbump(int n);
    void setg(char_type* gbeg, char_type* gnext, char_type* gend);
    virtual ~basic_streambuf();
// 31.6.3.3.1, locales
    locale pubimbue(const locale& loc);
    locale getloc() const;
// 31.6.3.3.2, buffer and positioning
    basic_streambuf* pubsetbuf(char_type* s, streamsize n);
    pos_type pubseekoff(off_type off, ios_base::seekdir way,
                        ios_base::openmode which
                        = ios_base::in | ios_base::out);
    pos_type pubseekpos(pos_type sp,
                        ios_base::openmode which
                        = ios_base::in | ios_base::out);
    int      pubsync();
// get and put areas
// 31.6.3.3.3, get area
    streamsize in_avail();
    int_type snextc();
    int_type sbumpc();
    int_type sgetc();
    streamsize sgetn(char_type* s, streamsize n);
// 31.6.3.3.4, putback
    int_type sputbackc(char_type c);
    int_type sungetc();
// 31.6.3.3.5, put area
    int_type sputc(char_type c);
    streamsize sputn(const char_type* s, streamsize n);
protected:
    basic_streambuf();
    basic_streambuf(const basic_streambuf& rhs);
    basic_streambuf& operator=(const basic_streambuf& rhs);
    void swap(basic_streambuf& rhs);
// 31.6.3.4.2, get area access char_type* eback() const; char_type* gptr() const; char_type* egptr() const;
// — a character input sequence; — a character output sequence.
// 31.6.3.2 Constructors [streambuf.cons]
    basic_streambuf();
// 31.6.3.4.3, put area access
    char_type* pbase() const;
    char_type* pptr() const;
    char_type* epptr() const;
    void pbump(int n);
    void setp(char_type* pbeg, char_type* pend);
// 31.6.3.5, virtual functions
// 31.6.3.5.1, locales
    virtual void imbue(const locale& loc);
// 31.6.3.5.2, buffer management and positioning
    virtual basic_streambuf* setbuf(char_type* s, streamsize n);
    virtual pos_type seekoff(off_type off, ios_base::seekdir way,
                             ios_base::openmode which
                             = ios_base::in | ios_base::out);
    virtual pos_type seekpos(pos_type sp,
                             ios_base::openmode which
                             = ios_base::in | ios_base::out);
    virtual int      sync();
// 31.6.3.5.3, get area
    virtual streamsize showmanyc();
    virtual streamsize xsgetn(char_type* s, streamsize n);
    virtual int_type
    virtual int_type
// 31.6.3.5.4, putback virtual int_type
    underflow();
    uflow();
    pbackfail(int_type c = traits::eof());
// 31.6.3.5.5, put area
    virtual streamsize xsputn(const char_type* s, streamsize n);
    virtual int_type overflow(int_type c = traits::eof());
};
}
// The class template basic_streambuf serves as an abstract base class for deriving various stream buffers whose objects each control two character sequences:
// Effects: Initializes:282
// — all pointer member objects to null pointers,
// — the getloc() member to a copy the global locale, locale(), at the time of construction.
// Remarks: Once the getloc() member is initialized, results of calling locale member functions, and of members of facets so obtained, can safely be cached until the next time the member imbue is called.
basic_streambuf(const basic_streambuf& rhs);
// Postconditions:— eback() == rhs.eback() — gptr() == rhs.gptr() — egptr() == rhs.egptr() — pbase() == rhs.pbase()
//  282) The default constructor is protected for class basic_streambuf to assure that only objects for classes derived from this class can be constructed.— pptr() == rhs.pptr() — epptr() == rhs.epptr() — getloc() == rhs.getloc()
~basic_streambuf();
Effects:
None.
// 31.6.3.3 Public member functions  [streambuf.members]
// 31.6.3.3.1 Locales [streambuf.locales]
locale pubimbue(const locale& loc);
// Effects: Calls imbue(loc). Postconditions: loc == getloc().
// Returns: Previous value of getloc().
locale getloc() const;
// Returns: If pubimbue() has ever been called, then the last value of loc supplied, otherwise the current global locale, locale(), in effect at the time of construction. If called after pubimbue() has been called but before pubimbue has returned (i.e., from within the call of imbue()) then it returns the previous value.
// 31.6.3.3.2 Buffer management and positioning [streambuf.buffer]
basic_streambuf* pubsetbuf(char_type* s, streamsize n);
// Returns: setbuf(s, n).
pos_type pubseekoff(off_type off, ios_base::seekdir way,
                    ios_base::openmode which
                    = ios_base::in | ios_base::out);
// Returns: seekoff(off, way, which).
pos_type pubseekpos(pos_type sp,
                    ios_base::openmode which
                    = ios_base::in | ios_base::out);
// Returns: seekpos(sp, which). int pubsync();
// Returns: sync().
// 31.6.3.3.3 Get area  [streambuf.pub.get]
streamsize in_avail();
// Returns: If a read position is available, returns egptr() - gptr(). Otherwise returns showmanyc() (31.6.3.5.3).
int_type snextc();
// Effects: Calls sbumpc().
// Returns: If that function returns traits::eof(), returns traits::eof(). Otherwise, returns sgetc().
int_type sbumpc();
// Effects: If the input sequence read position is not available, returns uflow(). Otherwise, returns traits::to_int_type(*gptr()) and increments the next pointer for the input sequence.
int_type sgetc();
// Returns: If the input sequence read position is not available, returns underflow(). Otherwise, returns traits::to_int_type(*gptr()).
streamsize sgetn(char_type* s, streamsize n);
// Returns: xsgetn(s, n).
// 31.6.3.3.4 Putback [streambuf.pub.pback]
int_type sputbackc(char_type c);
// Effects: If the input sequence putback position is not available, or if traits::eq(c, gptr()[-1]) is false, returns pbackfail(traits::to_int_type(c)). Otherwise, decrements the next pointer for the input sequence and returns traits::to_int_type(*gptr()).
int_type sungetc();
// Effects: If the input sequence putback position is not available, returns pbackfail(). Otherwise, decrements the next pointer for the input sequence and returns traits::to_int_type(*gptr()).
// 31.6.3.3.5 Put area [streambuf.pub.put]
int_type sputc(char_type c);
// Effects: If the output sequence write position is not available, returns overflow(traits::to_int_- type(c)). Otherwise, stores c at the next pointer for the output sequence, increments the pointer, and returns traits::to_int_type(c).
streamsize sputn(const char_type* s, streamsize n);
// Returns: xsputn(s, n).
// 31.6.3.4 Protected member functions
// 31.6.3.4.1 Assignment
basic_streambuf& operator=(const basic_streambuf& rhs);
// [streambuf.protected] [streambuf.assign]
// Postconditions:— eback() == rhs.eback() — gptr() == rhs.gptr()
// — egptr() == rhs.egptr() — pbase() == rhs.pbase() — pptr() == rhs.pptr()— epptr() == rhs.epptr() — getloc() == rhs.getloc()
// Returns: *this.
void swap(basic_streambuf& rhs);
// Effects: Swaps the data members of rhs and *this.
// 31.6.3.4.2 Get area access [streambuf.get.area]
char_type* eback() const;
// Returns: The beginning pointer for the input sequence. char_type* gptr() const;
// Returns: The next pointer for the input sequence. char_type* egptr() const;
// Returns: The end pointer for the input sequence. void gbump(int n);
// Effects: Adds n to the next pointer for the input sequence. void setg(char_type* gbeg, char_type* gnext, char_type* gend);
// Postconditions: gbeg == eback(), gnext == gptr(), and gend == egptr() are all true.
// 31.6.3.4.3 Put area access [streambuf.put.area]
char_type* pbase() const;
// Returns: The beginning pointer for the output sequence. char_type* pptr() const;
// Returns: The next pointer for the output sequence. char_type* epptr() const;
// Returns: The end pointer for the output sequence. void pbump(int n);
// Effects: Adds n to the next pointer for the output sequence.
void setp(char_type* pbeg, char_type* pend);
// Postconditions: pbeg == pbase(), pbeg == pptr(), and pend == epptr() are all true.
// 31.6.3.5 Virtual functions [streambuf.virtuals]
// 31.6.3.5.1 Locales [streambuf.virt.locales]
void imbue(const locale&);
// Effects: Change any translations based on locale.
// Remarks: Allows the derived class to be informed of changes in locale at the time they occur. Between invocations of this function a class derived from streambuf can safely cache results of calls to locale functions and to members of facets so obtained.
// Default behavior: Does nothing.
// 31.6.3.5.2 Buffer management and positioning [streambuf.virt.buffer]
basic_streambuf* setbuf(char_type* s, streamsize n);
// Effects: Influences stream buffering in a way that is defined separately for each class derived from basic_streambuf in this Clause (31.8.2.5, 31.10.2.5).
// Default behavior: Does nothing. Returns this.
pos_type seekoff(off_type off, ios_base::seekdir way,
                 ios_base::openmode which
                 = ios_base::in | ios_base::out);
// Effects: Alters the stream positions within one or more of the controlled sequences in a way that is defined separately for each class derived from basic_streambuf in this Clause (31.8.2.5, 31.10.2.5).
// Default behavior: Returns pos_type(off_type(-1)).
pos_type seekpos(pos_type sp,
                 ios_base::openmode which
                 = ios_base::in | ios_base::out);
// Effects: Alters the stream positions within one or more of the controlled sequences in a way that is defined separately for each class derived from basic_streambuf in this Clause (31.8.2, 31.10.2).
Default behavior:
Returns pos_type(off_type(-1)). int sync();
// Effects: Synchronizes the controlled sequences with the arrays. That is, if pbase() is non-null the characters between pbase() and pptr() are written to the controlled sequence. The pointers may then be reset as appropriate.
// Returns: -1 on failure. What constitutes failure is determined by each derived class (31.10.2.5). Default behavior: Returns zero.
// 31.6.3.5.3 Get area [streambuf.virt.get]
streamsize showmanyc();//283
// Returns: An estimate of the number of characters available in the sequence, or −1. If it returns a positive value, then successive calls to underflow() will not return traits::eof() until at least that number of characters have been extracted from the stream. If showmanyc() returns −1, then calls to underflow() or uflow() will fail.284
// Default behavior: Returns zero. Remarks: Uses traits::eof().
streamsize xsgetn(char_type* s, streamsize n);
// Effects: Assigns up to n characters to successive elements of the array whose first element is designated by s. The characters assigned are read from the input sequence as if by repeated calls to sbumpc(). Assigning stops when either n characters have been assigned or a call to sbumpc() would return traits::eof().
// Returns: The number of characters assigned.285 Remarks: Uses traits::eof().
int_type underflow();
// The pending sequence of characters is defined as the concatenation of
// — the empty sequence if gptr() is null, otherwise the characters in [gptr(), egptr()), followed by — some (possibly empty) sequence of characters read from the input sequence.
// The result character is the first character of the pending sequence if it is non-empty, otherwise the next character that would be read from the input sequence.
// The backup sequence is the empty sequence if eback() is null, otherwise the characters in [eback(), gptr()).
// Effects: The function sets up the gptr() and egptr() such that if the pending sequence is non-empty, then egptr() is non-null and the characters in [gptr(), egptr()) are the characters in the pending sequence, otherwise either gptr() is null or gptr() == egptr().
//If eback() and gptr() are non-null then the function is not constrained as to their contents, but the “usual backup condition” is that either
// — the backup sequence contains at least gptr() - eback() characters, in which case the characters in [eback(), gptr()) agree with the last gptr() - eback() characters of the backup sequence, or
// — the characters in [gptr() - n, gptr()) agree with the backup sequence (where n is the length of the backup sequence).
// Returns: traits::to_int_type(c), where c is the first character of the pending sequence, without moving the input sequence position past it. If the pending sequence is null then the function returns traits::eof() to indicate failure.
// Default behavior: Returns traits::eof().
// Remarks: The public members of basic_streambuf call this virtual function only if gptr() is null or
gptr() >= egptr(). int_type uflow();
// Preconditions: The constraints are the same as for underflow(), except that the result character is transferred from the pending sequence to the backup sequence, and the pending sequence is not empty before the transfer.
//  283) The morphemes of showmanyc are “es-how-many-see”, not “show-manic”.
// 284) underflow or uflow can fail by throwing an exception prematurely. The intention is not only that the calls will not return eof() but that they will return “immediately”.
// 285) Classes derived from basic_streambuf can provide more efficient ways to implement xsgetn() and xsputn() by overriding these definitions from the base class.
// Default behavior: Calls underflow(). If underflow() returns traits::eof(), returns traits::eof(). Otherwise, returns the value of traits::to_int_type(*gptr()) and increment the value of the next pointer for the input sequence.
// Returns: traits::eof() to indicate failure.
// 31.6.3.5.4 Putback [streambuf.virt.pback]
int_type pbackfail(int_type c = traits::eof());
// The pending sequence is defined as for underflow(), with the modifications that
// — If traits::eq_int_type(c, traits::eof()) returns true, then the input sequence is backed up one character before the pending sequence is determined.
// — If traits::eq_int_type(c, traits::eof()) returns false, then c is prepended. Whether the input sequence is backed up or modified in any other way is unspecified.
// Postconditions: On return, the constraints of gptr(), eback(), and pptr() are the same as for underflow().
// Returns: traits::eof() to indicate failure. Failure may occur because the input sequence could not be backed up, or if for some other reason the pointers cannot be set consistent with the constraints. pbackfail() is called only when put back has really failed. Returns some value other than traits::eof() to indicate success. Default behavior: Returns traits::eof().
// Remarks: The public functions of basic_streambuf call this virtual function only when gptr() is null, gptr() == eback(), or traits::eq(traits::to_char_type(c), gptr()[-1]) returns false. Other calls shall also satisfy that constraint.
// 31.6.3.5.5 Put area [streambuf.virt.put]
streamsize xsputn(const char_type* s, streamsize n);
// Effects: Writes up to n characters to the output sequence as if by repeated calls to sputc(c). The characters written are obtained from successive elements of the array whose first element is designated by s. Writing stops when either n characters have been written or a call to sputc(c) would return traits::eof(). It is unspecified whether the function calls overflow() when pptr() == epptr() becomes true or whether it achieves the same effects by other means.
// Returns: The number of characters written. int_type overflow(int_type c = traits::eof());
// Effects: Consumes some initial subsequence of the characters of the pending sequence. The pending sequence is defined as the concatenation of
// — the empty sequence if pbase() is null, otherwise the pptr() - pbase() characters beginning at pbase(), followed by
// — the empty sequence if traits::eq_int_type(c, traits::eof()) returns true, otherwise the sequence consisting of c.
// Preconditions: Every overriding definition of this virtual function obeys the following constraints:
// — The effect of consuming a character on the associated output sequence is specified.286
// — Let r be the number of characters in the pending sequence not consumed. If r is nonzero then pbase() and pptr() are set so that: pptr() - pbase() == r and the r characters starting at pbase() are the associated output stream. In case r is zero (all characters of the pending sequence have been consumed) then either pbase() is set to nullptr, or pbase() and pptr() are both set to the same non-null value.
// — The function may fail if either appending some character to the associated output stream fails or if it is unable to establish pbase() and pptr() according to the above rules.
//  286) That is, for each class derived from a specialization of basic_streambuf in this Clause (31.8.2, 31.10.2), a specification of how consuming a character effects the associated output sequence is given. There is no requirement on a program-defined class.
// Returns: traits::eof() or throws an exception if the function fails.
Otherwise, returns some value other than traits::eof() to indicate success.287 Default behavior:
Returns traits::eof().
// Remarks: The member functions sputc() and sputn() call this function in case that no room can be found in the put buffer enough to accommodate the argument character sequence.
int main() {
    cout  <<  n4910 << endl;
    return EXIT_SUCCESS;
}
```

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

```ubuntu:bash
$ clang++ p1507.cpp -std=03 -o p1507l -I. -Wall
In file included from p1507.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 \
 ^
p1507.cpp:16:59: error: a space is required between consecutive right angle brackets (use '> >')
    template<class charT, class traits = char_traits<charT>>
                                                          ^~
                                                          > >
p1507.cpp:16:42: error: template parameter redefines default argument
    template<class charT, class traits = char_traits<charT>>
                                         ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/iosfwd:79:48: note: previous default template argument defined here
  template<typename _CharT, typename _Traits = char_traits<_CharT> >
                                               ^
p1507.cpp:18:24: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
    using streambuf  = basic_streambuf<char>;
                       ^
p1507.cpp:19:24: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
    using wstreambuf = basic_streambuf<wchar_t>;
                       ^
p1507.cpp:32:59: error: a space is required between consecutive right angle brackets (use '> >')
    template<class charT, class traits = char_traits<charT>>
                                                          ^~
                                                          > >
p1507.cpp:33:11: error: redefinition of 'basic_streambuf'
    class basic_streambuf {
          ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/streambuf:122:11: note: previous definition is here
    class basic_streambuf
          ^
p1507.cpp:108:23: error: use of class template 'basic_streambuf' requires template arguments
basic_streambuf(const basic_streambuf& rhs);
                      ^
p1507.cpp:17:13: note: template is declared here
      class basic_streambuf;
            ^
p1507.cpp:108:1: error: C++ requires a type specifier for all declarations
basic_streambuf(const basic_streambuf& rhs);
^
p1507.cpp:111:2: error: identifier 'basic_streambuf' after '~' in destructor name does not name a type
~basic_streambuf(); Effects: None.
 ^
p1507.cpp:17:13: note: non-type declaration found by destructor name lookup
      class basic_streambuf;
            ^
p1507.cpp:111:21: error: unknown type name 'Effects'
~basic_streambuf(); Effects: None.
                    ^
p1507.cpp:111:28: error: expected unqualified-id
~basic_streambuf(); Effects: None.
                           ^
p1507.cpp:117:17: error: non-member function cannot have 'const' qualifier
locale getloc() const;
                ^~~~~
p1507.cpp:120:1: error: use of class template 'basic_streambuf' requires template arguments
basic_streambuf* pubsetbuf(char_type* s, streamsize n);
^
p1507.cpp:17:13: note: template is declared here
      class basic_streambuf;
            ^
p1507.cpp:120:28: error: unknown type name 'char_type'
basic_streambuf* pubsetbuf(char_type* s, streamsize n);
                           ^
p1507.cpp:122:1: error: unknown type name 'pos_type'
pos_type pubseekoff(off_type off, ios_base::seekdir way,
^
p1507.cpp:122:21: error: unknown type name 'off_type'
pos_type pubseekoff(off_type off, ios_base::seekdir way,
                    ^
p1507.cpp:126:1: error: unknown type name 'pos_type'
pos_type pubseekpos(pos_type sp,
^
p1507.cpp:126:21: error: unknown type name 'pos_type'
pos_type pubseekpos(pos_type sp,
                    ^
p1507.cpp:134:1: error: unknown type name 'int_type'
int_type snextc();
^
p1507.cpp:137:1: error: unknown type name 'int_type'
int_type sbumpc();
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
2 warnings and 20 errors generated.
$ clang++ p1507.cpp -std=2b -o p1507l -I. -Wall
p1507.cpp:16:42: error: template parameter redefines default argument
    template<class charT, class traits = char_traits<charT>>
                                         ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/iosfwd:79:48: note: previous default template argument defined here
  template<typename _CharT, typename _Traits = char_traits<_CharT> >
                                               ^
p1507.cpp:33:11: error: redefinition of 'basic_streambuf'
    class basic_streambuf {
          ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/streambuf:122:11: note: previous definition is here
    class basic_streambuf
          ^
p1507.cpp:108:23: error: use of class template 'basic_streambuf' requires template arguments; argument deduction not allowed in function prototype
basic_streambuf(const basic_streambuf& rhs);
                      ^~~~~~~~~~~~~~~
p1507.cpp:17:13: note: template is declared here
      class basic_streambuf;
            ^
p1507.cpp:108:1: error: deduction guide must be declared in the same scope as template 'std::basic_streambuf'
basic_streambuf(const basic_streambuf& rhs);
^
p1507.cpp:17:13: note: template is declared here
      class basic_streambuf;
            ^
p1507.cpp:108:1: error: deduction guide declaration without trailing return type
basic_streambuf(const basic_streambuf& rhs);
^
p1507.cpp:111:2: error: identifier 'basic_streambuf' after '~' in destructor name does not name a type
~basic_streambuf(); Effects: None.
 ^
p1507.cpp:17:13: note: non-type declaration found by destructor name lookup
      class basic_streambuf;
            ^
p1507.cpp:111:21: error: unknown type name 'Effects'
~basic_streambuf(); Effects: None.
                    ^
p1507.cpp:111:28: error: expected unqualified-id
~basic_streambuf(); Effects: None.
                           ^
p1507.cpp:117:17: error: non-member function cannot have 'const' qualifier
locale getloc() const;
                ^~~~~
p1507.cpp:120:28: error: unknown type name 'char_type'
basic_streambuf* pubsetbuf(char_type* s, streamsize n);
                           ^
p1507.cpp:120:1: error: use of class template 'basic_streambuf' requires template arguments; argument deduction not allowed in function return type
basic_streambuf* pubsetbuf(char_type* s, streamsize n);
^~~~~~~~~~~~~~~
p1507.cpp:17:13: note: template is declared here
      class basic_streambuf;
            ^
p1507.cpp:122:1: error: unknown type name 'pos_type'
pos_type pubseekoff(off_type off, ios_base::seekdir way,
^
p1507.cpp:122:21: error: unknown type name 'off_type'
pos_type pubseekoff(off_type off, ios_base::seekdir way,
                    ^
p1507.cpp:126:1: error: unknown type name 'pos_type'
pos_type pubseekpos(pos_type sp,
^
p1507.cpp:126:21: error: unknown type name 'pos_type'
pos_type pubseekpos(pos_type sp,
                    ^
p1507.cpp:134:1: error: unknown type name 'int_type'
int_type snextc();
^
p1507.cpp:137:1: error: unknown type name 'int_type'
int_type sbumpc();
^
p1507.cpp:139:1: error: unknown type name 'int_type'
int_type sgetc();
^
p1507.cpp:141:18: error: unknown type name 'char_type'
streamsize sgetn(char_type* s, streamsize n);
                 ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

$ g++ p1507.cpp -std=03 -o p1507g -I. -Wall
In file included from /usr/local/include/c++/12.1.0/atomic:38,
                 from N4910.h:11,
                 from p1507.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 \
      |  ^~~~~
p1507.cpp:16:59: error: spurious '>>', use '>' to terminate a template argument list
   16 |     template<class charT, class traits = char_traits<charT>>
      |                                                           ^~
p1507.cpp:17:13: error: template argument required for 'class basic_streambuf'
   17 |       class basic_streambuf;
      |             ^~~~~~~~~~~~~~~
p1507.cpp:16:42: error: two or more data types in declaration of 'type name'
   16 |     template<class charT, class traits = char_traits<charT>>
      |                                          ^~~~~~~~~~~~~~~~~~~
p1507.cpp:17:28: error: expected '>' before ';' token
   17 |       class basic_streambuf;
      |                            ^
p1507.cpp:17:28: error: expected unqualified-id before ';' token
p1507.cpp:18:11: error: expected nested-name-specifier before 'streambuf'
   18 |     using streambuf  = basic_streambuf<char>;
      |           ^~~~~~~~~
p1507.cpp:19:11: error: expected nested-name-specifier before 'wstreambuf'
   19 |     using wstreambuf = basic_streambuf<wchar_t>;
      |           ^~~~~~~~~~
p1507.cpp:32:59: error: spurious '>>', use '>' to terminate a template argument list
   32 |     template<class charT, class traits = char_traits<charT>>
      |                                                           ^~
p1507.cpp:33:11: error: class template 'basic_streambuf' redeclared as non-template
   33 |     class basic_streambuf {
      |           ^~~~~~~~~~~~~~~
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:80:11: note: previous declaration here
   80 |     class basic_streambuf;
      |           ^~~~~~~~~~~~~~~
p1507.cpp:32:42: error: two or more data types in declaration of 'type name'
   32 |     template<class charT, class traits = char_traits<charT>>
      |                                          ^~~~~~~~~~~~~~~~~~~
p1507.cpp:102:2: error: expected '>' before ';' token
  102 | }; }
      |  ^
p1507.cpp:102:2: error: expected unqualified-id before ';' token
p1507.cpp:108:23: error: invalid use of template-name 'std::basic_streambuf' without an argument list
  108 | basic_streambuf(const basic_streambuf& rhs);
      |                       ^~~~~~~~~~~~~~~
p1507.cpp:108:23: note: class template argument deduction is only available with '-std=c++17' or '-std=gnu++17'
/usr/local/include/c++/12.1.0/iosfwd:80:11: note: 'template<class _CharT, class _Traits> class std::basic_streambuf' declared here
   80 |     class basic_streambuf;
      |           ^~~~~~~~~~~~~~~
p1507.cpp:108:44: error: expected constructor, destructor, or type conversion before ';' token
  108 | basic_streambuf(const basic_streambuf& rhs);
      |                                            ^
p1507.cpp:111:17: error: expected class-name before '(' token
  111 | ~basic_streambuf(); Effects: None.
      |                 ^
p1507.cpp:111:28: error: found ':' in nested-name-specifier, expected '::'
  111 | ~basic_streambuf(); Effects: None.
      |                            ^
      |                            ::
p1507.cpp:111:21: error: 'Effects' does not name a type
  111 | ~basic_streambuf(); Effects: None.
      |                     ^~~~~~~
p1507.cpp:117:17: error: non-member function 'std::locale getloc()' cannot have cv-qualifier
  117 | locale getloc() const;
      |                 ^~~~~
p1507.cpp:120:1: error: invalid use of template-name 'std::basic_streambuf' without an argument list
  120 | basic_streambuf* pubsetbuf(char_type* s, streamsize n);
      | ^~~~~~~~~~~~~~~
p1507.cpp:120: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:80:11: note: 'template<class _CharT, class _Traits> class std::basic_streambuf' declared here
   80 |     class basic_streambuf;
      |           ^~~~~~~~~~~~~~~
p1507.cpp:122:1: error: 'pos_type' does not name a type
  122 | pos_type pubseekoff(off_type off, ios_base::seekdir way,
      | ^~~~~~~~
p1507.cpp:126:1: error: 'pos_type' does not name a type
  126 | pos_type pubseekpos(pos_type sp,
      | ^~~~~~~~
p1507.cpp:134:1: error: 'int_type' does not name a type
  134 | int_type snextc();
      | ^~~~~~~~
p1507.cpp:137:1: error: 'int_type' does not name a type
  137 | int_type sbumpc();
      | ^~~~~~~~
p1507.cpp:139:1: error: 'int_type' does not name a type
  139 | int_type sgetc();
      | ^~~~~~~~
p1507.cpp:141:18: error: 'char_type' was not declared in this scope
  141 | streamsize sgetn(char_type* s, streamsize n);
      |                  ^~~~~~~~~
p1507.cpp:141:29: error: 's' was not declared in this scope
  141 | streamsize sgetn(char_type* s, streamsize n);
      |                             ^
p1507.cpp:141:43: error: expected primary-expression before 'n'
  141 | streamsize sgetn(char_type* s, streamsize n);
      |                                           ^
p1507.cpp:141:44: error: expression list treated as compound expression in initializer [-fpermissive]
  141 | streamsize sgetn(char_type* s, streamsize n);
      |                                            ^
p1507.cpp:144:1: error: 'int_type' does not name a type
  144 | int_type sputbackc(char_type c);
      | ^~~~~~~~
p1507.cpp:146:1: error: 'int_type' does not name a type
  146 | int_type sungetc();
      | ^~~~~~~~
p1507.cpp:149:1: error: 'int_type' does not name a type
  149 | int_type sputc(char_type c);
      | ^~~~~~~~
p1507.cpp:151:24: error: 'char_type' does not name a type
  151 | streamsize sputn(const char_type* s, streamsize n);
      |                        ^~~~~~~~~
p1507.cpp:155:1: error: invalid use of template-name 'std::basic_streambuf' without an argument list
  155 | basic_streambuf& operator=(const basic_streambuf& rhs);
      | ^~~~~~~~~~~~~~~
p1507.cpp:155: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:80:11: note: 'template<class _CharT, class _Traits> class std::basic_streambuf' declared here
   80 |     class basic_streambuf;
      |           ^~~~~~~~~~~~~~~
p1507.cpp:160:6: error: variable or field 'swap' declared void
  160 | void swap(basic_streambuf& rhs);
      |      ^~~~
p1507.cpp:160:26: error: missing template arguments before '&' token
  160 | void swap(basic_streambuf& rhs);
      |                          ^
p1507.cpp:160:28: error: 'rhs' was not declared in this scope
  160 | void swap(basic_streambuf& rhs);
      |                            ^~~
p1507.cpp:163:1: error: 'char_type' does not name a type
  163 | char_type* eback() const;
      | ^~~~~~~~~
p1507.cpp:170:4: error: 'char_type' does not name a type
  170 |    char_type* pbase() const;
      |    ^~~~~~~~~
p1507.cpp:175:6: error: variable or field 'setp' declared void
  175 | void setp(char_type* pbeg, char_type* pend);
      |      ^~~~
p1507.cpp:175:11: error: 'char_type' was not declared in this scope
  175 | void setp(char_type* pbeg, char_type* pend);
      |           ^~~~~~~~~
p1507.cpp:175:22: error: 'pbeg' was not declared in this scope
  175 | void setp(char_type* pbeg, char_type* pend);
      |                      ^~~~
p1507.cpp:175:28: error: 'char_type' was not declared in this scope
  175 | void setp(char_type* pbeg, char_type* pend);
      |                            ^~~~~~~~~
p1507.cpp:175:39: error: 'pend' was not declared in this scope
  175 | void setp(char_type* pbeg, char_type* pend);
      |                                       ^~~~
p1507.cpp:184:1: error: invalid use of template-name 'std::basic_streambuf' without an argument list
  184 | basic_streambuf* setbuf(char_type* s, streamsize n);
      | ^~~~~~~~~~~~~~~
p1507.cpp:184: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:80:11: note: 'template<class _CharT, class _Traits> class std::basic_streambuf' declared here
   80 |     class basic_streambuf;
      |           ^~~~~~~~~~~~~~~
p1507.cpp:187:1: error: 'pos_type' does not name a type
  187 | pos_type seekoff(off_type off, ios_base::seekdir way,
      | ^~~~~~~~
p1507.cpp:192:1: error: 'pos_type' does not name a type
  192 | pos_type seekpos(pos_type sp,
      | ^~~~~~~~
p1507.cpp:196:1: error: 'Default' does not name a type
  196 | Default behavior: Returns pos_type(off_type(-1)). int sync();
      | ^~~~~~~
p1507.cpp:203:19: error: 'char_type' was not declared in this scope
  203 | streamsize xsgetn(char_type* s, streamsize n);
      |                   ^~~~~~~~~
p1507.cpp:203:30: error: 's' was not declared in this scope
  203 | streamsize xsgetn(char_type* s, streamsize n);
      |                              ^
p1507.cpp:203:44: error: expected primary-expression before 'n'
  203 | streamsize xsgetn(char_type* s, streamsize n);
      |                                            ^
p1507.cpp:203:45: error: expression list treated as compound expression in initializer [-fpermissive]
  203 | streamsize xsgetn(char_type* s, streamsize n);
      |                                             ^
p1507.cpp:206:1: error: 'int_type' does not name a type
  206 | int_type underflow();
      | ^~~~~~~~
p1507.cpp:218:8: error: expected constructor, destructor, or type conversion before '>=' token
  218 | gptr() >= egptr(). int_type uflow();
      |        ^~
p1507.cpp:226:1: error: 'int_type' does not name a type
  226 | int_type pbackfail(int_type c = traits::eof());
      | ^~~~~~~~
p1507.cpp:234:25: error: 'char_type' does not name a type
  234 | streamsize xsputn(const char_type* s, streamsize n);
      |                         ^~~~~~~~~
p1507.cpp:246:1: error: 'Otherwise' does not name a type
  246 | Otherwise, returns some value other than traits::eof() to indicate success.287 Default behavior: Returns traits::eof().
      | ^~~~~~~~~

$ g++ p1507.cpp -std=2b -o p1507g -I. -Wall
p1507.cpp:16:27: error: redefinition of default argument for 'class traits'
   16 |     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 p1507.cpp:10:
/usr/local/include/c++/12.1.0/iosfwd:79:29: note: original definition appeared here
   79 |   template<typename _CharT, typename _Traits = char_traits<_CharT> >
      |                             ^~~~~~~~
p1507.cpp:32:27: error: redefinition of default argument for 'class traits'
   32 |     template<class charT, class traits = char_traits<charT>>
      |                           ^~~~~
/usr/local/include/c++/12.1.0/iosfwd:79:29: note: original definition appeared here
   79 |   template<typename _CharT, typename _Traits = char_traits<_CharT> >
      |                             ^~~~~~~~
p1507.cpp:108:17: error: template placeholder type 'const basic_streambuf<...auto...>' must be followed by a simple declarator-id
  108 | basic_streambuf(const basic_streambuf& rhs);
      |                 ^~~~~
/usr/local/include/c++/12.1.0/iosfwd:80:11: note: 'template<class _CharT, class _Traits> class std::basic_streambuf' declared here
   80 |     class basic_streambuf;
      |           ^~~~~~~~~~~~~~~
p1507.cpp:108:1: error: deduction guide for 'std::basic_streambuf<_CharT, _Traits>' must have trailing return type
  108 | basic_streambuf(const basic_streambuf& rhs);
      | ^~~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/iosfwd:80:11: note: 'template<class _CharT, class _Traits> class std::basic_streambuf' declared here
   80 |     class basic_streambuf;
      |           ^~~~~~~~~~~~~~~
p1507.cpp:111:17: error: expected class-name before '(' token
  111 | ~basic_streambuf(); Effects: None.
      |                 ^
p1507.cpp:111:28: error: found ':' in nested-name-specifier, expected '::'
  111 | ~basic_streambuf(); Effects: None.
      |                            ^
      |                            ::
p1507.cpp:111:21: error: 'Effects' does not name a type
  111 | ~basic_streambuf(); Effects: None.
      |                     ^~~~~~~
p1507.cpp:117:17: error: non-member function 'std::locale getloc()' cannot have cv-qualifier
  117 | locale getloc() const;
      |                 ^~~~~
p1507.cpp:120:1: error: template placeholder type 'basic_streambuf<...auto...>' must be followed by a simple declarator-id
  120 | basic_streambuf* pubsetbuf(char_type* s, streamsize n);
      | ^~~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/iosfwd:80:11: note: 'template<class _CharT, class _Traits> class std::basic_streambuf' declared here
   80 |     class basic_streambuf;
      |           ^~~~~~~~~~~~~~~
p1507.cpp:120:28: error: 'char_type' was not declared in this scope
  120 | basic_streambuf* pubsetbuf(char_type* s, streamsize n);
      |                            ^~~~~~~~~
p1507.cpp:120:39: error: 's' was not declared in this scope
  120 | basic_streambuf* pubsetbuf(char_type* s, streamsize n);
      |                                       ^
p1507.cpp:120:53: error: expected primary-expression before 'n'
  120 | basic_streambuf* pubsetbuf(char_type* s, streamsize n);
      |                                                     ^
p1507.cpp:122:1: error: 'pos_type' does not name a type
  122 | pos_type pubseekoff(off_type off, ios_base::seekdir way,
      | ^~~~~~~~
p1507.cpp:126:1: error: 'pos_type' does not name a type
  126 | pos_type pubseekpos(pos_type sp,
      | ^~~~~~~~
p1507.cpp:134:1: error: 'int_type' does not name a type
  134 | int_type snextc();
      | ^~~~~~~~
p1507.cpp:137:1: error: 'int_type' does not name a type
  137 | int_type sbumpc();
      | ^~~~~~~~
p1507.cpp:139:1: error: 'int_type' does not name a type
  139 | int_type sgetc();
      | ^~~~~~~~
p1507.cpp:141:18: error: 'char_type' was not declared in this scope
  141 | streamsize sgetn(char_type* s, streamsize n);
      |                  ^~~~~~~~~
p1507.cpp:141:29: error: 's' was not declared in this scope
  141 | streamsize sgetn(char_type* s, streamsize n);
      |                             ^
p1507.cpp:141:43: error: expected primary-expression before 'n'
  141 | streamsize sgetn(char_type* s, streamsize n);
      |                                           ^
p1507.cpp:141:44: error: expression list treated as compound expression in initializer [-fpermissive]
  141 | streamsize sgetn(char_type* s, streamsize n);
      |                                            ^
p1507.cpp:144:1: error: 'int_type' does not name a type
  144 | int_type sputbackc(char_type c);
      | ^~~~~~~~
p1507.cpp:146:1: error: 'int_type' does not name a type
  146 | int_type sungetc();
      | ^~~~~~~~
p1507.cpp:149:1: error: 'int_type' does not name a type
  149 | int_type sputc(char_type c);
      | ^~~~~~~~
p1507.cpp:151:24: error: 'char_type' does not name a type
  151 | streamsize sputn(const char_type* s, streamsize n);
      |                        ^~~~~~~~~
p1507.cpp:155:28: error: template placeholder type 'const basic_streambuf<...auto...>' must be followed by a simple declarator-id
  155 | basic_streambuf& operator=(const basic_streambuf& rhs);
      |                            ^~~~~
/usr/local/include/c++/12.1.0/iosfwd:80:11: note: 'template<class _CharT, class _Traits> class std::basic_streambuf' declared here
   80 |     class basic_streambuf;
      |           ^~~~~~~~~~~~~~~
p1507.cpp:155:1: error: deduced class type 'basic_streambuf' in function return type
  155 | basic_streambuf& operator=(const basic_streambuf& rhs);
      | ^~~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/iosfwd:80:11: note: 'template<class _CharT, class _Traits> class std::basic_streambuf' declared here
   80 |     class basic_streambuf;
      |           ^~~~~~~~~~~~~~~
p1507.cpp:160:11: error: template placeholder type 'basic_streambuf<...auto...>' must be followed by a simple declarator-id
  160 | void swap(basic_streambuf& rhs);
      |           ^~~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/iosfwd:80:11: note: 'template<class _CharT, class _Traits> class std::basic_streambuf' declared here
   80 |     class basic_streambuf;
      |           ^~~~~~~~~~~~~~~
p1507.cpp:163:1: error: 'char_type' does not name a type
  163 | char_type* eback() const;
      | ^~~~~~~~~
p1507.cpp:170:4: error: 'char_type' does not name a type
  170 |    char_type* pbase() const;
      |    ^~~~~~~~~
p1507.cpp:175:6: error: variable or field 'setp' declared void
  175 | void setp(char_type* pbeg, char_type* pend);
      |      ^~~~
p1507.cpp:175:11: error: 'char_type' was not declared in this scope
  175 | void setp(char_type* pbeg, char_type* pend);
      |           ^~~~~~~~~
p1507.cpp:175:22: error: 'pbeg' was not declared in this scope
  175 | void setp(char_type* pbeg, char_type* pend);
      |                      ^~~~
p1507.cpp:175:28: error: 'char_type' was not declared in this scope
  175 | void setp(char_type* pbeg, char_type* pend);
      |                            ^~~~~~~~~
p1507.cpp:175:39: error: 'pend' was not declared in this scope
  175 | void setp(char_type* pbeg, char_type* pend);
      |                                       ^~~~
p1507.cpp:184:1: error: template placeholder type 'basic_streambuf<...auto...>' must be followed by a simple declarator-id
  184 | basic_streambuf* setbuf(char_type* s, streamsize n);
      | ^~~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/iosfwd:80:11: note: 'template<class _CharT, class _Traits> class std::basic_streambuf' declared here
   80 |     class basic_streambuf;
      |           ^~~~~~~~~~~~~~~
p1507.cpp:184:25: error: 'char_type' was not declared in this scope
  184 | basic_streambuf* setbuf(char_type* s, streamsize n);
      |                         ^~~~~~~~~
p1507.cpp:184:36: error: 's' was not declared in this scope
  184 | basic_streambuf* setbuf(char_type* s, streamsize n);
      |                                    ^
p1507.cpp:184:50: error: expected primary-expression before 'n'
  184 | basic_streambuf* setbuf(char_type* s, streamsize n);
      |                                                  ^
p1507.cpp:187:1: error: 'pos_type' does not name a type
  187 | pos_type seekoff(off_type off, ios_base::seekdir way,
      | ^~~~~~~~
p1507.cpp:192:1: error: 'pos_type' does not name a type
  192 | pos_type seekpos(pos_type sp,
      | ^~~~~~~~
p1507.cpp:196:1: error: 'Default' does not name a type
  196 | Default behavior: Returns pos_type(off_type(-1)). int sync();
      | ^~~~~~~
p1507.cpp:203:19: error: 'char_type' was not declared in this scope
  203 | streamsize xsgetn(char_type* s, streamsize n);
      |                   ^~~~~~~~~
p1507.cpp:203:30: error: 's' was not declared in this scope
  203 | streamsize xsgetn(char_type* s, streamsize n);
      |                              ^
p1507.cpp:203:44: error: expected primary-expression before 'n'
  203 | streamsize xsgetn(char_type* s, streamsize n);
      |                                            ^
p1507.cpp:203:45: error: expression list treated as compound expression in initializer [-fpermissive]
  203 | streamsize xsgetn(char_type* s, streamsize n);
      |                                             ^
p1507.cpp:206:1: error: 'int_type' does not name a type
  206 | int_type underflow();
      | ^~~~~~~~
p1507.cpp:218:8: error: expected constructor, destructor, or type conversion before '>=' token
  218 | gptr() >= egptr(). int_type uflow();
      |        ^~
p1507.cpp:226:1: error: 'int_type' does not name a type
  226 | int_type pbackfail(int_type c = traits::eof());
      | ^~~~~~~~
p1507.cpp:234:25: error: 'char_type' does not name a type
  234 | streamsize xsputn(const char_type* s, streamsize n);
      |                         ^~~~~~~~~
p1507.cpp:246:1: error: 'Otherwise' does not name a type
  246 | Otherwise, returns some value other than traits::eof() to indicate success.287 Default behavior: Returns traits::eof().
      | ^~~~~~~~~

```

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

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

## 応用例1　AUTOSAR C++

AUTOSARでC++のコーディング標準を作っている。　
MISRA-C++コーディング標準の改訂をまたずに、C++14に対応したかったためかもしれない。　

Autosar Guidelines C++14 example code compile list

https://qiita.com/kaizen_nagoya/items/8ccbf6675c3494d57a76

MISRA C++, AUTOSAR C++について

https://qiita.com/kaizen_nagoya/items/3436fbd49865e0da7d35

## 応用例2　MISRA C/C++

MISRA C まとめ #include <misra_c.h>

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

MISRA C++ 5-0-16

https://qiita.com/kaizen_nagoya/items/7df2d4e05db724752a74

## 応用例3 CERT C/C++

SEI CERT C++ Coding Standard AA. Bibliography 確認中。

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

MISRA C/C++, AUTOSAR C++, CERT C/C++とC/C++工業標準をコンパイルする

https://qiita.com/kaizen_nagoya/items/8dff19511e42b2593db1

## 応用例4 箱庭　

箱庭もくもく会 #10 日時：2022/09/14(水) 17:30-19:30

https://hakoniwa.connpass.com/event/258129/

箱庭ではUnityをはじめC++を使っているらしい。　

ここでコンパイルしたコードと同じようなコードを使っているか、
ここで出たコンパイルエラーと同じようなエラーがでたかを
いろいろな版のコンパイラでコンパイルして確認していく。

この項目は、箱庭プロジェクトを市場分析の対象として、原則的には、箱庭プロジェクトの外部から分析し、外部から箱庭の広告宣伝のための戦略会議を仮想した結果、仮想「箱庭もくもく会」を開催してみることを企画するものである。　
一切の内容は、箱庭プロジェクト、Athrill, TOPPERSとは無関係である。　
一(いち)参加データアナリストの、個人的なつぶやきです。

仮想戦略会議「箱庭」

https://qiita.com/kaizen_nagoya/items/73cb132707653176a461

お盆には「箱庭」記事を書きましょう「もくもく会」の題材になる（１）

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

お盆には「箱庭」記事を書きましょう「もくもく会」の題材になる（2）

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


# エンジニア夏休み企画

https://qiita.com/official-events/6d31965c499a69377c0b

個人開発と読書感想文に焦点を当てたのは良い企画だと思った。

## 個人開発

【個人開発】　効率的な背景　＜エンジニア夏休み企画＞

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

Cコンパイラの試験を一人でもくもくとやっているのは個人開発の一つの姿です。

## 読書感想文

CコンパイラによるC言語規格の読書感想文として掲載しています。
コンパイル実験が、C++N4910に対する、G++とClang++による感想文だということご理解いただけると幸いです。

読書感想文は人間かAIだけが作るものとは限りません。
本（電子書籍を含む）を入力として、その内容に対する文字列を読書感想文として受け止めましょう。
元の文章をあり方、コンパイルできるように電子化しておくこと、コンパイラが解釈可能な断片の作り方など。

https://qiita.com/tags/読書感想文

## 自己参考資料(self 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/kaizen_nagoya/items/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

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

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