std::wbuffe...ffer_convert(3)
πΈ NAME πΈ
okay so bestie, this is the manual page for std::wbuffer_convert::wbuffer_convert from the C++ Standard Library β yes, the constructor page, and the header is out here truncating like std::wbuffe...ffer_convert(3) (iykyk π).
β¨ Synopsis β¨
the signatures are giving constructor realness, and (since C++14) is part of the vibe:
wbuffer_convert() : wbuffer_convert(nullptr) {} (1)
explicit wbuffer_convert( std::streambuf* bytebuf,
Codecvt* pcvt = new Codecvt, (2)
state_type state = state_type() );
wbuffer_convert( const std::wbuffer_convert& ) = delete; (3)
(since C++14)
- Default constructor. literally the default one, and the signature shows it forwarding to
wbuffer_convert(nullptr). - Constructs the
wbuffer_convertobject with the specified underlying byte stream, specifiedcodecvtfacet, and specified initial conversion state β all parameters are optional, bestie. - The copy constructor is deleted, so
wbuffer_convertis notCopyConstructible. no cap, it said what it said π .
π Parameters π
bytebufβ pointer tostd::streambufto serve as the underlying narrow character stream.pcvtβ pointer to a standalone (not managed by a locale)std::codecvtfacet. The behavior is undefined if this pointer is null, so please do not play with that.stateβ the initial value of the character conversion state.
fr fr, pcvt being null is not a cute look β undefined behavior is not invited to the group chat.
π©Ή Defect reports π©Ή
The following behavior-changing defect reports were applied retroactively to previously published C++ standards. history really said βlet me fix that for youβ:
P0935R0β applied to C++11; behavior as published: default constructor wasexplicit; correct behavior: made implicit. slay, glow-up applied retroactively β¨
π Example π
// Run this code
#include <codecvt>
#include <iostream>
#include <locale>
#include <sstream>
int main()
{
// Wrap a UTF-8 string stream in a UCS4 wbuffer_convert
std::stringbuf utf8buf("z\u00df\u6c34\U0001f34c");
// or "\x7a\xc3\x9f\xe6\xb0\xb4\xf0\x9f\x8d\x8c"
// or u8"zΓζ°΄π"
std::wbuffer_convert<std::codecvt_utf8<wchar_t>> conv_in(&utf8buf);
std::wistream ucsbuf(&conv_in);
std::cout << "Reading from a UTF-8 stringbuf via wbuffer_convert: "
<< std::hex << std::showbase;
for (wchar_t c; ucsbuf.get(c);)
std::cout << static_cast<std::wint_t>(c) << ' ';
// Wrap a UTF-8 aware std::cout in a UCS4 wbuffer_convert to output UCS4
std::wbuffer_convert<std::codecvt_utf8<wchar_t>> conv_out(std::cout.rdbuf());
std::wostream out(&conv_out);
std::cout << "\nSending UCS4 data to std::cout via wbuffer_convert: ";
out << L"z\u00df\u6c34\U0001f34c\n";
}
π Output π
Reading from a UTF-8 stringbuf via wbuffer_convert: 0x7a 0xdf 0x6c34 0x1f34c
Sending UCS4 data to std::cout via wbuffer_convert: zΓζ°΄π
and thatβs the whole page, bestie π«Ά this little manual moment came from cppreference.com, dated 2024.06.10 β bye icon, go wrap those buffers πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms