parameter_type_of.hpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  5. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  6. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  7. // Use, modification and distribution is subject to the Boost Software License,
  8. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. #ifndef BOOST_GEOMETRY_UTIL_PARAMETER_TYPE_OF_HPP
  11. #define BOOST_GEOMETRY_UTIL_PARAMETER_TYPE_OF_HPP
  12. #include <boost/function_types/function_arity.hpp>
  13. #include <boost/function_types/is_member_function_pointer.hpp>
  14. #include <boost/function_types/parameter_types.hpp>
  15. #include <boost/mpl/at.hpp>
  16. #include <boost/mpl/int.hpp>
  17. #include <boost/mpl/plus.hpp>
  18. #include <boost/type_traits/remove_reference.hpp>
  19. namespace boost { namespace geometry
  20. {
  21. /*!
  22. \brief Meta-function selecting a parameter type of a (member) function, by index
  23. \ingroup utility
  24. */
  25. template <typename Method, std::size_t Index>
  26. struct parameter_type_of
  27. {
  28. typedef typename boost::function_types::parameter_types
  29. <
  30. Method
  31. >::type parameter_types;
  32. typedef typename boost::mpl::if_
  33. <
  34. boost::function_types::is_member_function_pointer<Method>,
  35. boost::mpl::int_<1>,
  36. boost::mpl::int_<0>
  37. >::type base_index_type;
  38. typedef typename boost::mpl::if_c
  39. <
  40. Index == 0,
  41. base_index_type,
  42. typename boost::mpl::plus
  43. <
  44. base_index_type,
  45. boost::mpl::int_<Index>
  46. >::type
  47. >::type indexed_type;
  48. typedef typename boost::remove_reference
  49. <
  50. typename boost::mpl::at
  51. <
  52. parameter_types,
  53. indexed_type
  54. >::type
  55. >::type type;
  56. };
  57. }} // namespace boost::geometry
  58. #endif // BOOST_GEOMETRY_UTIL_PARAMETER_TYPE_OF_HPP