1 // Boost string_algo library util.hpp header file ---------------------------//
3 // Copyright Pavol Droba 2002-2003.
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // See http://www.boost.org/ for updates, documentation, and revision history.
11 #ifndef BOOST_STRING_UTIL_DETAIL_HPP
12 #define BOOST_STRING_UTIL_DETAIL_HPP
14 #include <boost/algorithm/string/config.hpp>
16 #include <boost/range/iterator_range_core.hpp>
22 // empty container -----------------------------------------------//
26 This class represents always empty container,
27 containing elements of type CharT.
29 It is supposed to be used in a const version only
31 template< typename CharT >
32 struct empty_container
34 typedef empty_container<CharT> type;
35 typedef CharT value_type;
36 typedef std::size_t size_type;
37 typedef std::ptrdiff_t difference_type;
38 typedef const value_type& reference;
39 typedef const value_type& const_reference;
40 typedef const value_type* iterator;
41 typedef const value_type* const_iterator;
45 const_iterator begin() const
47 return reinterpret_cast<const_iterator>(0);
50 const_iterator end() const
52 return reinterpret_cast<const_iterator>(0);
60 size_type size() const
66 // bounded copy algorithm -----------------------------------------------//
68 // Bounded version of the std::copy algorithm
69 template<typename InputIteratorT, typename OutputIteratorT>
70 inline OutputIteratorT bounded_copy(
73 OutputIteratorT DestFirst,
74 OutputIteratorT DestLast )
76 InputIteratorT InputIt=First;
77 OutputIteratorT OutputIt=DestFirst;
78 for(; InputIt!=Last && OutputIt!=DestLast; InputIt++, OutputIt++ )
86 // iterator range utilities -----------------------------------------//
91 typename IteratorT=BOOST_STRING_TYPENAME SeqT::const_iterator >
92 struct copy_iterator_rangeF :
93 public std::unary_function< iterator_range<IteratorT>, SeqT >
95 SeqT operator()( const iterator_range<IteratorT>& Range ) const
97 return copy_range<SeqT>(Range);
101 } // namespace detail
102 } // namespace algorithm
106 #endif // BOOST_STRING_UTIL_DETAIL_HPP