Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:27

0001 // Copyright (c) 2009-2020 Vladimir Batov.
0002 // Use, modification and distribution are subject to the Boost Software License,
0003 // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt.
0004 
0005 #ifndef BOOST_CONVERT_IS_FUNCTION_HPP
0006 #define BOOST_CONVERT_IS_FUNCTION_HPP
0007 
0008 #include <boost/convert/detail/config.hpp>
0009 #include <boost/convert/detail/has_member.hpp>
0010 #include <boost/function_types/is_function_pointer.hpp>
0011 #include <boost/function_types/function_arity.hpp>
0012 #include <boost/function_types/result_type.hpp>
0013 
0014 namespace boost { namespace cnv
0015 {
0016     using yes_type = ::boost::type_traits::yes_type;
0017     using  no_type = ::boost::type_traits:: no_type;
0018 
0019     template <bool has_operator, typename Functor, typename TypeOut>
0020     struct check_functor { BOOST_STATIC_CONSTANT(bool, value = false); };
0021 
0022     template<typename Func, typename TypeOut, typename Enable = void>
0023     struct is_fun { BOOST_STATIC_CONSTANT(bool, value = false); };
0024 
0025     template <typename Functor, typename TypeOut>
0026     struct check_functor<true, Functor, TypeOut>
0027     {
0028         static yes_type test (TypeOut const&);
0029         static no_type  test (...);
0030 
0031         static bool BOOST_CONSTEXPR_OR_CONST value = sizeof(yes_type) == sizeof(test(((Functor*) 0)->operator()()));
0032     };
0033     template<typename Functor, typename TypeOut>
0034     struct is_fun<Functor, TypeOut,
0035         typename enable_if_c<std::is_class<Functor>::value && !is_convertible<Functor, TypeOut>::value, void>::type>
0036     {
0037         BOOST_DECLARE_HAS_MEMBER(has_funop, operator());
0038 
0039         BOOST_STATIC_CONSTANT(bool, value = (check_functor<has_funop<Functor>::value, Functor, TypeOut>::value));
0040     };
0041     template<typename Function, typename TypeOut>
0042     struct is_fun<Function, TypeOut,
0043         typename enable_if_c<
0044             function_types::is_function_pointer<Function>::value &&
0045             function_types::function_arity<Function>::value == 0 &&
0046             !is_same<Function, TypeOut>::value,
0047         void>::type>
0048     {
0049         using  out_type = TypeOut;
0050         using func_type = typename function_types::result_type<Function>::type;
0051 
0052         BOOST_STATIC_CONSTANT(bool, value = (is_convertible<func_type, out_type>::value));
0053     };
0054 }}
0055 
0056 #endif // BOOST_CONVERT_IS_FUNCTION_HPP
0057