⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 type_deduction.hpp

📁 Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work
💻 HPP
📖 第 1 页 / 共 2 页
字号:
    };    template <typename T, std::size_t N>    struct reference_type<T[N]>    {        typedef T& type;    };    template <typename T>    struct reference_type<T*>    {        typedef T& type;    };    template <typename C>    struct const_reference_type    {        typedef typename C::const_reference type;    };    template <typename C>    struct mapped_type    {        typedef typename C::mapped_type type;    };    struct asymmetric;    template <typename X, typename Y>    cant_deduce_type    test(...); // The black hole !!!    template <typename X, typename Y>    bool_value_type    test(bool const&);    template <typename X, typename Y>    int_value_type    test(int const&);    template <typename X, typename Y>    uint_value_type    test(unsigned const&);    template <typename X, typename Y>    double_value_type    test(double const&);    template <typename X, typename Y>    bool_reference_type    test(bool&);    template <typename X, typename Y>    int_reference_type    test(int&);    template <typename X, typename Y>    uint_reference_type    test(unsigned&);    template <typename X, typename Y>    double_reference_type    test(double&);    template <typename X, typename Y>    typename disable_if<        mpl::or_<is_basic<X>, is_const<X> >      , x_value_type    >::type    test(X const&);    template <typename X, typename Y>    typename disable_if<        is_basic<X>      , x_reference_type    >::type    test(X&);    template <typename X, typename Y>    typename disable_if<        mpl::or_<            is_basic<X>          , is_const<X>        >      , x_const_pointer_type    >::type    test(X const*);    template <typename X, typename Y>    x_pointer_type    test(X*);    template <typename X, typename Y>    typename disable_if<        mpl::or_<            is_basic<Y>          , is_same<Y, asymmetric>          , is_const<Y>          , is_same<X, Y>        >      , y_value_type    >::type    test(Y const&);    template <typename X, typename Y>    typename disable_if<        mpl::or_<            is_basic<Y>          , is_same<Y, asymmetric>          , is_same<X, Y>        >      , y_reference_type    >::type    test(Y&);    template <typename X, typename Y>    typename disable_if<        mpl::or_<            is_same<Y, asymmetric>          , is_const<Y>          , is_same<X, Y>        >      , y_const_pointer_type    >::type    test(Y const*);    template <typename X, typename Y>    typename disable_if<        mpl::or_<            is_same<Y, asymmetric>          , is_same<X, Y>        >      , y_pointer_type    >::type    test(Y*);    template <typename X, typename Y>    typename disable_if<        is_basic<typename X::value_type>      , container_reference_type    >::type    test(typename X::reference);    template <typename X, typename Y, typename Z>    typename enable_if<        mpl::and_<            mpl::or_<is_array<X>, is_pointer<X> >          , mpl::not_<is_basic<Z> >          , mpl::not_<is_same<X, Z> >        >      , container_reference_type    >::type    test(Z&);    template <typename X, typename Y>    typename disable_if<        is_basic<typename X::value_type>      , container_const_reference_type    >::type    test(typename X::const_reference);    template <typename X, typename Y>    typename disable_if<        is_basic<typename X::mapped_type>      , container_mapped_type    >::type    test(typename X::mapped_type);    template <typename X, typename Y>    struct base_result_of    {        typedef typename phoenix::detail::unwrap_local_reference<X>::type x_type_;        typedef typename phoenix::detail::unwrap_local_reference<Y>::type y_type_;        typedef typename remove_reference<x_type_>::type x_type;        typedef typename remove_reference<y_type_>::type y_type;        typedef mpl::vector20<            mpl::identity<bool>          , mpl::identity<int>          , mpl::identity<unsigned>          , mpl::identity<double>          , mpl::identity<bool&>          , mpl::identity<int&>          , mpl::identity<unsigned&>          , mpl::identity<double&>          , mpl::identity<x_type>          , mpl::identity<x_type&>          , mpl::identity<x_type const*>          , mpl::identity<x_type*>          , mpl::identity<y_type>          , mpl::identity<y_type&>          , mpl::identity<y_type const*>          , mpl::identity<y_type*>          , reference_type<x_type>          , const_reference_type<x_type>          , mapped_type<x_type>          , mpl::identity<error_cant_deduce_type>        >        types;    };}} // namespace boost::type_deduction_detail#define BOOST_RESULT_OF_COMMON(expr, name, Y, SYMMETRY)                         \    struct name                                                                 \    {                                                                           \        typedef type_deduction_detail::base_result_of<X, Y> base_type;          \        static typename base_type::x_type x;                                    \        static typename base_type::y_type y;                                    \                                                                                \        BOOST_STATIC_CONSTANT(int,                                              \            size = sizeof(                                                      \                type_deduction_detail::test<                                    \                    typename base_type::x_type                                  \                  , SYMMETRY                                                    \                >(expr)                                                         \            ));                                                                 \                                                                                \        BOOST_STATIC_CONSTANT(int, index = (size / sizeof(char)) - 1);          \                                                                                \        typedef typename mpl::at_c<                                             \            typename base_type::types, index>::type id;                         \        typedef typename id::type type;                                         \    };#define BOOST_UNARY_RESULT_OF(expr, name)                                       \    template <typename X>                                                       \    BOOST_RESULT_OF_COMMON(expr, name,                                          \        type_deduction_detail::asymmetric, type_deduction_detail::asymmetric)#define BOOST_BINARY_RESULT_OF(expr, name)                                      \    template <typename X, typename Y>                                           \    BOOST_RESULT_OF_COMMON(expr, name, Y, typename base_type::y_type)#define BOOST_ASYMMETRIC_BINARY_RESULT_OF(expr, name)                           \    template <typename X, typename Y>                                           \    BOOST_RESULT_OF_COMMON(expr, name, Y, type_deduction_detail::asymmetric)#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -