Compare commits

..

2 Commits

Author SHA1 Message Date
4e57acbce7 Make fusion::pair trivially copyable if possible 2018-03-23 02:26:05 +09:00
44ef9e56e6 Added tests for support/pair 2018-03-23 02:25:38 +09:00
35 changed files with 278 additions and 617 deletions

View File

@ -11,6 +11,11 @@ os:
- linux
- osx
branches:
only:
- master
- develop
env:
matrix:
- BOGUS_JOB=true
@ -25,20 +30,6 @@ matrix:
- os: linux
env: TOOLSET=gcc CXXSTD=03,11,1y
- os: linux
env: TOOLSET=gcc-4.4 CXXSTD=98,0x
addons:
apt:
packages:
- g++-4.4
- os: linux
env: TOOLSET=gcc-4.6 CXXSTD=03,0x
addons:
apt:
packages:
- g++-4.6
- os: linux
env: TOOLSET=gcc-4.7 CXXSTD=03,11
addons:
@ -162,17 +153,6 @@ matrix:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
- os: linux
env: TOOLSET=clang-5.0 CXXSTD=03,11,14,1z,2a
addons:
apt:
packages:
- clang-5.0
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-5.0
- os: osx
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z

View File

@ -7,35 +7,25 @@ version: 1.0.{build}-{branch}
shallow_clone: true
branches:
only:
- master
- develop
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
TOOLSET: msvc-9.0
CXXSTD: latest # fake
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
TOOLSET: msvc-10.0
CXXSTD: latest # fake
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
TOOLSET: msvc-11.0
CXXSTD: latest # fake
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
TOOLSET: msvc-12.0
CXXSTD: latest # fake
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-14.0
CXXSTD: 14
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-14.0
CXXSTD: latest
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
CXXSTD: 14
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
CXXSTD: 17
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
CXXSTD: latest
install:
- set BOOST_BRANCH=develop
@ -82,4 +72,4 @@ install:
build: off
test_script:
- b2 -j%NUMBER_OF_PROCESSORS% --hash libs/fusion/test toolset=%TOOLSET% cxxstd=%CXXSTD%
- b2 -j%NUMBER_OF_PROCESSORS% --hash libs/fusion/test toolset=%TOOLSET%

View File

