size.hpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ///////////////////////////////////////////////////////////////////////////////
  2. /// \file size.hpp
  3. /// Proto callables for boost::size()
  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_SIZE_HPP_EAN_27_08_2012
  9. #define BOOST_PROTO_FUNCTIONAL_RANGE_SIZE_HPP_EAN_27_08_2012
  10. #include <boost/range/size.hpp>
  11. #include <boost/proto/proto_fwd.hpp>
  12. namespace boost { namespace proto { namespace functional
  13. {
  14. // A PolymorphicFunctionObject that wraps boost::size()
  15. struct size
  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_size<Rng>
  23. {};
  24. template<typename This, typename Rng>
  25. struct result<This(Rng &)>
  26. : boost::range_size<Rng>
  27. {};
  28. template<typename Rng>
  29. typename boost::range_size<Rng>::type operator()(Rng const &rng) const
  30. {
  31. return boost::size(rng);
  32. }
  33. };
  34. }}}
  35. #endif