//------------------------------------------------------------------------------ /* This file is part of Beast: https://github.com/vinniefalco/Beast Copyright 2013, Vinnie Falco Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== #ifndef BEAST_UTILITY_STD_OSTREAM_H_INCLUDED #define BEAST_UTILITY_STD_OSTREAM_H_INCLUDED #include #include namespace beast { /** Wraps an existing std::basic_ostream as an abstract_ostream. */ template < class CharT, class Traits = std::char_traits > class basic_std_ostream : public basic_abstract_ostream { private: using typename basic_abstract_ostream ::string_type; std::reference_wrapper m_stream; public: explicit basic_std_ostream ( std::basic_ostream & stream) : m_stream (stream) { } void write (string_type const& s) override { m_stream.get() << s << std::endl; } }; typedef basic_std_ostream std_ostream; //------------------------------------------------------------------------------ /** Returns a basic_std_ostream using template argument deduction. */ template < class CharT, class Traits = std::char_traits > basic_std_ostream make_std_ostream (std::basic_ostream & stream) { return basic_std_ostream (stream); } } #endif