begin.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. ///////////////////////////////////////////////////////////////////////////////
  2. /// \file begin.hpp
  3. /// Proto callables for boost::begin()
  4. //
  5. // Copyright 2012 Eric Niebler. Distributed under the Boost
  6. // Software License, Version 1.0. (See accompanying file
  7. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  8. #ifndef BOOST_PROTO_FUNCTIONAL_RANGE_BEGIN_HPP_EAN_27_08_2012
  9. #define BOOST_PROTO_FUNCTIONAL_RANGE_BEGIN_HPP_EAN_27_08_2012
  10. #include <boost/range/begin.hpp>
  11. #include <boost/proto/proto_fwd.hpp>
  12. namespace boost { namespace proto { namespace functional
  13. {
  14. // A PolymorphicFunctionObject that wraps boost::begin()
  15. struct begin
  16. {
  17. BOOST_PROTO_CALLABLE()
  18. template<typename Sig>
  19. struct result;
  20. template<typename This, typename Rng>
  21. struct result<This(Rng)>
  22. : boost::range_iterator<Rng const>
  23. {};
  24. template<typename This, typename Rng>
  25. struct result<This(Rng &)>
  26. : boost::range_iterator<Rng>
  27. {};
  28. template<typename Rng>
  29. typename boost::range_iterator<Rng>::type operator()(Rng &rng) const
  30. {
  31. return boost::begin(rng);
  32. }
  33. template<typename Rng>
  34. typename boost::range_iterator<Rng const>::type operator()(Rng const &rng) const
  35. {
  36. return boost::begin(rng);
  37. }
  38. };
  39. }}}
  40. #endif