| 1 | |
| 2 | // Copyright 2000 John Maddock (john@johnmaddock.co.uk) |
| 3 | // Copyright 2002 Aleksey Gurtovoy (agurtovoy@meta-comm.com) |
| 4 | // |
| 5 | // Use, modification and distribution are subject to the Boost Software License, |
| 6 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
| 7 | // http://www.boost.org/LICENSE_1_0.txt). |
| 8 | // |
| 9 | // See http://www.boost.org/libs/type_traits for most recent version including documentation. |
| 10 | |
| 11 | #ifndef BOOST_TT_IS_FUNCTION_HPP_INCLUDED |
| 12 | #define BOOST_TT_IS_FUNCTION_HPP_INCLUDED |
| 13 | |
| 14 | #include <boost/type_traits/is_reference.hpp> |
| 15 | #include <boost/type_traits/detail/config.hpp> |
| 16 | |
| 17 | #if !defined(BOOST_TT_TEST_MS_FUNC_SIGS) |
| 18 | # include <boost/type_traits/detail/is_function_ptr_helper.hpp> |
| 19 | #else |
| 20 | # include <boost/type_traits/detail/is_function_ptr_tester.hpp> |
| 21 | # include <boost/type_traits/detail/yes_no_type.hpp> |
| 22 | #endif |
| 23 | |
| 24 | // is a type a function? |
| 25 | // Please note that this implementation is unnecessarily complex: |
| 26 | // we could just use !is_convertible<T*, const volatile void*>::value, |
| 27 | // except that some compilers erroneously allow conversions from |
| 28 | // function pointers to void*. |
| 29 | |
| 30 | namespace boost { |
| 31 | |
| 32 | #if !defined( __CODEGEARC__ ) |
| 33 | |
| 34 | namespace detail { |
| 35 | |
| 36 | #if !defined(BOOST_TT_TEST_MS_FUNC_SIGS) |
| 37 | template<bool is_ref = true> |
| 38 | struct is_function_chooser |
| 39 | { |
| 40 | template< typename T > struct result_ |
| 41 | : public false_type {}; |
| 42 | }; |
| 43 | |
| 44 | template <> |
| 45 | struct is_function_chooser<false> |
| 46 | { |
| 47 | template< typename T > struct result_ |
| 48 | : public ::boost::type_traits::is_function_ptr_helper<T*> {}; |
| 49 | }; |
| 50 | |
| 51 | template <typename T> |
| 52 | struct is_function_impl |
| 53 | : public is_function_chooser< ::boost::is_reference<T>::value > |
| 54 | ::BOOST_NESTED_TEMPLATE result_<T> |
| 55 | { |
| 56 | }; |
| 57 | |
| 58 | #else |
| 59 | |
| 60 | template <typename T> |
| 61 | struct is_function_impl |
| 62 | { |
| 63 | #if BOOST_WORKAROUND(BOOST_MSVC_FULL_VER, >= 140050000) |
| 64 | #pragma warning(push) |
| 65 | #pragma warning(disable:6334) |
| 66 | #endif |
| 67 | static T* t; |
| 68 | BOOST_STATIC_CONSTANT( |
| 69 | bool, value = sizeof(::boost::type_traits::is_function_ptr_tester(t)) |
| 70 | == sizeof(::boost::type_traits::yes_type) |
| 71 | ); |
| 72 | #if BOOST_WORKAROUND(BOOST_MSVC_FULL_VER, >= 140050000) |
| 73 | #pragma warning(pop) |
| 74 | #endif |
| 75 | }; |
| 76 | |
| 77 | template <typename T> |
| 78 | struct is_function_impl<T&> : public false_type |
| 79 | {}; |
| 80 | #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES |
| 81 | template <typename T> |
| 82 | struct is_function_impl<T&&> : public false_type |
| 83 | {}; |
| 84 | #endif |
| 85 | |
| 86 | #endif |
| 87 | |
| 88 | } // namespace detail |
| 89 | |
| 90 | #endif // !defined( __CODEGEARC__ ) |
| 91 | |
| 92 | #if defined( __CODEGEARC__ ) |
| 93 | template <class T> struct is_function : integral_constant<bool, __is_function(T)> {}; |
| 94 | #else |
| 95 | template <class T> struct is_function : integral_constant<bool, ::boost::detail::is_function_impl<T>::value> {}; |
| 96 | #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES |
| 97 | template <class T> struct is_function<T&&> : public false_type {}; |
| 98 | #endif |
| 99 | #endif |
| 100 | } // namespace boost |
| 101 | |
| 102 | #endif // BOOST_TT_IS_FUNCTION_HPP_INCLUDED |
| 103 | |