add_varargs.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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_ADD_VARARGS_HPP
  7. #define BOOST_CLBL_TRTS_ADD_VARARGS_HPP
  8. #include <boost/callable_traits/detail/core.hpp>
  9. namespace boost { namespace callable_traits {
  10. //[ add_varargs_hpp
  11. /*`
  12. [section:ref_add_varargs add_varargs]
  13. [heading Header]
  14. ``#include <boost/callable_traits/add_varargs.hpp>``
  15. [heading Definition]
  16. */
  17. template<typename T>
  18. using add_varargs_t = //see below
  19. //<-
  20. detail::try_but_fail_if_invalid<
  21. typename detail::traits<T>::add_varargs,
  22. varargs_are_illegal_for_this_type>;
  23. namespace detail {
  24. template<typename T, typename = std::false_type>
  25. struct add_varargs_impl {};
  26. template<typename T>
  27. struct add_varargs_impl <T, typename std::is_same<
  28. add_varargs_t<T>, detail::dummy>::type>
  29. {
  30. using type = add_varargs_t<T>;
  31. };
  32. }
  33. //->
  34. template<typename T>
  35. struct add_varargs : detail::add_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. * Adds C-style variadics (`...`) to the signature of `T`, if not already present.
  50. [heading Input/Output Examples]
  51. [table
  52. [[`T`] [`add_varargs_t<T>`]]
  53. [[`int()`] [`int(...)`]]
  54. [[`int(int)`] [`int(int, ...)`]]
  55. [[`int (&)()`] [`int(&)(...)`]]
  56. [[`int (*)()`] [`int(*)(...)`]]
  57. [[`int (*)(...)`] [`int(*)(...)`]]
  58. [[`int(foo::*)()`] [`int(foo::*)(...)`]]
  59. [[`int(foo::*)() &`] [`int(foo::*)(...) &`]]
  60. [[`int(foo::*)() &&`] [`int(foo::*)(...) &&`]]
  61. [[`int(foo::*)() const`] [`int(foo::*)(...) const`]]
  62. [[`int(foo::*)() transaction_safe`] [`int(foo::*)(...) transaction_safe`]]
  63. [[`int`] [(substitution failure)]]
  64. [[`int foo::*`] [(substitution failure)]]
  65. [[`int (*&)()`] [(substitution failure)]]
  66. ]
  67. [heading Example Program]
  68. [import ../example/add_varargs.cpp]
  69. [add_varargs]
  70. [endsect]
  71. */
  72. //]
  73. #endif