Chris@16: // Boost string_algo library util.hpp header file ---------------------------// Chris@16: Chris@16: // Copyright Pavol Droba 2002-2003. Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. Chris@16: // (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: // See http://www.boost.org/ for updates, documentation, and revision history. Chris@16: Chris@16: #ifndef BOOST_STRING_UTIL_DETAIL_HPP Chris@16: #define BOOST_STRING_UTIL_DETAIL_HPP Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace algorithm { Chris@16: namespace detail { Chris@16: Chris@16: // empty container -----------------------------------------------// Chris@16: Chris@16: // empty_container Chris@16: /* Chris@16: This class represents always empty container, Chris@16: containing elements of type CharT. Chris@16: Chris@16: It is supposed to be used in a const version only Chris@16: */ Chris@16: template< typename CharT > Chris@16: struct empty_container Chris@16: { Chris@16: typedef empty_container type; Chris@16: typedef CharT value_type; Chris@16: typedef std::size_t size_type; Chris@16: typedef std::ptrdiff_t difference_type; Chris@16: typedef const value_type& reference; Chris@16: typedef const value_type& const_reference; Chris@16: typedef const value_type* iterator; Chris@16: typedef const value_type* const_iterator; Chris@16: Chris@16: Chris@16: // Operations Chris@16: const_iterator begin() const Chris@16: { Chris@16: return reinterpret_cast(0); Chris@16: } Chris@16: Chris@16: const_iterator end() const Chris@16: { Chris@16: return reinterpret_cast(0); Chris@16: } Chris@16: Chris@16: bool empty() const Chris@16: { Chris@16: return false; Chris@16: } Chris@16: Chris@16: size_type size() const Chris@16: { Chris@16: return 0; Chris@16: } Chris@16: }; Chris@16: Chris@16: // bounded copy algorithm -----------------------------------------------// Chris@16: Chris@16: // Bounded version of the std::copy algorithm Chris@16: template Chris@16: inline OutputIteratorT bounded_copy( Chris@16: InputIteratorT First, Chris@16: InputIteratorT Last, Chris@16: OutputIteratorT DestFirst, Chris@16: OutputIteratorT DestLast ) Chris@16: { Chris@16: InputIteratorT InputIt=First; Chris@16: OutputIteratorT OutputIt=DestFirst; Chris@16: for(; InputIt!=Last && OutputIt!=DestLast; InputIt++, OutputIt++ ) Chris@16: { Chris@16: *OutputIt=*InputIt; Chris@16: } Chris@16: Chris@16: return OutputIt; Chris@16: } Chris@16: Chris@16: // iterator range utilities -----------------------------------------// Chris@16: Chris@16: // copy range functor Chris@16: template< Chris@16: typename SeqT, Chris@16: typename IteratorT=BOOST_STRING_TYPENAME SeqT::const_iterator > Chris@16: struct copy_iterator_rangeF : Chris@16: public std::unary_function< iterator_range, SeqT > Chris@16: { Chris@16: SeqT operator()( const iterator_range& Range ) const Chris@16: { Chris@16: return copy_range(Range); Chris@16: } Chris@16: }; Chris@16: Chris@16: } // namespace detail Chris@16: } // namespace algorithm Chris@16: } // namespace boost Chris@16: Chris@16: Chris@16: #endif // BOOST_STRING_UTIL_DETAIL_HPP