tuple_conversion.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*=============================================================================
  2. Copyright (c) 2016 Lee Clagett
  3. Use modification and distribution are subject to the Boost Software
  4. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt).
  6. ==============================================================================*/
  7. #include <boost/detail/lightweight_test.hpp>
  8. #include <boost/fusion/tuple.hpp>
  9. #define FUSION_SEQUENCE boost::fusion::tuple
  10. #include "conversion.hpp"
  11. // Bug in C++03 tuple? Cannot construct from a std::pair without including
  12. // std::pair fusion adaption
  13. #if !defined(BOOST_FUSION_HAS_VARIADIC_TUPLE)
  14. # include <boost/fusion/adapted/std_pair.hpp>
  15. #endif
  16. using namespace test_detail;
  17. void test_tuple()
  18. {
  19. BOOST_TEST((
  20. run< can_copy< boost::fusion::tuple<int, int> > >(
  21. std::pair<int, int>(1, 9)
  22. )
  23. ));
  24. BOOST_TEST((
  25. run< can_copy< boost::fusion::tuple<int, convertible> > >(
  26. std::pair<int, int>(1, 9)
  27. )
  28. ));
  29. BOOST_TEST((
  30. run< can_copy< boost::fusion::tuple<convertible, int> > >(
  31. std::pair<int, int>(1, 9)
  32. )
  33. ));
  34. BOOST_TEST((
  35. run< can_copy< boost::fusion::tuple<convertible, convertible> > >(
  36. std::pair<int, int>(1, 9)
  37. )
  38. ));
  39. }
  40. int main()
  41. {
  42. test<can_assign>(); // conversion construction not supported
  43. test_tuple();
  44. return boost::report_errors();
  45. }