remove_varargs.hpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. @Copyright Barrett Adair 2015-2017
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  5. */
  6. #ifndef BOOST_CLBL_TRTS_REMOVE_VARARGS_HPP
  7. #define BOOST_CLBL_TRTS_REMOVE_VARARGS_HPP
  8. #include <boost/callable_traits/detail/core.hpp>
  9. namespace boost { namespace callable_traits {
  10. //[ remove_varargs_hpp
  11. /*`
  12. [section:ref_remove_varargs remove_varargs]
  13. [heading Header]
  14. ``#include <boost/callable_traits/remove_varargs.hpp>``
  15. [heading Definition]
  16. */
  17. template<typename T>
  18. using remove_varargs_t = //see below
  19. //<-
  20. detail::try_but_fail_if_invalid<
  21. typename detail::traits<T>::remove_varargs,
  22. varargs_are_illegal_for_this_type>;
  23. namespace detail {
  24. template<typename T, typename = std::false_type>
  25. struct remove_varargs_impl {};
  26. template<typename T>
  27. struct remove_varargs_impl <T, typename std::is_same<
  28. remove_varargs_t<T>, detail::dummy>::type>
  29. {
  30. using type = remove_varargs_t<T>;
  31. };
  32. }
  33. //->
  34. template<typename T>
  35. struct remove_varargs : detail::remove_varargs_impl<T> {};
  36. //<-
  37. }} // namespace boost::callable_traits
  38. //->
  39. /*`
  40. [heading Constraints]
  41. * `T` must be one of the following:
  42. * function type
  43. * function pointer type
  44. * function reference type
  45. * member function pointer type
  46. * If `T` is a pointer, it may not be cv/ref qualified
  47. [heading Behavior]
  48. * A substitution failure occurs if the constraints are violated.
  49. * Removes C-style variadics (`...`) from the signature of `T`, if present.
  50. [heading Input/Output Examples]
  51. [table
  52. [[`T`] [`remove_varargs_t<T>`]]
  53. [[`int(...)`] [`int()`]]
  54. [[`int(int, ...)`] [`int(int)`]]
  55. [[`int (&)(...)`] [`int(&)()`]]
  56. [[`int (*)()`] [`int(*)()`]]
  57. [[`int(foo::*)(...)`] [`int(foo::*)()`]]
  58. [[`int(foo::*)(...) &`] [`int(foo::*)() &`]]
  59. [[`int(foo::*)(...) &&`] [`int(foo::*)() &&`]]
  60. [[`int(foo::*)(...) const`] [`int(foo::*)() const`]]
  61. [[`int(foo::*)(...) transaction_safe`] [`int(foo::*)() transaction_safe`]]
  62. [[`int`] [(substitution failure)]]
  63. [[`int foo::*`] [(substitution failure)]]
  64. [[`int (* const)()`] [(substitution failure)]]
  65. ]
  66. [heading Example Program]
  67. [import ../example/remove_varargs.cpp]
  68. [remove_varargs]
  69. [endsect]
  70. */
  71. //]
  72. #endif // #ifndef BOOST_CLBL_TRTS_REMOVE_VARARGS_HPP