@ -30,7 +30,7 @@ namespace detail
template <typename First, typename Last, typename F>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline void
for_each_linear(First const& first, Last const& last, F& f, mpl::false_)
for_each_linear(First const& first, Last const& last, F const& f, mpl::false_)
{
f(*first);
detail::for_each_linear(fusion::next(first), last, f,
@ -41,7 +41,7 @@ namespace detail
template <typename Sequence, typename F, typename Tag>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline void
for_each_dispatch(Sequence& seq, F& f, Tag)
for_each_dispatch(Sequence& seq, F const& f, Tag)
{
detail::for_each_linear(
fusion::begin(seq)
@ -57,7 +57,7 @@ namespace detail
{
template<typename I0, typename F>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static void call(I0 const& i0, F& f)
static void call(I0 const& i0, F const& f)
{
f(*i0);
typedef typename result_of::next<I0>::type I1;
@ -78,7 +78,7 @@ namespace detail
{
template<typename I0, typename F>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static void call(I0 const& i0, F& f)
static void call(I0 const& i0, F const& f)
{
f(*i0);
typedef typename result_of::next<I0>::type I1;
@ -95,7 +95,7 @@ namespace detail
{
template<typename I0, typename F>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static void call(I0 const& i0, F& f)
static void call(I0 const& i0, F const& f)
{
f(*i0);
typedef typename result_of::next<I0>::type I1;
@ -109,7 +109,7 @@ namespace detail
{
template<typename I0, typename F>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static void call(I0 const& i0, F& f)
static void call(I0 const& i0, F const& f)
{
f(*i0);
}
@ -128,7 +128,7 @@ namespace detail
template <typename Sequence, typename F>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline void
for_each_dispatch(Sequence& seq, F& f, random_access_traversal_tag)
for_each_dispatch(Sequence& seq, F const& f, random_access_traversal_tag)
{
typedef typename result_of::begin<Sequence>::type begin;
typedef typename result_of::end<Sequence>::type end;
@ -138,7 +138,7 @@ namespace detail
template <typename Sequence, typename F>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline void
for_each(Sequence& seq, F& f, mpl::false_) // unsegmented implementation
for_each(Sequence& seq, F const& f, mpl::false_) // unsegmented implementation
{
detail::for_each_dispatch(seq, f, typename traits::category_of<Sequence>::type());
}

View File

@ -19,11 +19,11 @@ namespace boost { namespace fusion { namespace detail
struct segmented_for_each_fun
{
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
explicit segmented_for_each_fun(Fun& f)
explicit segmented_for_each_fun(Fun const& f)
: fun(f)
{}
Fun& fun;
Fun const& fun;
template <typename Sequence, typename State, typename Context>
struct apply
@ -43,7 +43,7 @@ namespace boost { namespace fusion { namespace detail
template <typename Sequence, typename F>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline void
for_each(Sequence& seq, F& f, mpl::true_) // segmented implementation
for_each(Sequence& seq, F const& f, mpl::true_) // segmented implementation
{
fusion::segmented_fold_until(seq, void_(), segmented_for_each_fun<F>(f));
}

View File

@ -1,7 +1,6 @@
/*=============================================================================
Copyright (c) 2001-2007 Joel de Guzman
Copyright (c) 2007 Dan Marsden
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)
@ -14,7 +13,7 @@
#include <boost/fusion/algorithm/iteration/detail/segmented_for_each.hpp>
#include <boost/fusion/support/is_segmented.hpp>
#include <boost/fusion/support/is_sequence.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/utility/enable_if.hpp>
namespace boost { namespace fusion
{
@ -29,16 +28,24 @@ namespace boost { namespace fusion
template <typename Sequence, typename F>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename enable_if<traits::is_sequence<Sequence> >::type
for_each(Sequence& seq, F f)
inline typename
enable_if<
traits::is_sequence<Sequence>
, void
>::type
for_each(Sequence& seq, F const& f)
{
detail::for_each(seq, f, typename traits::is_segmented<Sequence>::type());
}
template <typename Sequence, typename F>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename enable_if<traits::is_sequence<Sequence> >::type
for_each(Sequence const& seq, F f)
inline typename
enable_if<
traits::is_sequence<Sequence>
, void
>::type
for_each(Sequence const& seq, F const& f)
{
detail::for_each(seq, f, typename traits::is_segmented<Sequence>::type());
}

View File

@ -1,6 +1,5 @@
/*=============================================================================
Copyright (c) 2011 Eric Niebler
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)
@ -10,7 +9,7 @@
#include <boost/fusion/support/config.hpp>
#include <boost/fusion/support/is_sequence.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/utility/enable_if.hpp>
namespace boost { namespace fusion
{
@ -22,13 +21,21 @@ namespace boost { namespace fusion
template <typename Sequence, typename F>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename enable_if<traits::is_sequence<Sequence> >::type
for_each(Sequence& seq, F f);
inline typename
enable_if<
traits::is_sequence<Sequence>
, void
>::type
for_each(Sequence& seq, F const& f);
template <typename Sequence, typename F>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename enable_if<traits::is_sequence<Sequence> >::type
for_each(Sequence const& seq, F f);
inline typename
enable_if<
traits::is_sequence<Sequence>
, void
>::type
for_each(Sequence const& seq, F const& f);
}}
#endif

View File

@ -13,11 +13,6 @@
#include <boost/fusion/iterator/deref.hpp>
#include <boost/fusion/iterator/next.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && BOOST_WORKAROUND(BOOST_GCC, / 100 == 404)
#include <boost/core/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>
#endif
namespace boost { namespace fusion
{
struct fusion_sequence_tag;
@ -119,13 +114,8 @@ namespace boost { namespace fusion { namespace detail
{}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#if BOOST_WORKAROUND(BOOST_GCC, / 100 == 404)
template <typename Value_, typename = typename enable_if<is_same<Value_, Value> >::type>
#else
typedef Value Value_;
#endif
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
keyed_element(Value_&& value, Rest&& rest)
keyed_element(Value&& value, Rest&& rest)
: Rest(std::move(rest))
, value_(BOOST_FUSION_FWD_ELEM(Value, value))
{}

View File

@ -70,10 +70,6 @@ namespace boost { namespace fusion
cons(cons<Car2, Cdr2> const& rhs)
: car(rhs.car), cdr(rhs.cdr) {}
#if BOOST_WORKAROUND(BOOST_GCC, / 100 == 406) && !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
// Workaround for `array used as initializer` compile error on gcc 4.6 w/ c++0x.
template <typename = void>
#endif
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
cons(cons const& rhs)
: car(rhs.car), cdr(rhs.cdr) {}

View File

@ -125,7 +125,11 @@ namespace boost { namespace fusion { namespace detail
}
BOOST_FUSION_GPU_ENABLED
mpl::identity<value_type> get_val(mpl::identity<key_type>) const;
value_type get_val(mpl::identity<key_type>);
BOOST_FUSION_GPU_ENABLED
pair_type get_val(mpl::int_<index>);
BOOST_FUSION_GPU_ENABLED
value_type get_val(mpl::identity<key_type>) const;
BOOST_FUSION_GPU_ENABLED
pair_type get_val(mpl::int_<index>) const;

View File

@ -1,6 +1,5 @@
/*=============================================================================
Copyright (c) 2001-2013 Joel de Guzman
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)
@ -9,6 +8,10 @@
#define BOOST_FUSION_MAP_DETAIL_VALUE_AT_KEY_IMPL_02042013_0821
#include <boost/fusion/support/config.hpp>
#include <boost/fusion/support/detail/access.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/utility/declval.hpp>
namespace boost { namespace fusion
@ -26,9 +29,9 @@ namespace boost { namespace fusion
template <typename Sequence, typename Key>
struct apply
{
typedef typename BOOST_FUSION_IDENTIFIED_TYPE((
boost::declval<Sequence>().get_val(mpl::identity<Key>())
)) type;
typedef
decltype(boost::declval<Sequence>().get_val(mpl::identity<Key>()))
type;
};
};
}

View File

@ -1,5 +1,5 @@
/*=============================================================================
Copyright (c) 2014,2018 Kohei Takahashi
Copyright (c) 2014 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)
@ -7,6 +7,7 @@
#ifndef FUSION_VALUE_AT_IMPL_16122014_1641
#define FUSION_VALUE_AT_IMPL_16122014_1641
#include <boost/config.hpp>
#include <boost/fusion/support/config.hpp>
#include <boost/fusion/container/vector/detail/config.hpp>
@ -22,7 +23,6 @@
///////////////////////////////////////////////////////////////////////////////
#include <boost/fusion/container/vector/vector_fwd.hpp>
#include <boost/type_traits/declval.hpp>
#include <boost/mpl/identity.hpp>
namespace boost { namespace fusion
{
@ -35,7 +35,7 @@ namespace boost { namespace fusion
template <std::size_t N, typename U>
static inline BOOST_FUSION_GPU_ENABLED
mpl::identity<U> value_at_impl(store<N, U> const volatile*);
U value_at_impl(store<N, U> const volatile*);
}
namespace extension
@ -49,9 +49,9 @@ namespace boost { namespace fusion
template <typename Sequence, typename N>
struct apply
{
typedef typename BOOST_FUSION_IDENTIFIED_TYPE((
vector_detail::value_at_impl<N::value>(boost::declval<Sequence*>())
)) type;
typedef
decltype(vector_detail::value_at_impl<N::value>(boost::declval<Sequence*>()))
type;
};
};
}

View File

@ -1,6 +1,6 @@
/*=============================================================================
Copyright (c) 2014 Eric Niebler
Copyright (c) 2014,2015,2018 Kohei Takahashi
Copyright (c) 2014 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)
@ -96,24 +96,4 @@ namespace std
#define BOOST_FUSION_CONSTEXPR_THIS BOOST_CONSTEXPR
#endif
// Workaround for compiler which doesn't compile decltype(expr)::type.
// It expects decltype(expr) deduced as mpl::identity<T>.
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1913)) || BOOST_WORKAROUND(BOOST_GCC, < 40700)
# include <boost/mpl/identity.hpp>
# define BOOST_FUSION_IDENTIFIED_TYPE(parenthesized_expr) \
boost::mpl::identity<decltype parenthesized_expr>::type::type
#else
# define BOOST_FUSION_IDENTIFIED_TYPE(parenthesized_expr) \
decltype parenthesized_expr ::type
#endif
// Workaround for GCC 4.6 that rejects defaulted function with noexcept.
#if BOOST_WORKAROUND(BOOST_GCC, / 100 == 406)
# define BOOST_FUSION_NOEXCEPT_ON_DEFAULTED
#else
# define BOOST_FUSION_NOEXCEPT_ON_DEFAULTED BOOST_NOEXCEPT
#endif
#endif

View File

@ -1,6 +1,5 @@
/*=============================================================================
Copyright (c) 2016 Lee Clagett
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)
@ -9,7 +8,6 @@
#define FUSION_AND_07152016_1625
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <boost/type_traits/integral_constant.hpp>
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
@ -17,8 +15,7 @@
#endif
namespace boost { namespace fusion { namespace detail {
#if defined(BOOST_NO_CXX17_FOLD_EXPRESSIONS) \
|| BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1913))
#if defined(BOOST_NO_CXX17_FOLD_EXPRESSIONS)
template<typename ...Cond>
struct and_impl : false_type {};

View File

@ -8,15 +8,16 @@
#if !defined(FUSION_PAIR_07222005_1203)
#define FUSION_PAIR_07222005_1203
#include <boost/fusion/support/config.hpp>
#include <iosfwd>
#include <utility>
#include <boost/fusion/support/config.hpp>
#include <boost/fusion/support/detail/access.hpp>
#include <boost/fusion/support/detail/as_fusion_element.hpp>
#include <boost/config.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/fusion/support/detail/enabler.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/is_lvalue_reference.hpp>
#include <boost/type_traits/remove_cv_ref.hpp>
#if defined (BOOST_MSVC)
# pragma warning(push)
@ -33,54 +34,46 @@ namespace boost { namespace fusion
pair()
: second() {}
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
pair(pair const& rhs)
: second(rhs.second) {}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
pair(pair&& rhs)
: second(BOOST_FUSION_FWD_ELEM(Second, rhs.second)) {}
#endif
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
pair(typename detail::call_param<Second>::type val)
: second(val) {}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
template <typename Second2>
BOOST_FUSION_GPU_ENABLED
pair(Second2&& val
, typename boost::disable_if<is_lvalue_reference<Second2> >::type* /* dummy */ = 0
, typename boost::enable_if<is_convertible<Second2, Second> >::type* /*dummy*/ = 0
) : second(BOOST_FUSION_FWD_ELEM(Second, val)) {}
pair(typename remove_cv_ref<Second>::type&& val)
: second(BOOST_FUSION_FWD_ELEM(Second, val)) {}
#endif
template <typename Second2>
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
pair(pair<First, Second2> const& rhs)
pair(pair<First, Second2> const& rhs,
typename disable_if<is_same<Second, Second2>, detail::enabler_>::type = detail::enabler,
typename enable_if<is_convertible<Second2, Second>, detail::enabler_>::type = detail::enabler)
: second(rhs.second) {}
template <typename Second2>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
pair& operator=(pair<First, Second2> const& rhs)
{
second = rhs.second;
return *this;
}
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
pair& operator=(pair const& rhs)
typename disable_if<is_same<Second, Second2>, pair&>::type
operator=(pair<First, Second2> const& rhs)
{
second = rhs.second;
return *this;
}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
template <typename Second2>
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
pair(pair<First, Second2>&& rhs,
typename disable_if<is_same<Second, Second2>, detail::enabler_>::type = detail::enabler,
typename enable_if<is_convertible<Second2, Second>, detail::enabler_>::type = detail::enabler)
: second(std::move(rhs.second)) {}
template <typename Second2>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
pair& operator=(pair&& rhs)
typename disable_if<is_same<Second, Second2>, pair&>::type
operator=(pair<First, Second2>&& rhs)
{
second = BOOST_FUSION_FWD_ELEM(Second, rhs.second);
second = std::move(rhs.second);
return *this;
}
#endif

View File

@ -1,6 +1,5 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
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)
@ -11,6 +10,7 @@
#include <boost/fusion/support/config.hpp>
#include <iosfwd>
#include <boost/config.hpp>
#if defined(BOOST_MSVC)
# pragma warning(push)
# pragma warning(disable: 4522) // multiple assignment operators specified warning
@ -23,16 +23,9 @@ namespace boost { namespace fusion
struct unused_type
{
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
BOOST_DEFAULTED_FUNCTION(
unused_type() BOOST_FUSION_NOEXCEPT_ON_DEFAULTED,
unused_type() BOOST_NOEXCEPT
{
})
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
BOOST_DEFAULTED_FUNCTION(
unused_type(unused_type const&) BOOST_FUSION_NOEXCEPT_ON_DEFAULTED,
{
})
}
template <typename T>
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
@ -40,12 +33,35 @@ namespace boost { namespace fusion
{
}
template <typename T>
BOOST_FUSION_CONSTEXPR_THIS BOOST_FUSION_GPU_ENABLED
unused_type const&
operator=(T const&) const BOOST_NOEXCEPT
{
return *this;
}
template <typename T>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
unused_type&
operator=(T const&) BOOST_NOEXCEPT
{
return *this;
}
BOOST_FUSION_CONSTEXPR_THIS BOOST_FUSION_GPU_ENABLED
unused_type const&
operator=(unused_type const&) const BOOST_NOEXCEPT
{
return *this;
}
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
unused_type&
operator=(unused_type const&) BOOST_NOEXCEPT
{
return *this;
}
};
BOOST_CONSTEXPR_OR_CONST unused_type unused = unused_type();

View File

@ -9,8 +9,8 @@
<toolset name="msvc-11.0"/>
<toolset name="msvc-12.0"/>
<toolset name="qcc-4.4.2_x86"/>
<toolset name="gcc-4.4~c++0x*"/>
<toolset name="gcc-4.4~gnu0x*"/>
<toolset name="gcc-gnu-4.4~c++0x*"/>
<toolset name="gcc-gnu-4.4~gnu0x*"/>
<note author="Kohei Takahashi">
The compiler doesn't generate defaulted move ctor/assgin thus
perform copy construction/assginment. Even though such case,

View File

@ -237,7 +237,6 @@ project
[ run sequence/ref_vector.cpp ]
[ run sequence/flatten_view.cpp ]
[ compile sequence/github-159.cpp ]
[ run sequence/github-176.cpp ]
[ compile sequence/size.cpp ]
@ -256,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 ]
@ -267,7 +267,8 @@ project
[ compile support/and.cpp
: [ requires cxx11_variadic_templates ] ]
[ compile support/tag_of.cpp ]
[ compile support/unused.cpp ]
[ compile support/pair_trivially_copyable.cpp
: [ requires cxx11_hdr_type_traits ] ]
# [ compile-fail xxx.cpp ]

View File

@ -1,12 +1,11 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2007 Dan Marsden
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 <boost/core/lightweight_test.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/algorithm/query/all.hpp>
@ -29,19 +28,6 @@ namespace
int search;
};
struct mutable_search_for : search_for
{
explicit mutable_search_for(int in_search)
: search_for(in_search)
{}
template <typename T>
bool operator()(T const& v)
{
return search_for::operator()(v);
}
};
}
int
@ -72,20 +58,11 @@ main()
}
{
boost::fusion::vector<int, short, double> t(1, 2, 3.3);
BOOST_TEST(!boost::fusion::all(t, search_for(1)));
BOOST_TEST(!boost::fusion::all(t, mutable_search_for(1)));
}
{
typedef boost::mpl::vector_c<int, 1, 1, 1> mpl_vec;
typedef boost::mpl::vector_c<int, 1> mpl_vec;
// We cannot use lambda here as mpl vec iterators return
// rvalues, and lambda needs lvalues.
BOOST_TEST(boost::fusion::all(mpl_vec(), search_for(1)));
BOOST_TEST(!boost::fusion::all(mpl_vec(), search_for(2)));
BOOST_TEST(boost::fusion::all(mpl_vec(), mutable_search_for(1)));
BOOST_TEST(!boost::fusion::all(mpl_vec(), mutable_search_for(2)));
}
return boost::report_errors();

View File

@ -2,12 +2,11 @@
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005 Eric Niebler
Copyright (c) Dan Marsden
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 <boost/core/lightweight_test.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/algorithm/query/any.hpp>
@ -30,19 +29,6 @@ namespace
int search;
};
struct mutable_search_for : search_for
{
explicit mutable_search_for(int in_search)
: search_for(in_search)
{}
template <typename T>
bool operator()(T const& v)
{
return search_for::operator()(v);
}
};
}
int
@ -58,21 +44,12 @@ main()
BOOST_TEST(!boost::fusion::any(t, boost::lambda::_1 == 3));
}
{
boost::fusion::vector<int, short, double> t(1, 2, 3.3);
BOOST_TEST(boost::fusion::any(t, search_for(1)));
BOOST_TEST(boost::fusion::any(t, mutable_search_for(1)));
}
{
typedef boost::mpl::vector_c<int, 1, 2, 3> mpl_vec;
// We cannot use lambda here as mpl vec iterators return
// rvalues, and lambda needs lvalues.
BOOST_TEST(boost::fusion::any(mpl_vec(), search_for(2)));
BOOST_TEST(!boost::fusion::any(mpl_vec(), search_for(4)));
BOOST_TEST(boost::fusion::any(mpl_vec(), mutable_search_for(2)));
BOOST_TEST(!boost::fusion::any(mpl_vec(), mutable_search_for(4)));
}
return boost::report_errors();

View File

@ -1,12 +1,11 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005 Eric Niebler
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 <boost/core/lightweight_test.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/algorithm/query/count_if.hpp>
@ -19,29 +18,20 @@ struct bind1st<F<T> > : public F<T>
{
T n;
bind1st(T n) : n(n) { }
bool operator()(T v) { return F<T>::operator()(n, v); }
bool operator()(T v) const { return F<T>::operator()(n, v); }
};
template <typename T>
struct mutable_equal_to : std::equal_to<T>
{
bool operator()(T l, T r) { return std::equal_to<T>::operator()(l, r); }
};
int
main()
{
{
boost::fusion::vector<int, short, double> t(1, 2, 3.3);
BOOST_TEST(boost::fusion::count_if(t, bind1st<std::equal_to<double> >(2)) == 1);
BOOST_TEST(boost::fusion::count_if(t, bind1st<mutable_equal_to<double> >(2)) == 1);
}
{
boost::fusion::vector<int, short, double> t(1, 2, 3.3);
BOOST_TEST(boost::fusion::count_if(t, bind1st<std::equal_to<double> >(3)) == 0);
BOOST_TEST(boost::fusion::count_if(t, bind1st<mutable_equal_to<double> >(3)) == 0);
}
{
@ -49,7 +39,6 @@ main()
// Cannot use lambda here as mpl iterators return rvalues and lambda needs lvalues
BOOST_TEST(boost::fusion::count_if(mpl_vec(), bind1st<std::greater_equal<int> >(2)) == 2);
BOOST_TEST(boost::fusion::count_if(mpl_vec(), bind1st<std::less<int> >(2)) == 1);
BOOST_TEST(boost::fusion::count_if(mpl_vec(), bind1st<mutable_equal_to<int> >(2)) == 1);
}
return boost::report_errors();

View File

@ -1,25 +1,27 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2007 Dan Marsden
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 <boost/core/lightweight_test.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/algorithm/iteration/accumulate.hpp>
#include <boost/fusion/algorithm/iteration/fold.hpp>
#include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/next.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/fusion/algorithm/iteration/fold.hpp>
#include <boost/fusion/algorithm/iteration/accumulate.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/next.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/type_traits/is_reference.hpp>
#include <string>
@ -128,7 +130,7 @@ struct functor
}
};
struct mutable_visitor
struct visitor
{
typedef int result_type;
@ -246,7 +248,7 @@ main()
{
boost::fusion::vector<long> vec;
mutable_visitor v;
visitor v;
boost::fusion::fold(vec, 0, v);
}
}

View File

@ -1,15 +1,13 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
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 <boost/core/lightweight_test.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/algorithm/iteration/for_each.hpp>
#include <boost/mpl/vector_c.hpp>
@ -31,15 +29,6 @@ struct increment
}
};
struct mutable_increment : increment
{
template <typename T>
void operator()(T& v)
{
return increment::operator()(v);
}
};
int
main()
{
@ -55,20 +44,9 @@ main()
}
{
char const ruby[] = "Ruby";
typedef vector<int, char, double, char const*> vector_type;
vector_type v(1, 'x', 3.3, ruby);
vector_type v(1, 'x', 3.3, "Ruby");
for_each(v, increment());
BOOST_TEST_EQ(v, vector_type(2, 'y', 4.3, ruby + 1));
std::cout << v << std::endl;
}
{
char const ruby[] = "Ruby";
typedef vector<int, char, double, char const*> vector_type;
vector_type v(1, 'x', 3.3, ruby);
for_each(v, mutable_increment());
BOOST_TEST_EQ(v, vector_type(2, 'y', 4.3, ruby + 1));
std::cout << v << std::endl;
}

View File

@ -1,12 +1,11 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2007 Dan Marsden
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 <boost/core/lightweight_test.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/algorithm/query/none.hpp>
@ -29,19 +28,6 @@ namespace
int search;
};
struct mutable_search_for : search_for
{
explicit mutable_search_for(int in_search)
: search_for(in_search)
{}
template <typename T>
bool operator()(T const& v)
{
return search_for::operator()(v);
}
};
}
int
@ -59,24 +45,12 @@ main()
BOOST_TEST((!boost::fusion::none(t, boost::lambda::_1 < 3)));
}
{
boost::fusion::vector<int, short, double> t(1, 2, 3.3);
BOOST_TEST(!boost::fusion::none(t, search_for(1)));
BOOST_TEST(boost::fusion::none(t, search_for(3)));
BOOST_TEST(!boost::fusion::none(t, mutable_search_for(1)));
BOOST_TEST(boost::fusion::none(t, mutable_search_for(3)));
}
{
typedef boost::mpl::vector_c<int, 1, 2, 3> mpl_vec;
// We cannot use lambda here as mpl vec iterators return
// rvalues, and lambda needs lvalues.
BOOST_TEST(boost::fusion::none(mpl_vec(), search_for(4)));
BOOST_TEST(!boost::fusion::none(mpl_vec(), search_for(3)));
BOOST_TEST(boost::fusion::none(mpl_vec(), mutable_search_for(4)));
BOOST_TEST(!boost::fusion::none(mpl_vec(), mutable_search_for(3)));
}
return boost::report_errors();

View File

@ -1,16 +1,19 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
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 <boost/core/lightweight_test.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/fusion/algorithm/transformation/replace_if.hpp>
#include <string>
struct gt3
{
@ -21,15 +24,6 @@ struct gt3
}
};
struct mutable_gt3 : gt3
{
template <typename T>
bool operator()(T x)
{
return gt3::operator()(x);
}
};
int
main()
{
@ -48,18 +42,8 @@ main()
{
std::cout << replace_if(t1, gt3(), -456) << std::endl;
BOOST_TEST_EQ(replace_if(t1, gt3(), -456), make_vector(1, 2, -456, -456, s, -456));
}
}
{
char const* s = "Ruby";
typedef vector<int, short, double, long, char const*, float> vector_type;
vector_type t1(1, 2, 3.3, 4, s, 5.5f);
{
std::cout << replace_if(t1, mutable_gt3(), -456) << std::endl;
BOOST_TEST_EQ(replace_if(t1, mutable_gt3(), -456), make_vector(1, 2, -456, -456, s, -456));
BOOST_TEST((replace_if(t1, gt3(), -456)
== make_vector(1, 2, -456, -456, s, -456)));
}
}

View File

@ -1,17 +1,14 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2011 Eric Niebler
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 <boost/core/lightweight_test.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/fusion/algorithm/iteration/for_each.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/container/generation/make_vector.hpp>
#include "../sequence/tree.hpp"
struct print
@ -23,31 +20,6 @@ struct print
}
};
struct increment
{
template <typename T>
void operator()(T& v) const
{
++v;
}
};
struct mutable_increment : increment
{
template <typename T>
void operator()(T& v)
{
return increment::operator()(v);
}
};
template <typename F, typename Tree>
void test(Tree tree, Tree const& expected)
{
boost::fusion::for_each(tree, F());
BOOST_TEST_EQ(tree, expected);
}
int
main()
{
@ -70,69 +42,6 @@ main()
)
, print()
);
std::cout << std::endl;
}
{
test<increment>(
make_tree(
make_vector(double(0),'B')
, make_tree(
make_vector(1,2,long(3))
, make_tree(make_vector('a','b','c'))
, make_tree(make_vector(short('d'),'e','f'))
)
, make_tree(
make_vector(4,5,6)
, make_tree(make_vector(float(1),'h','i'))
, make_tree(make_vector('j','k','l'))
)
)
, make_tree(
make_vector(double(1),'C')
, make_tree(
make_vector(2,3,long(4))
, make_tree(make_vector('b','c','d'))
, make_tree(make_vector(short('e'),'f','g'))
)
, make_tree(
make_vector(5,6,7)
, make_tree(make_vector(float(2),'i','j'))
, make_tree(make_vector('k','l','m'))
)
)
);
}
{
test<mutable_increment>(
make_tree(
make_vector(double(0),'B')
, make_tree(
make_vector(1,2,long(3))
, make_tree(make_vector('a','b','c'))
, make_tree(make_vector(short('d'),'e','f'))
)
, make_tree(
make_vector(4,5,6)
, make_tree(make_vector(float(1),'h','i'))
, make_tree(make_vector('j','k','l'))
)
)
, make_tree(
make_vector(double(1),'C')
, make_tree(
make_vector(2,3,long(4))
, make_tree(make_vector('b','c','d'))
, make_tree(make_vector(short('e'),'f','g'))
)
, make_tree(
make_vector(5,6,7)
, make_tree(make_vector(float(2),'i','j'))
, make_tree(make_vector('k','l','m'))
)
)
);
}
return boost::report_errors();

