5906d9c316
- Construct from elements is enabled iff each argument is_convertible to corresponding element. - Construct from sequence is enabled iff the single argument is a fusion sequence. - C++11 vector and tuple also disable construct from sequence that are shorter than the destination. C++03 gives incorrect is_convertible responses in this situation and fails to compile if that constructor is used; C++11 can have instantation errors in and_<is_convertible<U, T>...> without the additional check. - C++11 tuple and vector support truncation conversion and assignment like all other sequences.
52 lines
1.5 KiB
C++
52 lines
1.5 KiB
C++
/*=============================================================================
|
|
Copyright (c) 2016 Lee Clagett
|
|
|
|
Use modification and distribution are subject to 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 <boost/detail/lightweight_test.hpp>
|
|
#include <boost/fusion/tuple.hpp>
|
|
|
|
#define FUSION_SEQUENCE boost::fusion::tuple
|
|
#include "conversion.hpp"
|
|
|
|
// Bug in C++03 tuple? Cannot construct from a std::pair without including
|
|
// std::pair fusion adaption
|
|
#if !defined(BOOST_FUSION_HAS_VARIADIC_TUPLE)
|
|
# include <boost/fusion/adapted/std_pair.hpp>
|
|
#endif
|
|
|
|
using namespace test_detail;
|
|
|
|
void test_tuple()
|
|
{
|
|
BOOST_TEST((
|
|
run< can_copy< boost::fusion::tuple<int, int> > >(
|
|
std::pair<int, int>(1, 9)
|
|
)
|
|
));
|
|
BOOST_TEST((
|
|
run< can_copy< boost::fusion::tuple<int, convertible> > >(
|
|
std::pair<int, int>(1, 9)
|
|
)
|
|
));
|
|
BOOST_TEST((
|
|
run< can_copy< boost::fusion::tuple<convertible, int> > >(
|
|
std::pair<int, int>(1, 9)
|
|
)
|
|
));
|
|
BOOST_TEST((
|
|
run< can_copy< boost::fusion::tuple<convertible, convertible> > >(
|
|
std::pair<int, int>(1, 9)
|
|
)
|
|
));
|
|
}
|
|
|
|
int main()
|
|
{
|
|
test<can_assign>(); // conversion construction not supported
|
|
test_tuple();
|
|
return boost::report_errors();
|
|
}
|