C%2b%2b Ostream Dev Null

C%2b%2b Ostream Dev Null
  1. 这个问题已经在这里有了答案: 9年前关闭。 Possible Duplicate: Implementing a no-op std::ostream 在c中是否有与NULL等价的流?我想编写一个函数,如果用户希望将内部输出输出到某个地方,则将其带入一个流中,但是如果没有,则输出进入某个伪造的地方.
  2. To define the ostream class in C sources, the ostream header file must be included. To use the predefined ostream objects (std::cerr, std::cout etc.) the header file must be included. 6.4.1.1: Writing to `ostream’ objects The class ostream supports both formatted and binary output.
  3. An Ostream is an abstract base class for all output systems (streams, files, token lists.
C%2b%2b Ostream Dev Null
  • for the first and third overloads (where CharT matches the type of ch), exactly traits::length(s) characters are inserted.
  • for the second overload, exactly std::char_traits<char>::length(s) characters are inserted.
  • for the last two overloads, exactly traits::length(reinterpret_cast<constchar*>(s)) are inserted.
Ostream
Dev

[edit]Parameters

os — output stream to insert data to ch — reference to a character to insert s — pointer to a character string to insert

[edit]Return value

1–2)os

[edit]Notes

Before LWG#1203, code such as (std::ostringstream()<<1.2).str() does not compile.

C%2b%2b Ostream Dev Null

[edit]Example

Output:

[edit]Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

[edit]See also

C 2b 2b Ostream Dev Null Test

inserts formatted data
(public member function)[edit] widens characters
(public member function of std::basic_ios<CharT,Traits>)[edit]

C 2b 2b Ostream Dev Null Command

Retrieved from ‘https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ostream/operator_ltlt2&oldid=116601'

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store