View File

@ -47,8 +47,8 @@ int main()
BOOST_TEST(y.w.value == 42);
}
// Older MSVCs and gcc 4.4 don't generate move ctor by default.
#if !(defined(CI_SKIP_KNOWN_FAILURE) && (BOOST_WORKAROUND(BOOST_MSVC, < 1900) || BOOST_WORKAROUND(BOOST_GCC, / 100 == 404)))
// Older MSVCs don't generate move ctor by default.
#if !(defined(CI_SKIP_KNOWN_FAILURE) && BOOST_WORKAROUND(BOOST_MSVC, < 1900))
{
ns::value x;
ns::value y(std::move(x)); // move
@ -66,7 +66,7 @@ int main()
BOOST_TEST(x.w.value == 0);
BOOST_TEST(y.w.value == 0);
}
#endif // !(ci && (msvc < 14.0 || gcc 4.4.x))
#endif // !(ci && msvc < 14.0)
return boost::report_errors();
}

View File

@ -47,8 +47,8 @@ int main()
BOOST_TEST(y.w.value == 42);
}
// Older MSVCs and gcc 4.4 don't generate move ctor by default.
#if !(defined(CI_SKIP_KNOWN_FAILURE) && (BOOST_WORKAROUND(BOOST_MSVC, < 1900) || BOOST_WORKAROUND(BOOST_GCC, / 100 == 404)))
// Older MSVCs don't generate move ctor by default.
#if !(defined(CI_SKIP_KNOWN_FAILURE) && BOOST_WORKAROUND(BOOST_MSVC, < 1900))
{
ns::value<wrapper> x;
ns::value<wrapper> y(std::move(x)); // move
@ -66,7 +66,7 @@ int main()
BOOST_TEST(x.w.value == 0);
BOOST_TEST(y.w.value == 0);
}
#endif // !(ci && (msvc < 14.0 || gcc 4.4.x))
#endif // !(ci && msvc < 14.0)
return boost::report_errors();
}

