blob: ccb42b775cf5969f268100f69bda0d52b7e2910f [file] [log] [blame]
Jeff Thompsonf7d49942013-08-01 16:47:40 -07001
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
Jeff Thompson3d613fd2013-10-15 15:39:04 -070011#ifndef NDNBOOST_TT_IS_FUNCTION_HPP_INCLUDED
12#define NDNBOOST_TT_IS_FUNCTION_HPP_INCLUDED
Jeff Thompsonf7d49942013-08-01 16:47:40 -070013
Jeff Thompson2277ce52013-08-01 17:34:11 -070014#include <ndnboost/type_traits/is_reference.hpp>
15#include <ndnboost/type_traits/detail/false_result.hpp>
16#include <ndnboost/config.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070017
Jeff Thompson3d613fd2013-10-15 15:39:04 -070018#if !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(NDNBOOST_TT_TEST_MS_FUNC_SIGS)
Jeff Thompson2277ce52013-08-01 17:34:11 -070019# include <ndnboost/type_traits/detail/is_function_ptr_helper.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070020#else
Jeff Thompson2277ce52013-08-01 17:34:11 -070021# include <ndnboost/type_traits/detail/is_function_ptr_tester.hpp>
22# include <ndnboost/type_traits/detail/yes_no_type.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070023#endif
24
25// should be the last #include
Jeff Thompson2277ce52013-08-01 17:34:11 -070026#include <ndnboost/type_traits/detail/bool_trait_def.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070027
28// is a type a function?
29// Please note that this implementation is unnecessarily complex:
30// we could just use !is_convertible<T*, const volatile void*>::value,
31// except that some compilers erroneously allow conversions from
32// function pointers to void*.
33
34namespace ndnboost {
35
36#if !defined( __CODEGEARC__ )
37
38namespace detail {
39
Jeff Thompson3d613fd2013-10-15 15:39:04 -070040#if !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(NDNBOOST_TT_TEST_MS_FUNC_SIGS)
Jeff Thompsonf7d49942013-08-01 16:47:40 -070041template<bool is_ref = true>
42struct is_function_chooser
43 : public ::ndnboost::type_traits::false_result
44{
45};
46
47template <>
48struct is_function_chooser<false>
49{
50 template< typename T > struct result_
51 : public ::ndnboost::type_traits::is_function_ptr_helper<T*>
52 {
53 };
54};
55
56template <typename T>
57struct is_function_impl
58 : public is_function_chooser< ::ndnboost::is_reference<T>::value >
Jeff Thompson3d613fd2013-10-15 15:39:04 -070059 ::NDNBOOST_NESTED_TEMPLATE result_<T>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070060{
61};
62
63#else
64
65template <typename T>
66struct is_function_impl
67{
Jeff Thompson3d613fd2013-10-15 15:39:04 -070068#if NDNBOOST_WORKAROUND(NDNBOOST_MSVC_FULL_VER, >= 140050000)
Jeff Thompsonf7d49942013-08-01 16:47:40 -070069#pragma warning(push)
70#pragma warning(disable:6334)
71#endif
72 static T* t;
Jeff Thompson3d613fd2013-10-15 15:39:04 -070073 NDNBOOST_STATIC_CONSTANT(
Jeff Thompsonf7d49942013-08-01 16:47:40 -070074 bool, value = sizeof(::ndnboost::type_traits::is_function_ptr_tester(t))
75 == sizeof(::ndnboost::type_traits::yes_type)
76 );
Jeff Thompson3d613fd2013-10-15 15:39:04 -070077#if NDNBOOST_WORKAROUND(NDNBOOST_MSVC_FULL_VER, >= 140050000)
Jeff Thompsonf7d49942013-08-01 16:47:40 -070078#pragma warning(pop)
79#endif
80};
81
Jeff Thompson3d613fd2013-10-15 15:39:04 -070082#if !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
Jeff Thompsonf7d49942013-08-01 16:47:40 -070083template <typename T>
84struct is_function_impl<T&> : public false_type
85{};
Jeff Thompson3d613fd2013-10-15 15:39:04 -070086#ifndef NDNBOOST_NO_CXX11_RVALUE_REFERENCES
Jeff Thompsonf7d49942013-08-01 16:47:40 -070087template <typename T>
88struct is_function_impl<T&&> : public false_type
89{};
90#endif
91#endif
92
93#endif
94
95} // namespace detail
96
97#endif // !defined( __CODEGEARC__ )
98
99#if defined( __CODEGEARC__ )
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700100NDNBOOST_TT_AUX_BOOL_TRAIT_DEF1(is_function,T,__is_function(T))
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700101#else
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700102NDNBOOST_TT_AUX_BOOL_TRAIT_DEF1(is_function,T,::ndnboost::detail::is_function_impl<T>::value)
103#ifndef NDNBOOST_NO_CXX11_RVALUE_REFERENCES
104NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_function,T&&,false)
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700105#endif
106#endif
107} // namespace ndnboost
108
Jeff Thompson2277ce52013-08-01 17:34:11 -0700109#include <ndnboost/type_traits/detail/bool_trait_undef.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700110
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700111#endif // NDNBOOST_TT_IS_FUNCTION_HPP_INCLUDED