Buckets:
| //===----------------------------------------------------------------------===// | |
| // | |
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| // See https://llvm.org/LICENSE.txt for license information. | |
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| // | |
| //===----------------------------------------------------------------------===// | |
| _LIBCPP_BEGIN_NAMESPACE_STD | |
| template <class StreamT, class BufferT> | |
| union stream_data { | |
| constexpr stream_data() {} | |
| constexpr ~stream_data() {} | |
| struct { | |
| // The stream has to be the first element, since that's referenced by the stream declarations in <iostream> | |
| StreamT stream; | |
| BufferT buffer; | |
| mbstate_t mb; | |
| }; | |
| void init(FILE* stdstream) { | |
| mb = {}; | |
| std::construct_at(&buffer, stdstream, &mb); | |
| std::construct_at(&stream, &buffer); | |
| } | |
| }; | |
| // These definitions and the declarations in <iostream> technically cause ODR violations, since they have different | |
| // types (stream_data and {i,o}stream respectively). This means that <iostream> should never be included in this TU. | |
| _LIBCPP_EXPORTED_FROM_ABI STREAM(basic_istream, __stdinbuf, char, cin); | |
| _LIBCPP_EXPORTED_FROM_ABI STREAM(basic_ostream, __stdoutbuf, char, cout); | |
| _LIBCPP_EXPORTED_FROM_ABI STREAM(basic_ostream, __stdoutbuf, char, cerr); | |
| _LIBCPP_EXPORTED_FROM_ABI STREAM(basic_ostream, __stdoutbuf, char, clog); | |
| _LIBCPP_EXPORTED_FROM_ABI STREAM(basic_istream, __stdinbuf, wchar_t, wcin); | |
| _LIBCPP_EXPORTED_FROM_ABI STREAM(basic_ostream, __stdoutbuf, wchar_t, wcout); | |
| _LIBCPP_EXPORTED_FROM_ABI STREAM(basic_ostream, __stdoutbuf, wchar_t, wcerr); | |
| _LIBCPP_EXPORTED_FROM_ABI STREAM(basic_ostream, __stdoutbuf, wchar_t, wclog); | |
| // Pretend we're inside a system header so the compiler doesn't flag the use of the init_priority | |
| // attribute with a value that's reserved for the implementation (we're the implementation). | |
| // On Windows the TLS storage for locales needs to be initialized before we create | |
| // the standard streams, otherwise it may not be alive during program termination | |
| // when we flush the streams. | |
| static void force_locale_initialization() { | |
| static bool once = []() { | |
| auto loc = __locale::__newlocale(_LIBCPP_ALL_MASK, "C", 0); | |
| { | |
| __locale::__locale_guard g(loc); // forces initialization of locale TLS | |
| ((void)g); | |
| } | |
| __locale::__freelocale(loc); | |
| return true; | |
| }(); | |
| ((void)once); | |
| } | |
| class DoIOSInit { | |
| public: | |
| DoIOSInit(); | |
| ~DoIOSInit(); | |
| }; | |
| DoIOSInit::DoIOSInit() { | |
| force_locale_initialization(); | |
| cin.init(stdin); | |
| cout.init(stdout); | |
| cerr.init(stderr); | |
| clog.init(stderr); | |
| cin.stream.tie(&cout.stream); | |
| std::unitbuf(cerr.stream); | |
| cerr.stream.tie(&cout.stream); | |
| wcin.init(stdin); | |
| wcout.init(stdout); | |
| wcerr.init(stderr); | |
| wclog.init(stderr); | |
| wcin.stream.tie(&wcout.stream); | |
| std::unitbuf(wcerr.stream); | |
| wcerr.stream.tie(&wcout.stream); | |
| } | |
| DoIOSInit::~DoIOSInit() { | |
| cout.stream.flush(); | |
| clog.stream.flush(); | |
| wcout.stream.flush(); | |
| wclog.stream.flush(); | |
| } | |
| ios_base::Init::Init() { | |
| static DoIOSInit init_the_streams; // gets initialized once | |
| } | |
| ios_base::Init::~Init() {} | |
| _LIBCPP_END_NAMESPACE_STD | |
Xet Storage Details
- Size:
- 4.42 kB
- Xet hash:
- bab64e4eff17e1f3ecf3bd32d2b8a9e4cc866ea817c91f1d2ffbfddea93734ae
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.