View File

@ -1,89 +0,0 @@
/*=============================================================================
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 <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/sequence/intrinsic/at_key.hpp>
#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/container/list.hpp>
#include <boost/fusion/container/deque.hpp>
#include <boost/fusion/container/map.hpp>
#include <boost/fusion/container/set.hpp>
#include <boost/fusion/tuple/tuple.hpp>
#include <boost/core/lightweight_test.hpp>
template <typename Sequence>
void test_at()
{
Sequence seq;
// zero initialized
BOOST_TEST(boost::fusion::at_c<0>(seq)[0] == 0);
BOOST_TEST(boost::fusion::at_c<0>(seq)[1] == 0);
BOOST_TEST(boost::fusion::at_c<0>(seq)[2] == 0);
int (&arr)[3] = boost::fusion::deref(boost::fusion::begin(seq));
arr[0] = 2;
arr[1] = 4;
arr[2] = 6;
BOOST_TEST(boost::fusion::at_c<0>(seq)[0] == 2);
BOOST_TEST(boost::fusion::at_c<0>(seq)[1] == 4);
BOOST_TEST(boost::fusion::at_c<0>(seq)[2] == 6);
boost::fusion::at_c<0>(seq)[1] = 42;
BOOST_TEST(boost::fusion::at_c<0>(seq)[0] == 2);
BOOST_TEST(boost::fusion::at_c<0>(seq)[1] == 42);
BOOST_TEST(boost::fusion::at_c<0>(seq)[2] == 6);
}
template <typename T> inline T& value(T& v) { return v; }
template <typename K, typename T> inline T& value(boost::fusion::pair<K, T>& v) { return v.second; }
template <typename Sequence>
void test_at_key()
{
Sequence seq;
// zero initialized
BOOST_TEST(boost::fusion::at_key<int[3]>(seq)[0] == 0);
BOOST_TEST(boost::fusion::at_key<int[3]>(seq)[1] == 0);
BOOST_TEST(boost::fusion::at_key<int[3]>(seq)[2] == 0);
int (&arr)[3] = value(boost::fusion::deref(boost::fusion::begin(seq)));
arr[0] = 2;
arr[1] = 4;
arr[2] = 6;
BOOST_TEST(boost::fusion::at_key<int[3]>(seq)[0] == 2);
BOOST_TEST(boost::fusion::at_key<int[3]>(seq)[1] == 4);
BOOST_TEST(boost::fusion::at_key<int[3]>(seq)[2] == 6);
boost::fusion::at_key<int[3]>(seq)[1] = 42;
BOOST_TEST(boost::fusion::at_key<int[3]>(seq)[0] == 2);
BOOST_TEST(boost::fusion::at_key<int[3]>(seq)[1] == 42);
BOOST_TEST(boost::fusion::at_key<int[3]>(seq)[2] == 6);
}
int main()
{
using namespace boost::fusion;
test_at<vector<int[3]> >();
test_at<deque<int[3]> >();
test_at<list<int[3]> >();
test_at<tuple<int[3]> >();
#if !BOOST_WORKAROUND(BOOST_GCC, / 100 == 406) || defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
// FIXME: gcc 4.6 w/ c++0x doesn't like set with array...
test_at_key<set<int[3]> >();
#endif
test_at_key<map<pair<int[3], int[3]> > >();
}

View File

@ -1,6 +1,5 @@
/*=============================================================================
Copyright (c) 2014 Christoph Weiss
Copyright (c) 2017 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,24 +11,24 @@
#include <boost/fusion/sequence/hash.hpp>
#include <boost/functional/hash.hpp>
void hash_test()
void
hash_test()
{
namespace fusion = boost::fusion;
using namespace fusion;
using namespace boost::fusion;
const FUSION_SEQUENCE<int, char, bool, std::string> v0(42, 'x', false, "Aurea prima");
const FUSION_SEQUENCE<int, char, bool, std::string> v1(42, 'x', false, "Aurea prima");
BOOST_TEST(fusion::hash_value(v0) == fusion::hash_value(v1));
BOOST_TEST(hash_value(v0) == hash_value(v1));
const FUSION_SEQUENCE<int, char, bool, std::string> w(41, 'x', false, "Aurea prima");
BOOST_TEST(fusion::hash_value(w) != fusion::hash_value(v0));
BOOST_TEST(hash_value(w) != hash_value(v0));
const FUSION_SEQUENCE<int, char, bool, std::string> x(42, 'y', false, "Aurea prima");
BOOST_TEST(fusion::hash_value(x) != fusion::hash_value(v0));
BOOST_TEST(hash_value(x) != hash_value(v0));
const FUSION_SEQUENCE<int, char, bool, std::string> y(42, 'x', true, "Aurea prima");
BOOST_TEST(fusion::hash_value(y) != fusion::hash_value(v0));
BOOST_TEST(hash_value(y) != hash_value(v0));
const FUSION_SEQUENCE<int, char, bool, std::string> z(42, 'x', false, "quae vindice nullo");
BOOST_TEST(fusion::hash_value(z) != fusion::hash_value(v0));
BOOST_TEST(hash_value(z) != hash_value(v0));
}

View File

@ -1,6 +1,5 @@
/*=============================================================================
Copyright (C) 2016 Lee Clagett
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)
@ -39,7 +38,9 @@ bool is_convertible(bool has_conversion)
}
// is_constructible has a few requirements
#ifdef BOOST_TT_IS_CONSTRUCTIBLE_CONFORMING
#if !defined(BOOST_NO_CXX11_DECLTYPE) && \
!defined(BOOST_NO_CXX11_TEMPLATES) && \
!defined(BOOST_NO_SFINAE_EXPR)
#define FUSION_TEST_HAS_CONSTRUCTIBLE
@ -87,9 +88,7 @@ void test_constructible()
BOOST_TEST((
is_constructible<FUSION_SEQUENCE<convertible>, convertible>(true)
));
// boost::is_constructible always fail to test ctor which takes 2 or more arguments on GCC 4.7.
#if !BOOST_WORKAROUND(BOOST_GCC, < 40700)
BOOST_TEST((
is_constructible<FUSION_SEQUENCE<int, int>, int, int>(true)
));
@ -132,7 +131,6 @@ void test_constructible()
FUSION_SEQUENCE<convertible, convertible>, convertible, convertible
>(true)
));
#endif // !(gcc < 4.7)
}
#endif // is_constructible is available

View File

@ -65,13 +65,10 @@ main()
BOOST_TEST((is_constructible<tuple<int>, int, int>(false)));
BOOST_TEST((is_constructible< tuple<int, int> >(true)));
// boost::is_constructible always fail to test ctor which takes 2 or more arguments on GCC 4.7.
#if !BOOST_WORKAROUND(BOOST_GCC, < 40700)
BOOST_TEST((is_constructible<tuple<int, int>, int, int>(true)));
BOOST_TEST((
is_constructible<tuple<convertible, convertible>, int, int>(true)
));
#endif // !(gcc < 4.7)
BOOST_TEST((is_constructible<tuple<int, not_convertible>, int, int>(false)));
BOOST_TEST((is_constructible<tuple<not_convertible, int>, int, int>(false)));
BOOST_TEST((

View File

@ -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 <utility>
#include <boost/config.hpp>
#include <boost/fusion/support/pair.hpp>
using namespace boost::fusion;
struct eat_int
{
eat_int(int);
};
struct eat_pair
{
template <typename K, typename V>
eat_pair(pair<K, V>);
};
int main()
{
pair<void, int> p;
pair<void, eat_int> ci(p);
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
pair<void, eat_int> 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<void, eat_pair>).
pair<void, eat_pair> cp(p);
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
pair<void, eat_pair> mp(std::move(p));
#endif
}

View File

@ -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 <typename C>
void copy()
void copy(C value)
{
pair<int, C> src;
pair<int, C> src(value);
pair<int, C> dest = src;
boost::ignore_unused(dest);
}
int main()
{
copy<pair<void, float> >();
copy<pair<void, float> >(42.195f);
copy<pair<int, float> >(42.195f);
float f;
pair<void, float&> r(f);
copy<pair<void, float&> >(r);
}

View File

@ -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 <type_traits>
#include <boost/fusion/support/pair.hpp>
#include <boost/mpl/assert.hpp>
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<void>));
BOOST_MPL_ASSERT((std::is_trivially_copyable<int>));
BOOST_MPL_ASSERT_NOT((std::is_trivially_copyable<non_trivially_copyable>));
BOOST_MPL_ASSERT((std::is_trivially_copyable<pod>));
BOOST_MPL_ASSERT_NOT((std::is_trivially_copyable<int&>));
BOOST_MPL_ASSERT((std::is_trivially_copyable<void*>));
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<void, int> >));
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<int, int> >));
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<non_trivially_copyable, int> >));
BOOST_MPL_ASSERT_NOT((std::is_trivially_copyable<pair<int, non_trivially_copyable> >));
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<pod, int> >));
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<int, pod> >));
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<void, int&> >));
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<int, int&> >));
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<non_trivially_copyable, int&> >));
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<int, non_trivially_copyable&> >));
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<int, pod&> >));
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<int, pod&> >));
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<void, int*> >));
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<int, int*> >));
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<non_trivially_copyable, int*> >));
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<int, non_trivially_copyable*> >));
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<int, pod*> >));
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<int, pod*> >));

View File

@ -1,95 +0,0 @@
/*=============================================================================
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 <boost/config.hpp>
#include <boost/fusion/support/unused.hpp>
#include <boost/type_traits/detail/yes_no_type.hpp>
#include <boost/static_assert.hpp>
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
#include <utility>
#endif
struct T { };
void unused_construction()
{
boost::fusion::unused_type dephault;
boost::fusion::unused_type BOOST_ATTRIBUTE_UNUSED parenthesis = boost::fusion::unused_type();
#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
boost::fusion::unused_type BOOST_ATTRIBUTE_UNUSED brace{};
boost::fusion::unused_type BOOST_ATTRIBUTE_UNUSED list_copy = {};
#endif
boost::fusion::unused_type copy_copy BOOST_ATTRIBUTE_UNUSED = dephault;
boost::fusion::unused_type copy_direct BOOST_ATTRIBUTE_UNUSED (dephault);
#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
boost::fusion::unused_type copy_copy_brace_direct BOOST_ATTRIBUTE_UNUSED = {dephault};
boost::fusion::unused_type copy_direct_brace BOOST_ATTRIBUTE_UNUSED {dephault};
#endif
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
boost::fusion::unused_type move_copy BOOST_ATTRIBUTE_UNUSED = std::move(dephault);
boost::fusion::unused_type move_direct BOOST_ATTRIBUTE_UNUSED (std::move(dephault));
#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
boost::fusion::unused_type move_copy_brace_direct BOOST_ATTRIBUTE_UNUSED = {std::move(dephault)};
boost::fusion::unused_type move_direct_brace BOOST_ATTRIBUTE_UNUSED {std::move(dephault)};
#endif
#endif
T value;
boost::fusion::unused_type T_copy_copy BOOST_ATTRIBUTE_UNUSED = value;
boost::fusion::unused_type T_copy_direct BOOST_ATTRIBUTE_UNUSED (value);
#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
boost::fusion::unused_type T_copy_copy_brace_direct BOOST_ATTRIBUTE_UNUSED = {value};
boost::fusion::unused_type T_copy_direct_brace BOOST_ATTRIBUTE_UNUSED {value};
#endif
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
boost::fusion::unused_type T_move_copy BOOST_ATTRIBUTE_UNUSED = std::move(value);
boost::fusion::unused_type T_move_direct BOOST_ATTRIBUTE_UNUSED (std::move(value));
#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
boost::fusion::unused_type T_move_copy_brace_direct BOOST_ATTRIBUTE_UNUSED = {std::move(value)};
boost::fusion::unused_type T_move_direct_brace BOOST_ATTRIBUTE_UNUSED {std::move(value)};
#endif
#endif
}
void unused_assignment()
{
boost::fusion::unused_type val1, val2;
val1 = val2;
#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
val1 = {};
#endif
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
val1 = std::move(val2);
#endif
T value;
val1 = value;
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
val1 = std::move(value);
#endif
}
boost::type_traits::yes_type test_unused(boost::fusion::detail::unused_only const&);
boost::type_traits::no_type test_unused(...);
void only_unused()
{
BOOST_STATIC_ASSERT((sizeof(test_unused(boost::fusion::unused)) == sizeof(boost::type_traits::yes_type)));
BOOST_STATIC_ASSERT((sizeof(test_unused(0)) == sizeof(boost::type_traits::no_type)));
boost::fusion::unused_type my_unused;
BOOST_STATIC_ASSERT((sizeof(test_unused(my_unused)) == sizeof(boost::type_traits::yes_type)));
}