function_param_limit.hpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*=============================================================================
  2. Copyright (c) 2016 Paul Fultz II
  3. function_param_limit.hpp
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. ==============================================================================*/
  7. #ifndef BOOST_HOF_GUARD_FUNCTION_PARAM_LIMIT_HPP
  8. #define BOOST_HOF_GUARD_FUNCTION_PARAM_LIMIT_HPP
  9. /// function_param_limit
  10. /// ====================
  11. ///
  12. /// Description
  13. /// -----------
  14. ///
  15. /// The `function_param_limit` metafunction retrieves the maximum number of
  16. /// parameters for a function. For function pointers it returns the number of
  17. /// parameters. Everything else, it returns `SIZE_MAX`, but this can be
  18. /// changed by annotating the function with the [`limit`](limit) decorator.
  19. ///
  20. /// This is a type trait that inherits from `std::integral_constant`.
  21. ///
  22. /// Synopsis
  23. /// --------
  24. ///
  25. /// template<class F>
  26. /// struct function_param_limit
  27. /// : std::integral_constant<std::size_t, ...>
  28. /// {};
  29. ///
  30. /// See Also
  31. /// --------
  32. ///
  33. /// * [Partial function evaluation](<Partial function evaluation>)
  34. /// * [limit](limit)
  35. ///
  36. #include <boost/hof/detail/holder.hpp>
  37. #include <type_traits>
  38. #include <cstdint>
  39. namespace boost { namespace hof {
  40. template<class F, class=void>
  41. struct function_param_limit
  42. : std::integral_constant<std::size_t, SIZE_MAX>
  43. {};
  44. template<class F>
  45. struct function_param_limit<F, typename detail::holder<typename F::fit_function_param_limit>::type>
  46. : F::fit_function_param_limit
  47. {};
  48. }} // namespace boost::hof
  49. #endif