]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/type_traits/doc/is_function.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / type_traits / doc / is_function.qbk
CommitLineData
7c673cae
FG
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:is_function is_function]
9
10 template <class T>
11 struct is_function : public __tof {};
12
13__inherit If T is a (possibly cv-qualified) function type then inherits from __true_type,
14otherwise inherits from __false_type. Note that this template does not detect /pointers
15to functions/, or /references to functions/, these are detected by __is_pointer and
16__is_reference respectively:
17
18 typedef int f1(); // f1 is of function type.
19 typedef int (*f2)(); // f2 is a pointer to a function.
20 typedef int (&f3)(); // f3 is a reference to a function.
21
22__std_ref 3.9.2p1 and 8.3.5.
23
24[all_compilers]
25
26__header ` #include <boost/type_traits/is_function.hpp>` or ` #include <boost/type_traits.hpp>`
27
28__examples
29
30[:`is_function<int (void)>` inherits from `__true_type`.]
31
32[:`is_function<long (double, int)>::type` is the type `__true_type`.]
33
34[:`is_function<long (double, int)>::value` is an integral constant
35expression that evaluates to /true/.]
36
37[:`is_function<long (*)(double, int)>::value` is an integral constant
38expression that evaluates to /false/: the argument in this case is a pointer type,
39not a function type.]
40
41[:`is_function<long (&)(double, int)>::value` is an integral constant
42expression that evaluates to /false/: the argument in this case is a
43reference to a function, not a function type.]
44
45[:`is_function<long (MyClass::*)(double, int)>::value` is an integral constant
46expression that evaluates to /false/: the argument in this case is a pointer
47to a member function.]
48
49[:`is_function<T>::value_type` is the type `bool`.]
50
51[tip Don't confuse function-types with pointers to functions:
52
53`typedef int f(double);`
54
55defines a function type,
56
57`f foo;`
58
59declares a prototype for a function of type `f`,
60
61`f* pf = foo;`
62
63`f& fr = foo;`
64
65declares a pointer and a reference to the function `foo`.
66
67If you want to detect whether some type is a pointer-to-function then use:
68
69`__is_function<__remove_pointer<T>::type>::value && __is_pointer<T>::value`
70
71or for pointers to member functions you can just use
72__is_member_function_pointer directly.
73]
74
75[endsect]
76
77