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).
8 [section:is_function is_function]
11 struct is_function : public __tof {};
13 __inherit If T is a (possibly cv-qualified) function type then inherits from __true_type,
14 otherwise inherits from __false_type. Note that this template does not detect /pointers
15 to functions/, or /references to functions/, these are detected by __is_pointer and
16 __is_reference respectively:
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.
22 __std_ref 3.9.2p1 and 8.3.5.
26 __header ` #include <boost/type_traits/is_function.hpp>` or ` #include <boost/type_traits.hpp>`
30 [:`is_function<int (void)>` inherits from `__true_type`.]
32 [:`is_function<long (double, int)>::type` is the type `__true_type`.]
34 [:`is_function<long (double, int)>::value` is an integral constant
35 expression that evaluates to /true/.]
37 [:`is_function<long (*)(double, int)>::value` is an integral constant
38 expression that evaluates to /false/: the argument in this case is a pointer type,
41 [:`is_function<long (&)(double, int)>::value` is an integral constant
42 expression that evaluates to /false/: the argument in this case is a
43 reference to a function, not a function type.]
45 [:`is_function<long (MyClass::*)(double, int)>::value` is an integral constant
46 expression that evaluates to /false/: the argument in this case is a pointer
47 to a member function.]
49 [:`is_function<T>::value_type` is the type `bool`.]
51 [tip Don't confuse function-types with pointers to functions:
53 `typedef int f(double);`
55 defines a function type,
59 declares a prototype for a function of type `f`,
65 declares a pointer and a reference to the function `foo`.
67 If you want to detect whether some type is a pointer-to-function then use:
69 `__is_function<__remove_pointer<T>::type>::value && __is_pointer<T>::value`
71 or for pointers to member functions you can just use
72 __is_member_function_pointer directly.