has_varargs.hpp 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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_HAS_VARARGS_HPP
  7. #define BOOST_CLBL_TRTS_HAS_VARARGS_HPP
  8. #include <boost/callable_traits/detail/core.hpp>
  9. namespace boost { namespace callable_traits {
  10. //[ has_varargs_hpp
  11. /*`[section:ref_has_varargs has_varargs]
  12. [heading Header]
  13. ``#include <boost/callable_traits/has_varargs.hpp>``
  14. [heading Definition]
  15. */
  16. // inherits from either std::true_type or std::false_type
  17. template<typename T>
  18. struct has_varargs;
  19. //<-
  20. template<typename T>
  21. struct has_varargs : detail::traits<
  22. detail::shallow_decay<T>>::has_varargs {
  23. using type = typename detail::traits<
  24. detail::shallow_decay<T>>::has_varargs;
  25. };
  26. #ifdef BOOST_CLBL_TRTS_DISABLE_VARIABLE_TEMPLATES
  27. template<typename T>
  28. struct has_varargs_v {
  29. static_assert(std::is_same<T, detail::dummy>::value,
  30. "Variable templates not supported on this compiler.");
  31. };
  32. #else
  33. //->
  34. // only available when variable templates are supported
  35. template<typename T>
  36. //<-
  37. BOOST_CLBL_TRAITS_INLINE_VAR
  38. //->
  39. constexpr bool has_varargs_v = //see below
  40. //<-
  41. detail::traits<detail::shallow_decay<T>>::has_varargs::value;
  42. #endif
  43. }} // namespace boost::callable_traits
  44. //->
  45. /*`
  46. [heading Constraints]
  47. * none
  48. [heading Behavior]
  49. * `std::false_type` is inherited by `has_varargs<T>` and is aliased by `typename has_varargs<T>::type`, except when one of the following criteria is met, in which case `std::true_type` would be similarly inherited and aliased:
  50. * `T` is a function, function pointer, or function reference where the function's parameter list includes C-style variadics.
  51. * `T` is a pointer to a member function with C-style variadics in the parameter list.
  52. * `T` is a function object with a non-overloaded `operator()`, which has C-style variadics in the parameter list of its `operator()`.
  53. * On compilers that support variable templates, `has_varargs_v<T>` is equivalent to `has_varargs<T>::value`.
  54. [heading Input/Output Examples]
  55. [table
  56. [[`T`] [`has_varargs_v<T>`]]
  57. [[`void(...)`] [`true`]]
  58. [[`void(int, ...) const`] [`true`]]
  59. [[`void(* volatile)(...)`] [`true`]]
  60. [[`void(&)(...)`] [`true`]]
  61. [[`void(foo::*)(...) const`] [`true`]]
  62. [[`void(*)()`] [`false`]]
  63. [[`void(*&)()`] [`false`]]
  64. [[`int`] [`false`]]
  65. [[`const int`] [`false`]]
  66. [[`int foo::*`] [`false`]]
  67. ]
  68. [heading Example Program]
  69. [import ../example/has_varargs.cpp]
  70. [has_varargs]
  71. [endsect]
  72. */
  73. //]
  74. #endif