1 /* 2 3 @Copyright Barrett Adair 2015-2017 4 Distributed under the Boost Software License, Version 1.0. 5 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) 6 7 */ 8 9 #ifndef BOOST_CLBL_TRTS_HAS_VARARGS_HPP 10 #define BOOST_CLBL_TRTS_HAS_VARARGS_HPP 11 12 #include <boost/callable_traits/detail/core.hpp> 13 14 namespace boost { namespace callable_traits { 15 16 //[ has_varargs_hpp 17 /*`[section:ref_has_varargs has_varargs] 18 [heading Header] 19 ``#include <boost/callable_traits/has_varargs.hpp>`` 20 [heading Definition] 21 */ 22 23 24 // inherits from either std::true_type or std::false_type 25 template<typename T> 26 struct has_varargs; 27 28 //<- 29 template<typename T> 30 struct has_varargs : detail::traits< 31 detail::shallow_decay<T>>::has_varargs { 32 33 using type = typename detail::traits< 34 detail::shallow_decay<T>>::has_varargs; 35 }; 36 37 #ifdef BOOST_CLBL_TRTS_DISABLE_VARIABLE_TEMPLATES 38 39 template<typename T> 40 struct has_varargs_v { 41 static_assert(std::is_same<T, detail::dummy>::value, 42 "Variable templates not supported on this compiler."); 43 }; 44 45 #else 46 //-> 47 // only available when variable templates are supported 48 template<typename T> 49 //<- 50 BOOST_CLBL_TRAITS_INLINE_VAR 51 //-> 52 constexpr bool has_varargs_v = //see below 53 //<- 54 detail::traits<detail::shallow_decay<T>>::has_varargs::value; 55 56 #endif 57 58 }} // namespace boost::callable_traits 59 //-> 60 61 /*` 62 [heading Constraints] 63 * none 64 65 [heading Behavior] 66 * `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: 67 * `T` is a function, function pointer, or function reference where the function's parameter list includes C-style variadics. 68 * `T` is a pointer to a member function with C-style variadics in the parameter list. 69 * `T` is a function object with a non-overloaded `operator()`, which has C-style variadics in the parameter list of its `operator()`. 70 * On compilers that support variable templates, `has_varargs_v<T>` is equivalent to `has_varargs<T>::value`. 71 72 [heading Input/Output Examples] 73 [table 74 [[`T`] [`has_varargs_v<T>`]] 75 [[`void(...)`] [`true`]] 76 [[`void(int, ...) const`] [`true`]] 77 [[`void(* volatile)(...)`] [`true`]] 78 [[`void(&)(...)`] [`true`]] 79 [[`void(foo::*)(...) const`] [`true`]] 80 [[`void(*)()`] [`false`]] 81 [[`void(*&)()`] [`false`]] 82 [[`int`] [`false`]] 83 [[`const int`] [`false`]] 84 [[`int foo::*`] [`false`]] 85 ] 86 87 [heading Example Program] 88 [import ../example/has_varargs.cpp] 89 [has_varargs] 90 [endsect] 91 */ 92 //] 93 94 #endif 95