]> git.lyx.org Git - lyx.git/blob - boost/boost/type_traits/is_function.hpp
update boost to version 1.29.0
[lyx.git] / boost / boost / type_traits / is_function.hpp
1
2 // Copyright (C) 2000 John Maddock (john_maddock@compuserve.com)
3 // Copyright (C) 2002 Aleksey Gurtovoy (agurtovoy@meta-comm.com)
4 //
5 // Permission to copy and use this software is granted, 
6 // provided this copyright notice appears in all copies. 
7 // Permission to modify the code and to distribute modified code is granted, 
8 // provided this copyright notice appears in all copies, and a notice 
9 // that the code was modified is included with the copyright notice.
10 //
11 // This software is provided "as is" without express or implied warranty, 
12 // and with no claim as to its suitability for any purpose.
13
14 #ifndef BOOST_TT_IS_FUNCTION_HPP_INCLUDED
15 #define BOOST_TT_IS_FUNCTION_HPP_INCLUDED
16
17 #include "boost/type_traits/is_reference.hpp"
18 #include "boost/type_traits/detail/false_result.hpp"
19 #include "boost/config.hpp"
20
21 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
22 #   include "boost/type_traits/detail/is_function_ptr_helper.hpp"
23 #else
24 #   include "boost/type_traits/detail/is_function_ptr_tester.hpp"
25 #   include "boost/type_traits/detail/yes_no_type.hpp"
26 #endif
27
28 // should be the last #include
29 #include "boost/type_traits/detail/bool_trait_def.hpp"
30
31 // is a type a function?
32 // Please note that this implementation is unnecessarily complex:
33 // we could just use !is_convertible<T*, const volatile void*>::value,
34 // except that some compilers erroneously allow conversions from
35 // function pointers to void*.
36
37 namespace boost {
38 namespace detail {
39
40 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
41 template<bool is_ref = true>
42 struct is_function_chooser
43     : ::boost::type_traits::false_result
44 {
45 };
46
47 template <>
48 struct is_function_chooser<false>
49 {
50     template< typename T > struct result_
51         : ::boost::type_traits::is_function_ptr_helper<T*>
52     {
53     };
54 };
55
56 template <typename T>
57 struct is_function_impl
58     : is_function_chooser< ::boost::is_reference<T>::value >
59         ::template result_<T>
60 {
61 };
62
63 #else
64
65 template <typename T>
66 struct is_function_impl
67 {
68     static T* t;
69     BOOST_STATIC_CONSTANT(
70         bool, value = sizeof(::boost::type_traits::is_function_ptr_tester(t))
71         == sizeof(::boost::type_traits::yes_type)
72         );
73 };
74
75 #endif
76
77 } // namespace detail
78
79 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_function,T,::boost::detail::is_function_impl<T>::value)
80
81 } // namespace boost
82
83 #include "boost/type_traits/detail/bool_trait_undef.hpp"
84
85 #endif // BOOST_TT_IS_FUNCTION_HPP_INCLUDED