source: mainline/uspace/lib/cpp/src/iostream.cpp@ 8fd0675f

Last change on this file since 8fd0675f 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
RevLine 
[21a7ebc]1/*
[b57ba05]2 * SPDX-FileCopyrightText: 2018 Jaroslav Jindrak
[21a7ebc]3 *
[b57ba05]4 * SPDX-License-Identifier: BSD-3-Clause
[21a7ebc]5 */
6
[b57a3ee]7#include <__bits/io/streambufs.hpp>
[21a7ebc]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 {
[4ff55d2]28 // TODO: These buffers should be static too
29 // in case somebody reassigns to cout/cin.
[21a7ebc]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 {
[7d0f2eb]39 if (--init_cnt_ == 0)
40 cout.flush();
[21a7ebc]41 }
42}
Note: See TracBrowser for help on using the repository browser.