- spanstream[meta header]
- std[meta namespace]
- class template[meta id-type]
- cpp23[meta cpp]
- ospanstream,wospanstream[meta alias]
namespace std {
template <class CharT,
class Traits = char_traits<CharT> >
class basic_ospanstream : public basic_ostream<CharT, Traits>;
using ospanstream = basic_ospanstream<char>;
using wospanstream = basic_ospanstream<wchar_t>;
}
- char_traits[link /reference/string/char_traits.md]
- basic_ostream[link /reference/ostream/basic_ostream.md]
std::basic_ospanstreamクラスは、std::span を使用した固定長ストリームバッファを出力先とする出力ストリームである。
| 名前 |
説明 |
対応バージョン |
swap |
2つのオブジェクトを入れ替える |
C++23 |
| 名前 |
説明 |
対応バージョン |
char_type |
テンプレート仮引数CharT |
C++23 |
int_type |
Traits::int_type |
C++23 |
pos_type |
Traits::pos_type |
C++23 |
off_type |
Traits::off_type |
C++23 |
traits_type |
テンプレート仮引数Traits |
C++23 |
#include <iostream>
#include <span>
#include <spanstream>
int main()
{
char buf[256] = {};
std::span<char> span{buf};
std::ospanstream oss(span);
// 数値や文字列を書き込む
oss << "The answer is " << 42 << " and pi is approximately " << 3.14;
// 先頭から文字列出力
const char* p = oss.span().data();
std::cout << p << std::endl;
}
- std::ospanstream[color ff0000]
- std::span[link /reference/span/span.md]
- span()[link /reference/spanstream/basic_ospanstream/span.md]
- data()[link /reference/span/span/data.md]
The answer is 42 and pi is approximately 3.14