Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame^] | 1 | // Boost.Range library |
| 2 | // |
| 3 | // Copyright Neil Groves 2009. |
| 4 | // Use, modification and distribution is subject to the Boost Software |
| 5 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
| 6 | // http://www.boost.org/LICENSE_1_0.txt) |
| 7 | // |
| 8 | // For more information, see http://www.boost.org/libs/range/ |
| 9 | // |
| 10 | #ifndef BOOST_RANGE_ITERATOR_RANGE_IO_HPP_INCLUDED |
| 11 | #define BOOST_RANGE_ITERATOR_RANGE_IO_HPP_INCLUDED |
| 12 | |
| 13 | #include <ndnboost/config.hpp> |
| 14 | #include <ndnboost/detail/workaround.hpp> |
| 15 | |
| 16 | #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500)) |
| 17 | #pragma warning( push ) |
| 18 | #pragma warning( disable : 4996 ) |
| 19 | #endif |
| 20 | |
| 21 | // From boost/dynamic_bitset.hpp; thanks to Matthias Troyer for Cray X1 patch. |
| 22 | #ifndef BOOST_OLD_IOSTREAMS |
| 23 | # if defined(__STL_CONFIG_H) && \ |
| 24 | !defined (__STL_USE_NEW_IOSTREAMS) && !defined(__crayx1) \ |
| 25 | /**/ |
| 26 | # define BOOST_OLD_IOSTREAMS |
| 27 | # endif |
| 28 | #endif // #ifndef BOOST_OLD_IOSTREAMS |
| 29 | |
| 30 | #ifndef _STLP_NO_IOSTREAMS |
| 31 | # ifndef BOOST_OLD_IOSTREAMS |
| 32 | # include <ostream> |
| 33 | # else |
| 34 | # include <ostream.h> |
| 35 | # endif |
| 36 | #endif // _STLP_NO_IOSTREAMS |
| 37 | |
| 38 | #include <ndnboost/range/iterator_range_core.hpp> |
| 39 | #include <iterator> |
| 40 | #include <algorithm> |
| 41 | #include <cstddef> |
| 42 | |
| 43 | namespace ndnboost |
| 44 | { |
| 45 | |
| 46 | #ifndef _STLP_NO_IOSTREAMS |
| 47 | # ifndef BOOST_OLD_IOSTREAMS |
| 48 | |
| 49 | //! iterator_range output operator |
| 50 | /*! |
| 51 | Output the range to an ostream. Elements are outputted |
| 52 | in a sequence without separators. |
| 53 | */ |
| 54 | template< typename IteratorT, typename Elem, typename Traits > |
| 55 | inline std::basic_ostream<Elem,Traits>& operator<<( |
| 56 | std::basic_ostream<Elem, Traits>& Os, |
| 57 | const iterator_range<IteratorT>& r ) |
| 58 | { |
| 59 | std::copy( r.begin(), r.end(), |
| 60 | std::ostream_iterator< BOOST_DEDUCED_TYPENAME |
| 61 | iterator_value<IteratorT>::type, |
| 62 | Elem, Traits>(Os) ); |
| 63 | return Os; |
| 64 | } |
| 65 | |
| 66 | # else |
| 67 | |
| 68 | //! iterator_range output operator |
| 69 | /*! |
| 70 | Output the range to an ostream. Elements are outputted |
| 71 | in a sequence without separators. |
| 72 | */ |
| 73 | template< typename IteratorT > |
| 74 | inline std::ostream& operator<<( |
| 75 | std::ostream& Os, |
| 76 | const iterator_range<IteratorT>& r ) |
| 77 | { |
| 78 | std::copy( r.begin(), r.end(), std::ostream_iterator<char>(Os)); |
| 79 | return Os; |
| 80 | } |
| 81 | |
| 82 | # endif |
| 83 | #endif // _STLP_NO_IOSTREAMS |
| 84 | |
| 85 | } // namespace ndnboost |
| 86 | |
| 87 | #undef BOOST_OLD_IOSTREAMS |
| 88 | |
| 89 | #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500)) |
| 90 | #pragma warning(pop) |
| 91 | #endif |
| 92 | |
| 93 | #endif // include guard |