diff --git a/include/boost/type_traits/function_traits.hpp b/include/boost/type_traits/function_traits.hpp index 2f6ac7b..2ec084b 100644 --- a/include/boost/type_traits/function_traits.hpp +++ b/include/boost/type_traits/function_traits.hpp @@ -10,13 +10,145 @@ // This software is provided "as is" without express or implied warranty, // and with no claim as to its suitability for any purpose. -#ifndef BOOST_TT_FUNCTION_TRAITS_HPP_INCLUDED -#define BOOST_TT_FUNCTION_TRAITS_HPP_INCLUDED +#ifndef BOOST_FUNCTION_TYPE_TRAITS_HPP +#define BOOST_FUNCTION_TYPE_TRAITS_HPP -#include "boost/type_traits/is_function.hpp" +#ifndef BOOST_ICE_TYPE_TRAITS_HPP +#include +#endif +#ifndef BOOST_FWD_TYPE_TRAITS_HPP +#include +#endif +#ifndef BOOST_COMPOSITE_TYPE_TRAITS_HPP +#include +#endif +// +// is a type a function? +// Please note that this implementation is unnecessarily complex: +// we could just use !is_convertible::value, +// except that some compilers erroneously allow conversions from +// function pointers to void*. +// +namespace boost{ +namespace detail{ + +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = false); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_function_helper_base{ BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_function_helper : is_function_helper_base{}; + +#else + +template +struct is_function_helper +{ + static T* t; + BOOST_STATIC_CONSTANT(bool, value = sizeof(is_function_tester(t)) == sizeof(::boost::type_traits::yes_type)); + //BOOST_STATIC_CONSTANT(bool, value = (!::boost::is_convertible::value)); +}; + +#endif + +template +struct is_function_ref_helper +{ + BOOST_STATIC_CONSTANT(bool, value = false); +}; + +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) +template +struct is_function_chooser +{ + typedef is_function_helper type; +}; +template +struct is_function_chooser +{ + typedef is_function_ref_helper type; +}; +#endif +} // namespace detail + +template +struct is_function +{ +private: +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + typedef typename detail::is_function_chooser::value>::type m_type; +#else + // without partial specialistaion we can't use is_reference on + // function types, that leaves this template broken in the case that + // T is a reference: + typedef detail::is_function_helper m_type; +#endif +public: + BOOST_STATIC_CONSTANT(bool, value = m_type::value); +}; #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -namespace boost { namespace detail { template struct function_traits_helper; @@ -229,6 +361,6 @@ struct function_traits }; #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -} +} // boost -#endif // BOOST_TT_FUNCTION_TRAITS_HPP_INCLUDED +#endif // BOOST_FUNCTION_TYPE_TRAITS_HPP