/*============================================================================= 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 struct test_conversion { test_conversion(int) {} }; struct test_no_conversion { explicit test_no_conversion(int) {} }; /* 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; using namespace boost::fusion; BOOST_TEST(!(is_convertible >::value)); BOOST_TEST(!(is_convertible >::value)); BOOST_TEST(!(is_convertible< int, tuple >::value)); BOOST_TEST(!(is_convertible< int&, tuple >::value)); BOOST_TEST(!(is_convertible< vector, tuple >::value)); BOOST_TEST(!(is_convertible< vector&, tuple >::value)); BOOST_TEST(!(is_convertible >::value)); BOOST_TEST(!(is_convertible >::value)); } // is_constructible has some restrictions ... #if !(defined(BOOST_NO_CXX11_DECLTYPE) || defined(BOOST_NO_CXX11_TEMPLATES) || \ defined(BOOST_NO_SFINAE_EXPR)) { using namespace boost; using namespace boost::fusion; BOOST_TEST((is_constructible< tuple<> >::value)); BOOST_TEST(!(is_constructible, int>::value)); BOOST_TEST(!(is_constructible, int&>::value)); BOOST_TEST((is_constructible< tuple >::value)); BOOST_TEST((is_constructible, int>::value)); BOOST_TEST((is_constructible, int&>::value)); BOOST_TEST((is_constructible, int>::value)); BOOST_TEST((is_constructible, int&>::value)); BOOST_TEST(!(is_constructible, int>::value)); BOOST_TEST(!(is_constructible, int&>::value)); BOOST_TEST(!(is_constructible< tuple, vector >::value)); BOOST_TEST(!(is_constructible, vector&>::value)); BOOST_TEST(!(is_constructible, int, int>::value)); BOOST_TEST(!(is_constructible, int&, int&>::value)); BOOST_TEST((is_constructible< tuple >::value)); BOOST_TEST((is_constructible, int, int>::value)); BOOST_TEST((is_constructible, int&, int&>::value)); BOOST_TEST(( is_constructible< tuple , int , int >::value )); BOOST_TEST(( is_constructible< tuple , int& , int& >::value )); BOOST_TEST(!( is_constructible< tuple , int , int >::value )); BOOST_TEST(!( is_constructible< tuple , int& , int& >::value )); #if defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) // C++03 fusion::tuple has constructors that can never be used BOOST_TEST(!(is_constructible, int>::value)); BOOST_TEST(!(is_constructible, int&>::value)); #endif BOOST_TEST(!(is_constructible, int, int, int>::value)); BOOST_TEST(!( is_constructible, int&, int&, int&>::value )); } #endif return boost::report_errors(); }