source: mainline/uspace/lib/cpp/src/iostream.cpp@ 8624d1f

Last change on this file since 8624d1f was b57ba05, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 3 years ago

Update headers in C++ files

  • Property mode set to 100644
File size: 832 bytes
Line 
1/*
2 * SPDX-FileCopyrightText: 2018 Jaroslav Jindrak
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <__bits/io/streambufs.hpp>
8#include <ios>
9#include <iostream>
10#include <new>
11
12namespace std
13{
14 istream cin{nullptr};
15 ostream cout{nullptr};
16
17 namespace aux
18 {
19 ios_base::Init init{};
20 }
21
22 int ios_base::Init::init_cnt_{};
23
24 ios_base::Init::Init()
25 {
26 if (init_cnt_++ == 0)
27 {
28 // TODO: These buffers should be static too
29 // in case somebody reassigns to cout/cin.
30 ::new(&cin) istream{::new aux::stdin_streambuf<char>{}};
31 ::new(&cout) ostream{::new aux::stdout_streambuf<char>{}};
32
33 cin.tie(&cout);
34 }
35 }
36
37 ios_base::Init::~Init()
38 {
39 if (--init_cnt_ == 0)
40 cout.flush();
41 }
42}
Note: See TracBrowser for help on using the repository browser.