/usr/include/boost/proto/functional/std
Edit: /usr/include/boost/proto/functional/std/iterator.hpp (4701B)
///////////////////////////////////////////////////////////////////////////////
/// \file iterator.hpp
/// Proto callables for std functions found in \
//
// Copyright 2012 Eric Niebler. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_PROTO_FUNCTIONAL_STD_ITERATOR_HPP_EAN_27_08_2012
#define BOOST_PROTO_FUNCTIONAL_STD_ITERATOR_HPP_EAN_27_08_2012
#include
#include
#include
#include
namespace boost { namespace proto { namespace functional
{
// A PolymorphicFunctionObject wrapping std::advance
struct advance
{
BOOST_PROTO_CALLABLE()
typedef void result_type;
template
void operator()(InputIterator &x, Distance n) const
{
std::advance(x, n);
}
};
// A PolymorphicFunctionObject wrapping std::distance
struct distance
{
BOOST_PROTO_CALLABLE()
template
struct result;
template
struct result
{
typedef
typename std::iterator_traits<
typename boost::remove_const<
typename boost::remove_reference::type
>::type
>::difference_type
type;
};
template
typename std::iterator_traits::difference_type
operator()(InputIterator first, InputIterator last) const
{
return std::distance(first, last);
}
};
// A PolymorphicFunctionObject wrapping std::next
struct next
{
BOOST_PROTO_CALLABLE()
template
struct result;
template
struct result
{
typedef
typename boost::remove_const<
typename boost::remove_reference::type
>::type
type;
};
template
struct result
{
typedef
typename boost::remove_const<
typename boost::remove_reference::type
>::type
type;
};
template
ForwardIterator operator()(ForwardIterator x) const
{
return std::advance(
x
, static_cast::difference_type>(1)
);
}
template
ForwardIterator operator()(
ForwardIterator x
, typename std::iterator_traits::difference_type n
) const
{
return std::advance(x, n);
}
};
// A PolymorphicFunctionObject wrapping std::prior
struct prior
{
BOOST_PROTO_CALLABLE()
template
struct result;
template
struct result
{
typedef
typename boost::remove_const<
typename boost::remove_reference::type
>::type
type;
};
template
struct result
{
typedef
typename boost::remove_const<
typename boost::remove_reference::type
>::type
type;
};
template
BidirectionalIterator operator()(BidirectionalIterator x) const
{
return std::advance(
x
, -static_cast::difference_type>(1)
);
}
template
BidirectionalIterator operator()(
BidirectionalIterator x
, typename std::iterator_traits::difference_type n
) const
{
return std::advance(x, -n);
}
};
}}}
#endif