has_varargs.hpp
Go to the documentation of this file.
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 
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>
31  detail::shallow_decay<T>>::has_varargs {
32 
33  using type = typename detail::traits<
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 //<-
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
#define BOOST_CLBL_TRAITS_INLINE_VAR
Definition: config.hpp:27
typename std::remove_cv< typename std::remove_reference< T >::type >::type shallow_decay
Definition: utility.hpp:79
typename BOOST_CLBL_TRTS_DISJUNCTION(function_object< unwrap_reference< T > >, function< T >, pmf< T >, pmd< T >, default_callable_traits< T >)::traits traits
Definition: traits.hpp:25
constexpr BOOST_CLBL_TRAITS_INLINE_VAR bool has_varargs_v
Definition: has_varargs.hpp:52
typename detail::traits< detail::shallow_decay< T > >::has_varargs type
Definition: has_varargs.hpp:34