/*============================================================================= Copyright (C) 2016 Lee Clagett Copyright (C) 2018 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #include #include #include #include #include #include #include #include #include #include #include struct convertible { convertible(int) {} }; template bool is_convertible(bool has_conversion) { typedef typename boost::remove_reference< typename boost::remove_const::type >::type from_rvalue; typedef typename boost::add_reference::type from_lvalue; typedef typename boost::add_const::type from_const_lvalue; return boost::is_convertible::value == has_conversion && boost::is_convertible::value == has_conversion && boost::is_convertible::value == has_conversion; } // is_constructible has a few requirements #ifdef BOOST_TT_IS_CONSTRUCTIBLE_CONFORMING #define FUSION_TEST_HAS_CONSTRUCTIBLE template bool is_lvalue_constructible(bool has_constructor) { return has_constructor == boost::is_constructible< To , typename boost::add_reference::type... >::value; } template bool is_constructible_impl(bool has_constructor) { return boost::is_constructible::value == has_constructor && is_lvalue_constructible(has_constructor) && is_lvalue_constructible< To, typename boost::add_const::type... >(has_constructor); } template bool is_constructible(bool has_constructor) { return is_constructible_impl< To , typename boost::remove_reference< typename boost::remove_const::type >::type... >(has_constructor); } void test_constructible() { BOOST_TEST((is_constructible< FUSION_SEQUENCE<> >(true))); BOOST_TEST((is_constructible< FUSION_SEQUENCE >(true))); BOOST_TEST((is_constructible, int>(true))); BOOST_TEST((is_constructible, int>(true))); BOOST_TEST(( is_constructible, convertible>(true) )); // boost::is_constructible always fail to test ctor which takes 2 or more arguments on GCC 4.7. #if !BOOST_WORKAROUND(BOOST_GCC, < 40700) BOOST_TEST(( is_constructible, int, int>(true) )); BOOST_TEST(( is_constructible, int, int>(true) )); BOOST_TEST(( is_constructible< FUSION_SEQUENCE, convertible, int >(true) )); BOOST_TEST(( is_constructible, int, int>(true) )); BOOST_TEST(( is_constructible< FUSION_SEQUENCE, int, convertible >(true) )); BOOST_TEST(( is_constructible< FUSION_SEQUENCE, int, int >(true) )); BOOST_TEST(( is_constructible< FUSION_SEQUENCE, convertible, int >(true) )); BOOST_TEST(( is_constructible< FUSION_SEQUENCE, int, convertible >(true) )); BOOST_TEST(( is_constructible< FUSION_SEQUENCE, convertible, convertible >(true) )); #endif // !(gcc < 4.7) } #endif // is_constructible is available void test_convertible(bool has_seq_conversion) { BOOST_TEST((is_convertible >(false))); BOOST_TEST((is_convertible >(false))); BOOST_TEST((is_convertible >(false))); BOOST_TEST((is_convertible >(false))); BOOST_TEST(( is_convertible >(false) )); BOOST_TEST((is_convertible >(false))); BOOST_TEST(( is_convertible >(false) )); BOOST_TEST((is_convertible >(false))); BOOST_TEST(( is_convertible >(false) )); BOOST_TEST((is_convertible >(false))); BOOST_TEST(( is_convertible >(false) )); BOOST_TEST(( is_convertible >(false) )); BOOST_TEST(( is_convertible< int, FUSION_SEQUENCE >(false) )); BOOST_TEST((is_convertible, FUSION_SEQUENCE<> >(true))); BOOST_TEST(( is_convertible, FUSION_SEQUENCE >(true) )); BOOST_TEST(( is_convertible, FUSION_SEQUENCE >(true) )); BOOST_TEST(( is_convertible, FUSION_SEQUENCE >(true) )); BOOST_TEST(( is_convertible, FUSION_SEQUENCE >(true) )); BOOST_TEST(( is_convertible< FUSION_SEQUENCE, FUSION_SEQUENCE >(true) )); BOOST_TEST(( is_convertible< FUSION_SEQUENCE, FUSION_SEQUENCE >(true) )); BOOST_TEST(( is_convertible< FUSION_SEQUENCE, FUSION_SEQUENCE >(true) )); BOOST_TEST(( is_convertible< FUSION_SEQUENCE , FUSION_SEQUENCE >(true) )); BOOST_TEST(( is_convertible< FUSION_ALT_SEQUENCE<>, FUSION_SEQUENCE<> >(has_seq_conversion) )); BOOST_TEST(( is_convertible< FUSION_ALT_SEQUENCE, FUSION_SEQUENCE >(has_seq_conversion) )); BOOST_TEST(( is_convertible< FUSION_ALT_SEQUENCE, FUSION_SEQUENCE >(has_seq_conversion) )); BOOST_TEST(( is_convertible< FUSION_ALT_SEQUENCE, FUSION_SEQUENCE >(has_seq_conversion) )); BOOST_TEST(( is_convertible< FUSION_ALT_SEQUENCE, FUSION_SEQUENCE >(has_seq_conversion) )); BOOST_TEST(( is_convertible< FUSION_ALT_SEQUENCE , FUSION_SEQUENCE >(has_seq_conversion) )); BOOST_TEST(( is_convertible< FUSION_ALT_SEQUENCE, FUSION_SEQUENCE >(has_seq_conversion) )); BOOST_TEST(( is_convertible< FUSION_ALT_SEQUENCE, FUSION_SEQUENCE >(has_seq_conversion) )); BOOST_TEST(( is_convertible< FUSION_ALT_SEQUENCE , FUSION_SEQUENCE >(has_seq_conversion) )); }