]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/type_traits/doc/function_traits.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / type_traits / doc / function_traits.qbk
1 [/
2 Copyright 2007 John Maddock.
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at
5 http://www.boost.org/LICENSE_1_0.txt).
6 ]
7
8 [section:function_traits function_traits]
9 [def __argN '''arg<replaceable>N</replaceable>_type''']
10
11 template <class F>
12 struct function_traits
13 {
14 static const std::size_t arity = __below;
15 typedef __below result_type;
16 typedef __below __argN;
17 };
18
19 The class template function_traits will only compile if:
20
21 * The compiler supports partial specialization of class templates.
22 * The template argument `F` is a /function type/, note that this ['[*is not]]
23 the same thing as a /pointer to a function/.
24
25 [tip
26 function_traits is intended to introspect only C++ functions of the
27 form R (), R( A1 ), R ( A1, ... etc. ) and not function pointers or
28 class member functions. To convert a function pointer type to a suitable
29 type use __remove_pointer.]
30
31 [table Function Traits Members
32 [[Member] [Description]]
33 [[`function_traits<F>::arity`]
34 [An integral constant expression that gives the number of arguments accepted by the function type `F`.]]
35 [[`function_traits<F>::result_type`]
36 [The type returned by function type `F`.]]
37 [[`function_traits<F>::__argN`]
38 [The '''<replaceable>N</replaceable>th''' argument type of function type `F`, where `1 <= N <= arity` of `F`.]]
39 ]
40
41 [table Examples
42 [[Expression] [Result]]
43 [[`function_traits<void (void)>::arity`] [An integral constant expression that has the value 0.]]
44 [[`function_traits<long (int)>::arity`] [An integral constant expression that has the value 1.]]
45 [[`function_traits<long (int, long, double, void*)>::arity`] [An integral constant expression that has the value 4.]]
46 [[`function_traits<void (void)>::result_type`] [The type `void`.]]
47 [[`function_traits<long (int)>::result_type`] [The type `long`.]]
48 [[`function_traits<long (int)>::arg1_type`] [The type `int`.]]
49 [[`function_traits<long (int, long, double, void*)>::arg4_type`] [The type `void*`.]]
50 [[`function_traits<long (int, long, double, void*)>::arg5_type`] [A compiler error: there is no `arg5_type` since there are only four arguments.]]
51 [[`function_traits<long (*)(void)>::arity`] [A compiler error: argument type is a /function pointer/, and not a /function type/.]]
52
53 ]
54
55 [all_compilers]
56
57 [endsect]
58