/*============================================================================= Copyright (c) 2016 Lee Clagett 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 #define FUSION_SEQUENCE boost::fusion::tuple #define FUSION_ALT_SEQUENCE boost::fusion::vector #include "traits.hpp" struct not_convertible {}; /* Some construction differences in fusion::tuple from std::tuple: - Construction from elements cannot call an explicit constructor. - There is no implicit construction from elements. - Construction from std::pair is _enabled_ when tuple is not of size 2. - Construction from tuple is _enabled_ when destination tuple is of different size. - Implicit construction from std::pair can call explicit constructors on elements. - Implicit construction from tuple can call explicit constructors on elements. These differences are historical. Matching the behavior of std::tuple could break existing code, however, switching to fusion::vector would restore the historical behavior. */ int main() { using namespace boost::fusion; test_convertible(false /* no conversion construction */ ); BOOST_TEST((is_convertible, tuple >(true))); BOOST_TEST(( is_convertible, tuple >(true) )); BOOST_TEST(( is_convertible, tuple >(true) )); BOOST_TEST(( is_convertible< std::pair, tuple >(true) )); #if defined(FUSION_TEST_HAS_CONSTRUCTIBLE) test_constructible(); BOOST_TEST((is_constructible< tuple<> >(true))); BOOST_TEST((is_constructible, int>(false))); BOOST_TEST((is_constructible< tuple >(true))); BOOST_TEST((is_constructible, int>(true))); BOOST_TEST((is_constructible, int>(true))); BOOST_TEST((is_constructible, int>(false))); BOOST_TEST((is_constructible< tuple, vector >(false))); BOOST_TEST((is_constructible, int, int>(false))); BOOST_TEST((is_constructible< tuple >(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) )); #endif // !(gcc < 4.7) BOOST_TEST((is_constructible, int, int>(false))); BOOST_TEST((is_constructible, int, int>(false))); BOOST_TEST(( is_constructible, int, int>(false) )); #if defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) // C++03 fusion::tuple has constructors that can never be used BOOST_TEST((is_constructible, int>(false))); #endif BOOST_TEST((is_constructible, int, int, int>(false))); #endif // FUSION_TEST_HAS_CONSTRUCTIBLE return boost::report_errors(); }