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 
9 #ifndef BOOST_PROTO_FUNCTIONAL_RANGE_SIZE_HPP_EAN_27_08_2012
10 #define BOOST_PROTO_FUNCTIONAL_RANGE_SIZE_HPP_EAN_27_08_2012
11 
12 #include <boost/range/size.hpp>
13 #include <boost/proto/proto_fwd.hpp>
14 
15 namespace boost { namespace proto { namespace functional
16 {
17 
18     // A PolymorphicFunctionObject that wraps boost::size()
19     struct size
20     {
21         BOOST_PROTO_CALLABLE()
22 
23         template<typename Sig>
24         struct result;
25 
26         template<typename This, typename Rng>
27         struct result<This(Rng)>
28           : boost::range_size<Rng>
29         {};
30 
31         template<typename This, typename Rng>
32         struct result<This(Rng &)>
33           : boost::range_size<Rng>
34         {};
35 
36         template<typename Rng>
operator ()boost::proto::functional::size37         typename boost::range_size<Rng>::type operator()(Rng const &rng) const
38         {
39             return boost::size(rng);
40         }
41     };
42 
43 }}}
44 
45 #endif
46