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_ADD_VARARGS_HPP 10 #define BOOST_CLBL_TRTS_ADD_VARARGS_HPP 11 12 #include <boost/callable_traits/detail/core.hpp> 13 14 namespace boost { namespace callable_traits { 15 16 //[ add_varargs_hpp 17 /*` 18 [section:ref_add_varargs add_varargs] 19 [heading Header] 20 ``#include <boost/callable_traits/add_varargs.hpp>`` 21 [heading Definition] 22 */ 23 24 template<typename T> 25 using add_varargs_t = //see below 26 //<- 27 detail::try_but_fail_if_invalid< 28 typename detail::traits<T>::add_varargs, 29 varargs_are_illegal_for_this_type>; 30 31 namespace detail { 32 33 template<typename T, typename = std::false_type> 34 struct add_varargs_impl {}; 35 36 template<typename T> 37 struct add_varargs_impl <T, typename std::is_same< 38 add_varargs_t<T>, detail::dummy>::type> 39 { 40 using type = add_varargs_t<T>; 41 }; 42 } 43 //-> 44 45 template<typename T> 46 struct add_varargs : detail::add_varargs_impl<T> {}; 47 48 //<- 49 }} // namespace boost::callable_traits 50 //-> 51 52 /*` 53 [heading Constraints] 54 * `T` must be one of the following: 55 * function type 56 * function pointer type 57 * function reference type 58 * member function pointer type 59 * If `T` is a pointer, it may not be cv/ref qualified 60 61 [heading Behavior] 62 * A substitution failure occurs if the constraints are violated. 63 * Adds C-style variadics (`...`) to the signature of `T`, if not already present. 64 65 [heading Input/Output Examples] 66 [table 67 [[`T`] [`add_varargs_t<T>`]] 68 [[`int()`] [`int(...)`]] 69 [[`int(int)`] [`int(int, ...)`]] 70 [[`int (&)()`] [`int(&)(...)`]] 71 [[`int (*)()`] [`int(*)(...)`]] 72 [[`int (*)(...)`] [`int(*)(...)`]] 73 [[`int(foo::*)()`] [`int(foo::*)(...)`]] 74 [[`int(foo::*)() &`] [`int(foo::*)(...) &`]] 75 [[`int(foo::*)() &&`] [`int(foo::*)(...) &&`]] 76 [[`int(foo::*)() const`] [`int(foo::*)(...) const`]] 77 [[`int(foo::*)() transaction_safe`] [`int(foo::*)(...) transaction_safe`]] 78 [[`int`] [(substitution failure)]] 79 [[`int foo::*`] [(substitution failure)]] 80 [[`int (*&)()`] [(substitution failure)]] 81 ] 82 83 [heading Example Program] 84 [import ../example/add_varargs.cpp] 85 [add_varargs] 86 [endsect] 87 */ 88 //] 89 90 #endif 91