1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
11 #ifndef BOOST_COMPUTE_DETAIL_ITERATOR_PLUS_DISTANCE_HPP
12 #define BOOST_COMPUTE_DETAIL_ITERATOR_PLUS_DISTANCE_HPP
20 template<class Iterator, class Distance, class Tag>
21 inline Iterator iterator_plus_distance(Iterator i, Distance n, Tag)
28 template<class Iterator, class Distance>
29 inline Iterator iterator_plus_distance(Iterator i,
31 std::random_access_iterator_tag)
34 std::iterator_traits<Iterator>::difference_type difference_type;
36 return i + static_cast<difference_type>(n);
39 // similar to std::advance() except returns the advanced iterator and
40 // also works with iterators that don't define difference_type
41 template<class Iterator, class Distance>
42 inline Iterator iterator_plus_distance(Iterator i, Distance n)
44 typedef typename std::iterator_traits<Iterator>::iterator_category tag;
46 return iterator_plus_distance(i, n, tag());
49 } // end detail namespace
50 } // end compute namespace
51 } // end boost namespace
53 #endif // BOOST_COMPUTE_DETAIL_ITERATOR_PLUS_DISTANCE_HPP