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 | // |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 10 | #ifndef NDNBOOST_RANGE_ITERATOR_RANGE_IO_HPP_INCLUDED |
| 11 | #define NDNBOOST_RANGE_ITERATOR_RANGE_IO_HPP_INCLUDED |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 12 | |
| 13 | #include <ndnboost/config.hpp> |
| 14 | #include <ndnboost/detail/workaround.hpp> |
| 15 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 16 | #if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, NDNBOOST_TESTED_AT(1500)) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 17 | #pragma warning( push ) |
| 18 | #pragma warning( disable : 4996 ) |
| 19 | #endif |
| 20 | |
Jeff Thompson | 9939dcd | 2013-10-15 15:12:24 -0700 | [diff] [blame] | 21 | // From ndnboost/dynamic_bitset.hpp; thanks to Matthias Troyer for Cray X1 patch. |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 22 | #ifndef NDNBOOST_OLD_IOSTREAMS |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 23 | # if defined(__STL_CONFIG_H) && \ |
| 24 | !defined (__STL_USE_NEW_IOSTREAMS) && !defined(__crayx1) \ |
| 25 | /**/ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 26 | # define NDNBOOST_OLD_IOSTREAMS |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 27 | # endif |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 28 | #endif // #ifndef NDNBOOST_OLD_IOSTREAMS |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 29 | |
| 30 | #ifndef _STLP_NO_IOSTREAMS |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 31 | # ifndef NDNBOOST_OLD_IOSTREAMS |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 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 |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 47 | # ifndef NDNBOOST_OLD_IOSTREAMS |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 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(), |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 60 | std::ostream_iterator< NDNBOOST_DEDUCED_TYPENAME |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 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 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 87 | #undef NDNBOOST_OLD_IOSTREAMS |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 88 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 89 | #if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, NDNBOOST_TESTED_AT(1500)) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 90 | #pragma warning(pop) |
| 91 | #endif |
| 92 | |
| 93 | #endif // include guard |