args_type.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright 2015-2018 Hans Dembinski
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt
  5. // or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_HISTOGRAM_DETAIL_ARGS_TYPE_HPP
  7. #define BOOST_HISTOGRAM_DETAIL_ARGS_TYPE_HPP
  8. #include <tuple>
  9. namespace boost {
  10. namespace histogram {
  11. namespace detail {
  12. template <class T>
  13. struct args_type_impl {
  14. using T::ERROR_this_should_never_be_instantiated_please_write_an_issue;
  15. };
  16. template <class R, class T, class... Ts>
  17. struct args_type_impl<R (T::*)(Ts...)> {
  18. using type = std::tuple<Ts...>;
  19. };
  20. template <class R, class T, class... Ts>
  21. struct args_type_impl<R (T ::*)(Ts...) const> {
  22. using type = std::tuple<Ts...>;
  23. };
  24. template <class R, class... Ts>
  25. struct args_type_impl<R (*)(Ts...)> {
  26. using type = std::tuple<Ts...>;
  27. };
  28. #if __cpp_noexcept_function_type >= 201510
  29. template <class R, class T, class... Ts>
  30. struct args_type_impl<R (T::*)(Ts...) noexcept> {
  31. using type = std::tuple<Ts...>;
  32. };
  33. template <class R, class T, class... Ts>
  34. struct args_type_impl<R (T ::*)(Ts...) const noexcept> {
  35. using type = std::tuple<Ts...>;
  36. };
  37. template <class R, class... Ts>
  38. struct args_type_impl<R (*)(Ts...) noexcept> {
  39. using type = std::tuple<Ts...>;
  40. };
  41. #endif
  42. template <class FunctionPointer>
  43. using args_type = typename args_type_impl<FunctionPointer>::type;
  44. template <class T, std::size_t N = 0>
  45. using arg_type = std::tuple_element_t<N, args_type<T>>;
  46. } // namespace detail
  47. } // namespace histogram
  48. } // namespace boost
  49. #endif