1////
2Copyright 2019 Glen Joseph Fernandes
3([email protected])
4
5Distributed under the Boost Software License, Version 1.0.
6(http://www.boost.org/LICENSE_1_0.txt)
7////
8
9# Insert Formatted Output, <boost/io/ostream_put.hpp>
10:toc:
11:toc-title:
12:idprefix:
13
14## Description
15
16The header `<boost/io/ostream_put.hpp>` provides the function template
17`boost::io::ostream_put` for formatted output that satisfies the requirements
18of [ostream.formatted.reqmts].
19
20## Example
21
22The inserter for class template `basic_string_view` could be implemented as
23follows:
24
25```
26template<class charT, class traits>
27std::basic_ostream<charT, traits>&
28operator<<(std::basic_ostream<charT, traits>& os,
29    const basic_string_view<charT, traits>& str)
30{
31    return boost::io::ostream_put(os, str.data(), str.size());
32}
33```
34
35## Reference
36
37### Header Synopsis
38
39```
40namespace boost {
41namespace io {
42
43template<class charT, class traits>
44std::basic_ostream<charT, traits>&
45ostream_put(std::basic_ostream<charT, traits>& os,
46    const charT* data, std::size_t size);
47
48} // io
49} // boost
50```
51
52### Free functions
53
54```
55template<class charT, class traits>
56std::basic_ostream<charT, traits>&
57ostream_put(std::basic_ostream<charT, traits>& os,
58    const charT* data, std::size_t size);
59```
60
61[.specification]
62Effects:: Behaves like a formatted inserter (as described in
63[ostream.formatted.reqmts]) of `os`. Creates a character sequence `seq` of size
64characters starting at `data`, each widened using `os.widen()`
65([basic.ios.members]). Determines padding for `seq` as described in
66[ostream.formatted.reqmts]. Inserts `seq` into `os`. Calls `width(0)`.
67Returns:: `os`.
68
69## Acknowledgments
70
71Glen Fernandes updated the implementation of the `basic_string_ref` and
72`basic_string_view` stream insertion operators to write directly to the
73`basic_streambuf` and refactored that functionality into this common utility.
74