[ostream.inserters.character]

# 31 Input/output library [[input.output]](./#input.output)

## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#ostream.inserters.character)

### 31.7.6 Output streams [[output.streams]](output.streams#ostream.inserters.character)

#### 31.7.6.3 Formatted output functions [[ostream.formatted]](ostream.formatted#ostream.inserters.character)

#### 31.7.6.3.4 Character inserter function templates [ostream.inserters.character]

[ð](#lib:operator%3c%3c,basic_ostream)

`template<class charT, class traits>
  basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& out, charT c);
template<class charT, class traits>
  basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& out, char c);
// specialization
template<class traits>
  basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, char c);
// signed and unsigned
template<class traits>
  basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, signed char c);
template<class traits>
  basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, unsigned char c);
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6725)

*Effects*: Behaves as a [formatted output function](ostream.formatted.reqmts "31.7.6.3.1 Common requirements [ostream.formatted.reqmts]") of out[.](#1.sentence-1)

Constructs a character sequence seq[.](#1.sentence-2)

If c has typechar and the character container type of the stream is notchar,
then seq consists ofout.widen(c);
otherwise seq consists ofc[.](#1.sentence-3)

Determines padding for seq as described
in [[ostream.formatted.reqmts]](ostream.formatted.reqmts "31.7.6.3.1 Common requirements")[.](#1.sentence-4)

Inserts seq intoout[.](#1.sentence-5)

Calls os.width(0)[.](#1.sentence-6)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6740)

*Returns*: out[.](#2.sentence-1)

[ð](#lib:operator%3c%3c,basic_ostream_)

`template<class charT, class traits>
  basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& out, const charT* s);
template<class charT, class traits>
  basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& out, const char* s);
template<class traits>
  basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, const char* s);
template<class traits>
  basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, const signed char* s);
template<class traits>
  basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out,
                                          const unsigned char* s);
`

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6761)

*Preconditions*: s is not a null pointer[.](#3.sentence-1)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6765)

*Effects*: Behaves like a formatted inserter (as described in [[ostream.formatted.reqmts]](ostream.formatted.reqmts "31.7.6.3.1 Common requirements")) of out[.](#4.sentence-1)

Creates a character sequence seq of n characters
starting at s, each widened usingout.widen() ([[basic.ios.members]](basic.ios.members "31.5.4.3 Member functions")),
where n is the number that would be computed as if by:

- [(4.1)](#4.1)

traits​::​length(s) for the overload where the first argument is of typebasic_ostream<charT, traits>& and the second is of typeconst charT*,
and also for the overload where the first argument is of typebasic_ostream<char, traits>& and the second is of typeconst char*,

- [(4.2)](#4.2)

char_traits<char>​::​length(s) for the overload where the first argument is of typebasic_ostream<charT, traits>& and the second is of typeconst char*,

- [(4.3)](#4.3)

traits​::​length(reinterpret_cast<const char*>(s)) for the other two overloads[.](#4.sentence-2)

Determines padding for seq as described
in [[ostream.formatted.reqmts]](ostream.formatted.reqmts "31.7.6.3.1 Common requirements")[.](#4.sentence-3)

Inserts seq intoout[.](#4.sentence-4)

Calls width(0)[.](#4.sentence-5)

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6797)

*Returns*: out[.](#5.sentence-1)
