Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:52:41

0001 //  (C) Copyright Gennadiy Rozental 2001.
0002 //  Distributed under the Boost Software License, Version 1.0.
0003 //  (See accompanying file LICENSE_1_0.txt or copy at
0004 //  http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 //  See http://www.boost.org/libs/test for the library home page.
0007 //
0008 //  File        : $RCSfile$
0009 //
0010 //  Version     : $Revision$
0011 //
0012 //  Description : basic_cstring i/o implementation
0013 // ***************************************************************************
0014 
0015 #ifndef BOOST_TEST_UTILS_BASIC_CSTRING_IO_HPP
0016 #define BOOST_TEST_UTILS_BASIC_CSTRING_IO_HPP
0017 
0018 // Boost.Test
0019 #include <boost/test/utils/basic_cstring/basic_cstring.hpp>
0020 
0021 // STL
0022 #include <iosfwd>
0023 #include <string>
0024 
0025 #include <boost/test/detail/suppress_warnings.hpp>
0026 
0027 //____________________________________________________________________________//
0028 
0029 namespace boost {
0030 
0031 namespace unit_test {
0032 
0033 #ifdef BOOST_CLASSIC_IOSTREAMS
0034 
0035 template<typename CharT>
0036 inline std::ostream&
0037 operator<<( std::ostream& os, basic_cstring<CharT> const& str )
0038 {
0039     typedef typename ut_detail::bcs_base_char<CharT>::type char_type;
0040     char_type const* const beg = reinterpret_cast<char_type const* const>( str.begin() );
0041     char_type const* const end = reinterpret_cast<char_type const* const>( str.end() );
0042     os << std::basic_string<char_type>( beg, end - beg );
0043 
0044     return os;
0045 }
0046 
0047 #else
0048 
0049 template<typename CharT1, typename Tr,typename CharT2>
0050 inline std::basic_ostream<CharT1,Tr>&
0051 operator<<( std::basic_ostream<CharT1,Tr>& os, basic_cstring<CharT2> const& str )
0052 {
0053     CharT1 const* const beg = reinterpret_cast<CharT1 const*>( str.begin() ); // !!
0054     CharT1 const* const end = reinterpret_cast<CharT1 const*>( str.end() );
0055     os << std::basic_string<CharT1,Tr>( beg, end - beg );
0056 
0057     return os;
0058 }
0059 
0060 #endif
0061 
0062 //____________________________________________________________________________//
0063 
0064 
0065 } // namespace unit_test
0066 
0067 } // namespace boost
0068 
0069 //____________________________________________________________________________//
0070 
0071 #include <boost/test/detail/enable_warnings.hpp>
0072 
0073 #endif // BOOST_TEST_BASIC_CSTRING_IO_HPP_071894GER