From 10d9f0ffba1ec80e49e2aedee3d313318bdf4e87 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Tue, 25 Aug 2015 23:36:32 +0900 Subject: [PATCH 1/2] Add convert tests for non-assoc containers. --- test/Jamfile | 6 ++++ test/sequence/convert.hpp | 51 +++++++++++++++++++++++++++ test/sequence/convert_boost_tuple.cpp | 14 ++++++++ test/sequence/convert_deque.cpp | 13 +++++++ test/sequence/convert_list.cpp | 13 +++++++ test/sequence/convert_std_pair.cpp | 14 ++++++++ test/sequence/convert_std_tuple.cpp | 25 +++++++++++++ test/sequence/convert_vector.cpp | 13 +++++++ 8 files changed, 149 insertions(+) create mode 100644 test/sequence/convert.hpp create mode 100644 test/sequence/convert_boost_tuple.cpp create mode 100644 test/sequence/convert_deque.cpp create mode 100644 test/sequence/convert_list.cpp create mode 100644 test/sequence/convert_std_pair.cpp create mode 100644 test/sequence/convert_std_tuple.cpp create mode 100644 test/sequence/convert_vector.cpp diff --git a/test/Jamfile b/test/Jamfile index 33701cb6..fbfea3c9 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -65,6 +65,12 @@ project [ run sequence/boost_tuple.cpp : : : : ] [ run sequence/boost_tuple_iterator.cpp : : : : ] [ run sequence/cons.cpp : : : : ] + [ run sequence/convert_boost_tuple.cpp : : : : ] + [ run sequence/convert_deque.cpp : : : : ] + [ run sequence/convert_list.cpp : : : : ] + [ run sequence/convert_std_pair.cpp : : : : ] + [ run sequence/convert_std_tuple.cpp : : : : ] + [ run sequence/convert_vector.cpp : : : : ] [ run sequence/filter_view.cpp : : : : ] [ run sequence/hash.cpp : : : : ] [ run sequence/io.cpp : : : : ] diff --git a/test/sequence/convert.hpp b/test/sequence/convert.hpp new file mode 100644 index 00000000..233fabfb --- /dev/null +++ b/test/sequence/convert.hpp @@ -0,0 +1,51 @@ +/*============================================================================= + Copyright (c) 2015 Kohei Takahashi + + 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 +#include +#include +#include +#include + +#include +#include +#include +#include +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +#include +#endif + +template +void test(FUSION_SEQUENCE const& seq) +{ + typedef typename + boost::fusion::result_of::convert< + Tag + , FUSION_SEQUENCE + >::type + type; + + type v = boost::fusion::convert(seq); + BOOST_TEST((boost::fusion::at_c<0>(v) == 123)); + BOOST_TEST((boost::fusion::at_c<1>(v) == "Hola!!!")); +} + +int main() +{ + FUSION_SEQUENCE seq(123, "Hola!!!"); + test(seq); + test(seq); + test(seq); + test(seq); +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + test(seq); +#endif + + return boost::report_errors(); +} + diff --git a/test/sequence/convert_boost_tuple.cpp b/test/sequence/convert_boost_tuple.cpp new file mode 100644 index 00000000..588ee4d7 --- /dev/null +++ b/test/sequence/convert_boost_tuple.cpp @@ -0,0 +1,14 @@ +/*============================================================================= + Copyright (c) 2015 Kohei Takahashi + + 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 +#include + +#define FUSION_SEQUENCE boost::tuples::tuple +#include "convert.hpp" + diff --git a/test/sequence/convert_deque.cpp b/test/sequence/convert_deque.cpp new file mode 100644 index 00000000..5be34d3f --- /dev/null +++ b/test/sequence/convert_deque.cpp @@ -0,0 +1,13 @@ +/*============================================================================= + Copyright (c) 2015 Kohei Takahashi + + 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 + +#define FUSION_SEQUENCE boost::fusion::deque +#include "convert.hpp" + diff --git a/test/sequence/convert_list.cpp b/test/sequence/convert_list.cpp new file mode 100644 index 00000000..57ad0507 --- /dev/null +++ b/test/sequence/convert_list.cpp @@ -0,0 +1,13 @@ +/*============================================================================= + Copyright (c) 2015 Kohei Takahashi + + 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 + +#define FUSION_SEQUENCE boost::fusion::list +#include "convert.hpp" + diff --git a/test/sequence/convert_std_pair.cpp b/test/sequence/convert_std_pair.cpp new file mode 100644 index 00000000..aa350025 --- /dev/null +++ b/test/sequence/convert_std_pair.cpp @@ -0,0 +1,14 @@ +/*============================================================================= + Copyright (c) 2015 Kohei Takahashi + + 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 +#include + +#define FUSION_SEQUENCE std::pair +#include "convert.hpp" + diff --git a/test/sequence/convert_std_tuple.cpp b/test/sequence/convert_std_tuple.cpp new file mode 100644 index 00000000..3e28276c --- /dev/null +++ b/test/sequence/convert_std_tuple.cpp @@ -0,0 +1,25 @@ +/*============================================================================= + Copyright (c) 2015 Kohei Takahashi + + 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 + +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + +#include +#include + +#define FUSION_SEQUENCE std::tuple +#include "convert.hpp" + +#else + +int main() +{ +} + +#endif diff --git a/test/sequence/convert_vector.cpp b/test/sequence/convert_vector.cpp new file mode 100644 index 00000000..b39014df --- /dev/null +++ b/test/sequence/convert_vector.cpp @@ -0,0 +1,13 @@ +/*============================================================================= + Copyright (c) 2015 Kohei Takahashi + + 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 + +#define FUSION_SEQUENCE boost::fusion::vector +#include "convert.hpp" + From e61d08d953372820c311c796fcf7468a73c85d19 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Wed, 26 Aug 2015 00:20:07 +0900 Subject: [PATCH 2/2] Fix broken convert, close issue 11572. --- .../boost/fusion/container/deque/detail/convert_impl.hpp | 9 +++++++-- .../fusion/container/deque/detail/cpp03/build_deque.hpp | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/boost/fusion/container/deque/detail/convert_impl.hpp b/include/boost/fusion/container/deque/detail/convert_impl.hpp index ba9b8477..ede0cc48 100644 --- a/include/boost/fusion/container/deque/detail/convert_impl.hpp +++ b/include/boost/fusion/container/deque/detail/convert_impl.hpp @@ -1,6 +1,7 @@ /*============================================================================= Copyright (c) 2005-2012 Joel de Guzman Copyright (c) 2005-2006 Dan Marsden + Copyright (c) 2015 Kohei Takahashi 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) @@ -12,7 +13,7 @@ #include #include #include -#include +#include namespace boost { namespace fusion { @@ -41,7 +42,11 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type call(Sequence& seq) { - return gen::call(seq); + return gen::call(fusion::begin(seq) +#if defined(BOOST_FUSION_HAS_VARIADIC_DEQUE) + , fusion::end(seq) +#endif + ); } }; }; diff --git a/include/boost/fusion/container/deque/detail/cpp03/build_deque.hpp b/include/boost/fusion/container/deque/detail/cpp03/build_deque.hpp index 99cbe584..587aa3b0 100644 --- a/include/boost/fusion/container/deque/detail/cpp03/build_deque.hpp +++ b/include/boost/fusion/container/deque/detail/cpp03/build_deque.hpp @@ -22,6 +22,7 @@ namespace boost { namespace fusion { template struct as_deque + : detail::as_deque::value> { typedef typename detail::as_deque::value>