Make C++11 fusion::vector more consistent with C++03 fusion::vector

- 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.
This commit is contained in:
Lee Clagett
2016-08-21 16:59:04 -04:00
parent 55150a7fa6
commit 5906d9c316
22 changed files with 1504 additions and 283 deletions

View File

@ -7,13 +7,29 @@
#include <boost/fusion/tuple/tuple.hpp>
#include <boost/core/lightweight_test.hpp>
#define FUSION_SEQUENCE tuple
#define FUSION_SEQUENCE boost::fusion::tuple
#include "nest.hpp"
// tuple does not support conversion construction from sequence by design
template <typename T>
struct skip_constructor_conversion
{
template <typename Source, typename Expected>
bool operator()(Source const& source, Expected const& expected) const
{
using namespace test_detail;
return
run< can_copy<T> >(source, expected) &&
run< can_convert_using<can_assign>::to<T> >(source, expected) &&
run< can_construct_from_elements<T> >(source, expected);
}
};
int
main()
{
test();
test<skip_constructor_conversion>();
return boost::report_errors();
}