##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# Standard library header <ostream>

From cppreference.com
< cpp‎ | header

This header is part of the Input/output library.

### Classes
basic_ostream | wraps a given abstract device (std::basic_streambuf) and provides high-level output interface (class template)
std::ostream | basic_ostream<char> (typedef)
std::wostream | basic_ostream<wchar_t> (typedef)
### Functions
operator<<(std::basic_ostream) | inserts character data (function) [edit]
##### Manipulators
ends | outputs '\0' (function template) [edit]
flush | flushes the output stream (function template) [edit]
endl | outputs '\n' and flushes the output stream (function template) [edit]

### [edit] Synopsis

    namespace std {
        template <class charT, class traits = char_traits<charT> >
            class basic_ostream;
        typedef basic_ostream<char>    ostream;
        typedef basic_ostream<wchar_t> wostream;

        template <class charT, class traits>
            basic_ostream<charT,traits>& endl(basic_ostream<charT,traits>& os);
        template <class charT, class traits>
            basic_ostream<charT,traits>& ends(basic_ostream<charT,traits>& os);
        template <class charT, class traits>
            basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os);

        template <class charT, class traits, class T>
            basic_ostream<charT, traits>&
            operator<<(basic_ostream<charT, traits>&& os, const T& x);

        // character inserters
        template<class charT, class traits>
            basic_ostream<charT,traits>&
            operator<<(basic_ostream<charT,traits>&, charT);
        template<class charT, class traits>
            basic_ostream<charT,traits>&
            operator<<(basic_ostream<charT,traits>&, char);
        template<class traits>
            basic_ostream<char,traits>&
            operator<<(basic_ostream<char,traits>&, char);

        // signed and unsigned
        template<class traits>
            basic_ostream<char,traits>&
            operator<<(basic_ostream<char,traits>&, signed char);
        template<class traits>
            basic_ostream<char,traits>&
            operator<<(basic_ostream<char,traits>&, unsigned char);
        template<class charT, class traits>
            basic_ostream<charT,traits>&
            operator<<(basic_ostream<charT,traits>&, const charT*);
        template<class charT, class traits>
            basic_ostream<charT,traits>&
            operator<<(basic_ostream<charT,traits>&, const char*);
        template<class traits>
            basic_ostream<char,traits>&
            operator<<(basic_ostream<char,traits>&, const char*);

        // signed and unsigned
        template<class traits>
            basic_ostream<char,traits>&
            operator<<(basic_ostream<char,traits>&, const signed char*);
        template<class traits>
            basic_ostream<char,traits>&
            operator<<(basic_ostream<char,traits>&, const unsigned char*);
    }

#### [edit] Class std::basic_ostream

    template <class charT, class traits = char_traits<charT> >
    class basic_ostream : virtual public basic_ios<charT,traits> {
    public:
        // types (inherited from basic_ios):
        typedef charT                     char_type;
        typedef typename traits::int_type int_type;
        typedef typename traits::pos_type pos_type;
        typedef typename traits::off_type off_type;
        typedef traits                    traits_type;

        // Constructor/destructor:
        explicit basic_ostream(basic_streambuf<char_type,traits>* sb);
        virtual ~basic_ostream();

        // Prefix/suffix:
        class sentry;

        // Formatted output:
        basic_ostream<charT,traits>& operator<<(
            basic_ostream<charT,traits>& (*pf)(basic_ostream<charT,traits>&));
        basic_ostream<charT,traits>& operator<<(
            basic_ios<charT,traits>& (*pf)(basic_ios<charT,traits>&));
        basic_ostream<charT,traits>& operator<<(
            ios_base& (*pf)(ios_base&));

        basic_ostream<charT,traits>& operator<<(bool n);
        basic_ostream<charT,traits>& operator<<(short n);
        basic_ostream<charT,traits>& operator<<(unsigned short n);
        basic_ostream<charT,traits>& operator<<(int n);
        basic_ostream<charT,traits>& operator<<(unsigned int n);
        basic_ostream<charT,traits>& operator<<(long n);
        basic_ostream<charT,traits>& operator<<(unsigned long n);
        basic_ostream<charT,traits>& operator<<(long long n);
        basic_ostream<charT,traits>& operator<<(unsigned long long n);
        basic_ostream<charT,traits>& operator<<(float f);
        basic_ostream<charT,traits>& operator<<(double f);
        basic_ostream<charT,traits>& operator<<(long double f);

        basic_ostream<charT,traits>& operator<<(const void* p);
        basic_ostream<charT,traits>& operator<<(
            basic_streambuf<char_type,traits>* sb);

        // Unformatted output:
        basic_ostream<charT,traits>& put(char_type c);
        basic_ostream<charT,traits>& write(const char_type* s, streamsize n);

        basic_ostream<charT,traits>& flush();

        // seeks:
        pos_type tellp();
        basic_ostream<charT,traits>& seekp(pos_type);
        basic_ostream<charT,traits>& seekp(off_type, ios_base::seekdir);

    protected:
        basic_ostream(const basic_ostream& rhs) = delete;
        basic_ostream(basic_ostream&& rhs);

        // Assign/swap
        basic_ostream& operator=(basic_ostream& rhs) = delete;
        basic_ostream& operator=(const basic_ostream&& rhs);
        void swap(basic_ostream& rhs);
    };

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/header/ostream&oldid=57518"