diff --git a/test/Jamfile b/test/Jamfile index a61239d0..c8fde396 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -255,6 +255,7 @@ project [ run sequence/swap.cpp ] [ compile support/is_sequence.cpp ] + [ compile support/pair_conversion.cpp ] [ compile support/pair_deque.cpp ] [ compile support/pair_list.cpp ] [ compile support/pair_map.cpp ] @@ -266,6 +267,8 @@ project [ compile support/and.cpp : [ requires cxx11_variadic_templates ] ] [ compile support/tag_of.cpp ] + [ compile support/pair_trivially_copyable.cpp + : [ requires cxx11_hdr_type_traits ] ] # [ compile-fail xxx.cpp ] diff --git a/test/support/pair_conversion.cpp b/test/support/pair_conversion.cpp new file mode 100644 index 00000000..f0d63269 --- /dev/null +++ b/test/support/pair_conversion.cpp @@ -0,0 +1,42 @@ +/*============================================================================= + Copyright (c) 2018 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) +==============================================================================*/ + +#include +#include +#include + +using namespace boost::fusion; + +struct eat_int +{ + eat_int(int); +}; + +struct eat_pair +{ + template + eat_pair(pair); +}; + +int main() +{ + pair p; + + pair ci(p); + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + pair mi(std::move(p)); +#endif + + // eat_pair can't be converted from int, but can be pair. + // So pair(eat_pair) should be called rather than pair(pair). + pair cp(p); + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + pair mp(std::move(p)); +#endif +} diff --git a/test/support/pair_nest.cpp b/test/support/pair_nest.cpp index fbc253cb..9c2e9825 100644 --- a/test/support/pair_nest.cpp +++ b/test/support/pair_nest.cpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2015 Kohei Takahashi + Copyright (c) 2015,2018 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) @@ -10,15 +10,20 @@ using namespace boost::fusion; template -void copy() +void copy(C value) { - pair src; + pair src(value); pair dest = src; boost::ignore_unused(dest); } int main() { - copy >(); + copy >(42.195f); + copy >(42.195f); + + float f; + pair r(f); + copy >(r); } diff --git a/test/support/pair_trivially_copyable.cpp b/test/support/pair_trivially_copyable.cpp new file mode 100644 index 00000000..55926d93 --- /dev/null +++ b/test/support/pair_trivially_copyable.cpp @@ -0,0 +1,50 @@ +/*============================================================================= + Copyright (c) 2018 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) +==============================================================================*/ + +#include +#include +#include + +using namespace boost::fusion; + +struct non_trivially_copyable +{ + non_trivially_copyable(const non_trivially_copyable&); + non_trivially_copyable operator=(const non_trivially_copyable&); +}; + +struct pod { }; + +BOOST_MPL_ASSERT_NOT((std::is_trivially_copyable)); +BOOST_MPL_ASSERT((std::is_trivially_copyable)); +BOOST_MPL_ASSERT_NOT((std::is_trivially_copyable)); +BOOST_MPL_ASSERT((std::is_trivially_copyable)); +BOOST_MPL_ASSERT_NOT((std::is_trivially_copyable)); +BOOST_MPL_ASSERT((std::is_trivially_copyable)); + + + +BOOST_MPL_ASSERT((std::is_trivially_copyable >)); +BOOST_MPL_ASSERT((std::is_trivially_copyable >)); +BOOST_MPL_ASSERT((std::is_trivially_copyable >)); +BOOST_MPL_ASSERT_NOT((std::is_trivially_copyable >)); +BOOST_MPL_ASSERT((std::is_trivially_copyable >)); +BOOST_MPL_ASSERT((std::is_trivially_copyable >)); + +BOOST_MPL_ASSERT((std::is_trivially_copyable >)); +BOOST_MPL_ASSERT((std::is_trivially_copyable >)); +BOOST_MPL_ASSERT((std::is_trivially_copyable >)); +BOOST_MPL_ASSERT((std::is_trivially_copyable >)); +BOOST_MPL_ASSERT((std::is_trivially_copyable >)); +BOOST_MPL_ASSERT((std::is_trivially_copyable >)); + +BOOST_MPL_ASSERT((std::is_trivially_copyable >)); +BOOST_MPL_ASSERT((std::is_trivially_copyable >)); +BOOST_MPL_ASSERT((std::is_trivially_copyable >)); +BOOST_MPL_ASSERT((std::is_trivially_copyable >)); +BOOST_MPL_ASSERT((std::is_trivially_copyable >)); +BOOST_MPL_ASSERT((std::is_trivially_copyable >));