• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*<-
2 Copyright Barrett Adair 2016-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 
7 //[ add_varargs
8 #include <type_traits>
9 #include <boost/callable_traits/add_varargs.hpp>
10 
11 namespace ct = boost::callable_traits;
12 
13 struct foo {};
14 
main()15 int main() {
16 
17     {
18         using f = void(int);
19         using expect = void(int, ...);
20         using test = ct::add_varargs_t<f>;
21         static_assert(std::is_same<test, expect>::value, "");
22     } {
23         using fp = void(*)();
24         using expect = void(*)(...);
25         using test = ct::add_varargs_t<fp>;
26         static_assert(std::is_same<test, expect>::value, "");
27     } {
28         using fr = void(&)(const char*);
29         using expect = void(&)(const char*, ...);
30         using test = ct::add_varargs_t<fr>;
31         static_assert(std::is_same<test, expect>::value, "");
32     } {
33         using pmf = void(foo::*)() const;
34         using expect = void(foo::*)(...) const;
35         using test = ct::add_varargs_t<pmf>;
36         static_assert(std::is_same<test, expect>::value, "");
37 
38         // add_varargs_t doesn't change anything when
39         // the type already has varargs.
40         using twice = ct::add_varargs_t<test>;
41         static_assert(std::is_same<test, twice>::value, "");
42     }
43 }
44 //]
45