Merge pull request #141 from boostorg/develop
Boost 1.63.0 beta release
This commit is contained in:
commit
715a7fb729
23
include/boost/fusion/adapted/std_array.hpp
Normal file
23
include/boost/fusion/adapted/std_array.hpp
Normal file
@ -0,0 +1,23 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2013 Mateusz Loskot
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_STD_ARRAY__01062013_1700)
|
||||
#define BOOST_FUSION_STD_ARRAY__01062013_1700
|
||||
|
||||
#include <boost/fusion/adapted/std_array/std_array_iterator.hpp>
|
||||
#include <boost/fusion/adapted/std_array/tag_of.hpp>
|
||||
#include <boost/fusion/adapted/std_array/detail/is_view_impl.hpp>
|
||||
#include <boost/fusion/adapted/std_array/detail/is_sequence_impl.hpp>
|
||||
#include <boost/fusion/adapted/std_array/detail/category_of_impl.hpp>
|
||||
#include <boost/fusion/adapted/std_array/detail/begin_impl.hpp>
|
||||
#include <boost/fusion/adapted/std_array/detail/end_impl.hpp>
|
||||
#include <boost/fusion/adapted/std_array/detail/size_impl.hpp>
|
||||
#include <boost/fusion/adapted/std_array/detail/at_impl.hpp>
|
||||
#include <boost/fusion/adapted/std_array/detail/value_at_impl.hpp>
|
||||
|
||||
#endif
|
25
include/boost/fusion/adapted/std_array/detail/array_size.hpp
Normal file
25
include/boost/fusion/adapted/std_array/detail/array_size.hpp
Normal file
@ -0,0 +1,25 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2013 Mateusz Loskot
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_STD_ARRAY_ARRAY_SIZE_01062013_1700)
|
||||
#define BOOST_FUSION_STD_ARRAY_ARRAY_SIZE_01062013_1700
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace extension
|
||||
{
|
||||
template<class T>
|
||||
struct std_array_size;
|
||||
|
||||
template<template<typename, std::size_t> class Array, typename T, std::size_t N>
|
||||
struct std_array_size<Array<T, N>> : std::integral_constant<std::size_t, N> {};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
45
include/boost/fusion/adapted/std_array/detail/at_impl.hpp
Normal file
45
include/boost/fusion/adapted/std_array/detail/at_impl.hpp
Normal file
@ -0,0 +1,45 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_STD_ARRAY_AT_IMPL_01062013_1700)
|
||||
#define BOOST_FUSION_STD_ARRAY_AT_IMPL_01062013_1700
|
||||
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
|
||||
#include <boost/mpl/if.hpp>
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct std_array_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename T>
|
||||
struct at_impl;
|
||||
|
||||
template<>
|
||||
struct at_impl<std_array_tag>
|
||||
{
|
||||
template<typename Sequence, typename N>
|
||||
struct apply
|
||||
{
|
||||
typedef typename mpl::if_<
|
||||
is_const<Sequence>,
|
||||
typename Sequence::const_reference,
|
||||
typename Sequence::reference>::type type;
|
||||
|
||||
static type
|
||||
call(Sequence& seq)
|
||||
{
|
||||
return seq[N::value];
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
41
include/boost/fusion/adapted/std_array/detail/begin_impl.hpp
Normal file
41
include/boost/fusion/adapted/std_array/detail/begin_impl.hpp
Normal file
@ -0,0 +1,41 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2013 Mateusz Loskot
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_STD_ARRAY_BEGIN_OF_IMPL_01062013_1700)
|
||||
#define BOOST_FUSION_STD_ARRAY_BEGIN_OF_IMPL_01062013_1700
|
||||
|
||||
#include <boost/fusion/adapted/std_array/std_array_iterator.hpp>
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct std_array_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename T>
|
||||
struct begin_impl;
|
||||
|
||||
template <>
|
||||
struct begin_impl<std_array_tag>
|
||||
{
|
||||
template <typename Sequence>
|
||||
struct apply
|
||||
{
|
||||
typedef std_array_iterator<Sequence, 0> type;
|
||||
|
||||
static type
|
||||
call(Sequence& v)
|
||||
{
|
||||
return type(v);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
@ -0,0 +1,35 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_STD_ARRAY_CATEGORY_OF_IMPL_01062013_1700)
|
||||
#define BOOST_FUSION_STD_ARRAY_CATEGORY_OF_IMPL_01062013_1700
|
||||
|
||||
#include <boost/config/no_tr1/utility.hpp>
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct std_array_tag;
|
||||
struct random_access_traversal_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename T>
|
||||
struct category_of_impl;
|
||||
|
||||
template<>
|
||||
struct category_of_impl<std_array_tag>
|
||||
{
|
||||
template<typename T>
|
||||
struct apply
|
||||
{
|
||||
typedef random_access_traversal_tag type;
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
45
include/boost/fusion/adapted/std_array/detail/end_impl.hpp
Normal file
45
include/boost/fusion/adapted/std_array/detail/end_impl.hpp
Normal file
@ -0,0 +1,45 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2013 Mateusz Loskot
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_STD_ARRAY_END_OF_IMPL_01062013_1700)
|
||||
#define BOOST_FUSION_STD_ARRAY_END_OF_IMPL_01062013_1700
|
||||
|
||||
#include <boost/fusion/adapted/std_array/std_array_iterator.hpp>
|
||||
#include <boost/fusion/adapted/std_array/detail/array_size.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct std_array_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct end_impl;
|
||||
|
||||
template <>
|
||||
struct end_impl<std_array_tag>
|
||||
{
|
||||
template <typename Sequence>
|
||||
struct apply
|
||||
{
|
||||
typedef typename remove_const<Sequence>::type seq_type;
|
||||
static int const size = std_array_size<seq_type>::value;
|
||||
typedef std_array_iterator<Sequence, size> type;
|
||||
|
||||
static type
|
||||
call(Sequence& v)
|
||||
{
|
||||
return type(v);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
@ -0,0 +1,32 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2013 Mateusz Loskot
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_STD_ARRAY_IS_SEQUENCE_IMPL_01062013_1700)
|
||||
#define BOOST_FUSION_STD_ARRAY_IS_SEQUENCE_IMPL_01062013_1700
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct std_array_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename Tag>
|
||||
struct is_sequence_impl;
|
||||
|
||||
template<>
|
||||
struct is_sequence_impl<std_array_tag>
|
||||
{
|
||||
template<typename Sequence>
|
||||
struct apply : mpl::true_ {};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
@ -0,0 +1,33 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2013 Mateusz Loskot
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_STD_ARRAY_IS_VIEW_IMPL_01062013_1700)
|
||||
#define BOOST_FUSION_STD_ARRAY_IS_VIEW_IMPL_01062013_1700
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct std_array_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename Tag>
|
||||
struct is_view_impl;
|
||||
|
||||
template<>
|
||||
struct is_view_impl<std_array_tag>
|
||||
{
|
||||
template<typename T>
|
||||
struct apply : mpl::false_
|
||||
{};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
41
include/boost/fusion/adapted/std_array/detail/size_impl.hpp
Normal file
41
include/boost/fusion/adapted/std_array/detail/size_impl.hpp
Normal file
@ -0,0 +1,41 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2013 Mateusz Loskot
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_STD_ARRAY_SIZE_IMPL_01062013_1700)
|
||||
#define BOOST_FUSION_STD_ARRAY_SIZE_IMPL_01062013_1700
|
||||
|
||||
#include <boost/fusion/adapted/std_array/detail/array_size.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct std_array_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename T>
|
||||
struct size_impl;
|
||||
|
||||
template<>
|
||||
struct size_impl<std_array_tag>
|
||||
{
|
||||
template<typename Sequence>
|
||||
struct apply
|
||||
: mpl::int_
|
||||
<
|
||||
std_array_size
|
||||
<
|
||||
typename remove_const<Sequence>::type
|
||||
>::value
|
||||
>
|
||||
{};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
@ -0,0 +1,32 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_STD_ARRAY_VALUE_AT_IMPL_01062013_1700)
|
||||
#define BOOST_FUSION_STD_ARRAY_VALUE_AT_IMPL_01062013_1700
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct std_array_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename T>
|
||||
struct value_at_impl;
|
||||
|
||||
template <>
|
||||
struct value_at_impl<std_array_tag>
|
||||
{
|
||||
template <typename Sequence, typename N>
|
||||
struct apply
|
||||
{
|
||||
typedef typename Sequence::value_type type;
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
109
include/boost/fusion/adapted/std_array/std_array_iterator.hpp
Normal file
109
include/boost/fusion/adapted/std_array/std_array_iterator.hpp
Normal file
@ -0,0 +1,109 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2013 Mateusz Loskot
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_STD_ARRAY_ARRAY_ITERATOR_01062013_1700)
|
||||
#define BOOST_FUSION_STD_ARRAY_ARRAY_ITERATOR_01062013_1700
|
||||
|
||||
#include <cstddef>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/minus.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/fusion/iterator/iterator_facade.hpp>
|
||||
#include <boost/fusion/adapted/std_array/detail/array_size.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct random_access_traversal_tag;
|
||||
|
||||
template <typename Array, int Pos>
|
||||
struct std_array_iterator
|
||||
: iterator_facade<std_array_iterator<Array, Pos>, random_access_traversal_tag>
|
||||
{
|
||||
BOOST_MPL_ASSERT_RELATION(Pos, >=, 0);
|
||||
BOOST_MPL_ASSERT_RELATION(Pos, <=, std::tuple_size<Array>::value);
|
||||
|
||||
typedef mpl::int_<Pos> index;
|
||||
typedef Array array_type;
|
||||
|
||||
std_array_iterator(Array& a)
|
||||
: array(a) {}
|
||||
|
||||
Array& array;
|
||||
|
||||
template <typename Iterator>
|
||||
struct value_of
|
||||
{
|
||||
typedef typename Iterator::array_type array_type;
|
||||
typedef typename array_type::value_type type;
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
struct deref
|
||||
{
|
||||
typedef typename Iterator::array_type array_type;
|
||||
typedef typename
|
||||
mpl::if_<
|
||||
is_const<array_type>
|
||||
, typename array_type::const_reference
|
||||
, typename array_type::reference
|
||||
>::type
|
||||
type;
|
||||
|
||||
static type
|
||||
call(Iterator const & it)
|
||||
{
|
||||
return it.array[Iterator::index::value];
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Iterator, typename N>
|
||||
struct advance
|
||||
{
|
||||
typedef typename Iterator::index index;
|
||||
typedef typename Iterator::array_type array_type;
|
||||
typedef std_array_iterator<array_type, index::value + N::value> type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i)
|
||||
{
|
||||
return type(i.array);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
struct next : advance<Iterator, mpl::int_<1> > {};
|
||||
|
||||
template <typename Iterator>
|
||||
struct prior : advance<Iterator, mpl::int_<-1> > {};
|
||||
|
||||
template <typename I1, typename I2>
|
||||
struct distance : mpl::minus<typename I2::index, typename I1::index>
|
||||
{
|
||||
typedef typename
|
||||
mpl::minus<
|
||||
typename I2::index, typename I1::index
|
||||
>::type
|
||||
type;
|
||||
|
||||
static type
|
||||
call(I1 const&, I2 const&)
|
||||
{
|
||||
return type();
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
std_array_iterator<Array, Pos>& operator=(std_array_iterator<Array, Pos> const&);
|
||||
};
|
||||
}}
|
||||
|
||||
#endif
|
52
include/boost/fusion/adapted/std_array/tag_of.hpp
Normal file
52
include/boost/fusion/adapted/std_array/tag_of.hpp
Normal file
@ -0,0 +1,52 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_STD_ARRAY_TAG_OF_01062013_1700)
|
||||
#define BOOST_FUSION_STD_ARRAY_TAG_OF_01062013_1700
|
||||
|
||||
#include <boost/fusion/support/tag_of_fwd.hpp>
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct std_array_tag;
|
||||
struct fusion_sequence_tag;
|
||||
|
||||
namespace traits
|
||||
{
|
||||
template<typename T, std::size_t N>
|
||||
#if defined(BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS)
|
||||
struct tag_of<std::array<T,N>, void >
|
||||
#else
|
||||
struct tag_of<std::array<T,N> >
|
||||
#endif
|
||||
{
|
||||
typedef std_array_tag type;
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
namespace boost { namespace mpl
|
||||
{
|
||||
template<typename>
|
||||
struct sequence_tag;
|
||||
|
||||
template<typename T, std::size_t N>
|
||||
struct sequence_tag<std::array<T,N> >
|
||||
{
|
||||
typedef fusion::fusion_sequence_tag type;
|
||||
};
|
||||
|
||||
template<typename T, std::size_t N>
|
||||
struct sequence_tag<std::array<T,N> const>
|
||||
{
|
||||
typedef fusion::fusion_sequence_tag type;
|
||||
};
|
||||
}}
|
||||
|
||||
#endif
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/iterator/deref.hpp>
|
||||
#include <boost/fusion/iterator/next.hpp>
|
||||
@ -39,6 +40,8 @@
|
||||
#define BOOST_FUSION_DEFINE_STRUCT_FILLER_0_END
|
||||
#define BOOST_FUSION_DEFINE_STRUCT_FILLER_1_END
|
||||
|
||||
#ifdef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
|
||||
|
||||
#define BOOST_FUSION_DEFINE_STRUCT_COPY_CTOR_FILLER_I( \
|
||||
R, ATTRIBUTE_TUPLE_SIZE, I, ATTRIBUTE) \
|
||||
\
|
||||
@ -46,6 +49,54 @@
|
||||
BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE)( \
|
||||
other_self.BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE))
|
||||
|
||||
#define BOOST_FUSION_DEFINE_STRUCT_COPY_CTOR( \
|
||||
NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \
|
||||
\
|
||||
BOOST_FUSION_GPU_ENABLED \
|
||||
NAME(self_type const& other_self) \
|
||||
: BOOST_PP_SEQ_FOR_EACH_I_R( \
|
||||
1, \
|
||||
BOOST_FUSION_DEFINE_STRUCT_COPY_CTOR_FILLER_I, \
|
||||
ATTRIBUTE_TUPLE_SIZE, \
|
||||
ATTRIBUTES_SEQ) \
|
||||
{}
|
||||
|
||||
// Use templated version instead.
|
||||
#define BOOST_FUSION_DEFINE_STRUCT_COPY_ASSIGN_FILLER_I( \
|
||||
R, ATTRIBUTE_TUPLE_SIZE, I_, ATTRIBUTE) \
|
||||
\
|
||||
BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE)= \
|
||||
other.BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE);
|
||||
|
||||
#define BOOST_FUSION_DEFINE_STRUCT_COPY_ASSIGN_OP( \
|
||||
ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \
|
||||
\
|
||||
BOOST_FUSION_GPU_ENABLED \
|
||||
self_type& operator=(self_type const& other) \
|
||||
{ \
|
||||
BOOST_PP_SEQ_FOR_EACH_I_R( \
|
||||
1, \
|
||||
BOOST_FUSION_DEFINE_STRUCT_COPY_ASSIGN_FILLER_I, \
|
||||
ATTRIBUTE_TUPLE_SIZE, \
|
||||
ATTRIBUTES_SEQ) \
|
||||
\
|
||||
return *this; \
|
||||
}
|
||||
|
||||
#else // BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
|
||||
|
||||
#define BOOST_FUSION_DEFINE_STRUCT_COPY_CTOR( \
|
||||
NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \
|
||||
\
|
||||
BOOST_FUSION_GPU_ENABLED NAME(self_type const&) = default;
|
||||
|
||||
#define BOOST_FUSION_DEFINE_STRUCT_COPY_ASSIGN_OP( \
|
||||
ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \
|
||||
\
|
||||
BOOST_FUSION_GPU_ENABLED self_type& operator=(self_type const&) = default;
|
||||
|
||||
#endif // BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
|
||||
|
||||
#define BOOST_FUSION_DEFINE_STRUCT_ASSIGN_FILLER_I( \
|
||||
R, ATTRIBUTE_TUPLE_SIZE, I_, ATTRIBUTE) \
|
||||
\
|
||||
@ -85,6 +136,81 @@
|
||||
return *this; \
|
||||
}
|
||||
|
||||
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
#define BOOST_FUSION_DEFINE_STRUCT_MOVE_CTOR(NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)
|
||||
#define BOOST_FUSION_DEFINE_STRUCT_MOVE_ASSIGN_OP(ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)
|
||||
|
||||
#else // BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
#if defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) \
|
||||
|| BOOST_WORKAROUND(BOOST_GCC, < 40500) \
|
||||
|| BOOST_WORKAROUND(BOOST_MSVC, == 1800)
|
||||
|
||||
#define BOOST_FUSION_DEFINE_STRUCT_MOVE_CTOR_FILLER_I( \
|
||||
R, ATTRIBUTE_TUPLE_SIZE, I, ATTRIBUTE) \
|
||||
\
|
||||
BOOST_PP_COMMA_IF(I) \
|
||||
BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE)(std::move( \
|
||||
other_self.BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE)))
|
||||
|
||||
#define BOOST_FUSION_DEFINE_STRUCT_MOVE_CTOR( \
|
||||
NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \
|
||||
\
|
||||
BOOST_FUSION_GPU_ENABLED \
|
||||
NAME(self_type&& other_self) \
|
||||
: BOOST_PP_SEQ_FOR_EACH_I_R( \
|
||||
1, \
|
||||
BOOST_FUSION_DEFINE_STRUCT_MOVE_CTOR_FILLER_I, \
|
||||
ATTRIBUTE_TUPLE_SIZE, \
|
||||
ATTRIBUTES_SEQ) \
|
||||
{}
|
||||
|
||||
#else // BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
|
||||
|
||||
#define BOOST_FUSION_DEFINE_STRUCT_MOVE_CTOR( \
|
||||
NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \
|
||||
\
|
||||
BOOST_FUSION_GPU_ENABLED NAME(self_type&&) = default;
|
||||
|
||||
#endif // BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
|
||||
|
||||
#if defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) \
|
||||
|| BOOST_WORKAROUND(BOOST_GCC, < 40600) \
|
||||
|| BOOST_WORKAROUND(BOOST_MSVC, == 1800)
|
||||
|
||||
#define BOOST_FUSION_DEFINE_STRUCT_MOVE_ASSIGN_FILLER_I( \
|
||||
R, ATTRIBUTE_TUPLE_SIZE, I_, ATTRIBUTE) \
|
||||
\
|
||||
BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE)=std::move( \
|
||||
other.BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE));
|
||||
|
||||
#define BOOST_FUSION_DEFINE_STRUCT_MOVE_ASSIGN_OP( \
|
||||
ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \
|
||||
\
|
||||
BOOST_FUSION_GPU_ENABLED \
|
||||
self_type& operator=(self_type&& other) \
|
||||
{ \
|
||||
BOOST_PP_SEQ_FOR_EACH_I_R( \
|
||||
1, \
|
||||
BOOST_FUSION_DEFINE_STRUCT_MOVE_ASSIGN_FILLER_I, \
|
||||
ATTRIBUTE_TUPLE_SIZE, \
|
||||
ATTRIBUTES_SEQ) \
|
||||
\
|
||||
return *this; \
|
||||
}
|
||||
|
||||
#else // BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
|
||||
|
||||
#define BOOST_FUSION_DEFINE_STRUCT_MOVE_ASSIGN_OP( \
|
||||
ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \
|
||||
\
|
||||
BOOST_FUSION_GPU_ENABLED self_type& operator=(self_type&&) = default;
|
||||
|
||||
#endif // BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
|
||||
|
||||
#endif // BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
#define BOOST_FUSION_DEFINE_STRUCT_ATTR_I(R, ATTRIBUTE_TUPLE_SIZE, ATTRIBUTE) \
|
||||
\
|
||||
BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,0,ATTRIBUTE) \
|
||||
@ -135,14 +261,10 @@
|
||||
ATTRIBUTES_SEQ) \
|
||||
{} \
|
||||
\
|
||||
BOOST_FUSION_GPU_ENABLED \
|
||||
NAME(self_type const& other_self) \
|
||||
: BOOST_PP_SEQ_FOR_EACH_I_R( \
|
||||
1, \
|
||||
BOOST_FUSION_DEFINE_STRUCT_COPY_CTOR_FILLER_I, \
|
||||
ATTRIBUTE_TUPLE_SIZE, \
|
||||
ATTRIBUTES_SEQ) \
|
||||
{} \
|
||||
BOOST_FUSION_DEFINE_STRUCT_COPY_CTOR( \
|
||||
NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \
|
||||
BOOST_FUSION_DEFINE_STRUCT_MOVE_CTOR( \
|
||||
NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \
|
||||
\
|
||||
template<typename Seq> \
|
||||
BOOST_FUSION_GPU_ENABLED \
|
||||
@ -160,6 +282,10 @@
|
||||
ATTRIBUTES_SEQ) \
|
||||
{} \
|
||||
\
|
||||
BOOST_FUSION_DEFINE_STRUCT_COPY_ASSIGN_OP( \
|
||||
ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \
|
||||
BOOST_FUSION_DEFINE_STRUCT_MOVE_ASSIGN_OP( \
|
||||
ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \
|
||||
BOOST_FUSION_DEFINE_STRUCT_ASSIGN_OP(ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)
|
||||
|
||||
#define BOOST_FUSION_DEFINE_STRUCT_CTOR_1( \
|
||||
@ -282,20 +408,7 @@
|
||||
NAME, BOOST_PP_SEQ_TAIL(ATTRIBUTES_SEQ), ATTRIBUTE_TUPLE_SIZE)
|
||||
|
||||
#define BOOST_FUSION_DEFINE_EMPTY_STRUCT_IMPL( \
|
||||
NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \
|
||||
\
|
||||
template<typename Seq> \
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED \
|
||||
NAME(Seq const&) \
|
||||
{} \
|
||||
\
|
||||
template<typename Seq> \
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED \
|
||||
self_type& \
|
||||
operator=(Seq const& seq) \
|
||||
{ \
|
||||
return *this; \
|
||||
}
|
||||
NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)
|
||||
|
||||
#define BOOST_FUSION_DEFINE_STRUCT_IMPL( \
|
||||
NAMESPACE_SEQ, NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \
|
||||
@ -327,10 +440,7 @@
|
||||
ATTRIBUTE_TUPLE_SIZE)
|
||||
|
||||
#define BOOST_FUSION_DEFINE_EMPTY_TPL_STRUCT_IMPL( \
|
||||
TEMPLATE_PARAMS_SEQ, NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \
|
||||
\
|
||||
BOOST_FUSION_DEFINE_EMPTY_STRUCT_IMPL( \
|
||||
NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)
|
||||
TEMPLATE_PARAMS_SEQ, NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)
|
||||
|
||||
#define BOOST_FUSION_DEFINE_TPL_STRUCT_IMPL( \
|
||||
TEMPLATE_PARAMS_SEQ, \
|
||||
|
@ -59,7 +59,7 @@ namespace boost { namespace fusion { namespace detail
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
keyed_element(keyed_element&& rhs)
|
||||
: Rest(BOOST_FUSION_FWD_ELEM(Rest, rhs.forward_base()))
|
||||
: Rest(rhs.forward_base())
|
||||
, value_(BOOST_FUSION_FWD_ELEM(Value, rhs.value_))
|
||||
{}
|
||||
#endif
|
||||
@ -90,7 +90,7 @@ namespace boost { namespace fusion { namespace detail
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
Rest&& forward_base() BOOST_NOEXCEPT
|
||||
{
|
||||
return BOOST_FUSION_FWD_ELEM(Rest, *static_cast<Rest*>(this));
|
||||
return std::move(*static_cast<Rest*>(this));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -116,7 +116,7 @@ namespace boost { namespace fusion { namespace detail
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
keyed_element(Value&& value, Rest&& rest)
|
||||
: Rest(BOOST_FUSION_FWD_ELEM(Rest, rest))
|
||||
: Rest(std::move(rest))
|
||||
, value_(BOOST_FUSION_FWD_ELEM(Value, value))
|
||||
{}
|
||||
#endif
|
||||
@ -147,8 +147,8 @@ namespace boost { namespace fusion { namespace detail
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
keyed_element& operator=(keyed_element&& rhs)
|
||||
{
|
||||
base::operator=(std::forward<keyed_element>(rhs));
|
||||
value_ = BOOST_FUSION_FWD_ELEM(Value, rhs.value_);
|
||||
base::operator=(rhs.forward_base());
|
||||
value_ = std::move(rhs.value_);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
@ -15,6 +15,8 @@
|
||||
|| defined(BOOST_NO_CXX11_RVALUE_REFERENCES) \
|
||||
|| defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) \
|
||||
|| defined(BOOST_NO_CXX11_DECLTYPE)) \
|
||||
|| defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS) \
|
||||
|| defined(BOOST_FUSION_DISABLE_VARIADIC_VECTOR) \
|
||||
|| (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES))
|
||||
# if defined(BOOST_FUSION_HAS_VARIADIC_VECTOR)
|
||||
# undef BOOST_FUSION_HAS_VARIADIC_VECTOR
|
||||
|
@ -24,23 +24,21 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/fusion/support/sequence_base.hpp>
|
||||
#include <boost/fusion/support/is_sequence.hpp>
|
||||
#include <boost/fusion/support/void.hpp>
|
||||
#include <boost/fusion/support/detail/enabler.hpp>
|
||||
#include <boost/fusion/support/detail/and.hpp>
|
||||
#include <boost/fusion/support/detail/index_sequence.hpp>
|
||||
#include <boost/fusion/container/vector/detail/at_impl.hpp>
|
||||
#include <boost/fusion/container/vector/detail/value_at_impl.hpp>
|
||||
#include <boost/fusion/container/vector/detail/begin_impl.hpp>
|
||||
#include <boost/fusion/container/vector/detail/end_impl.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/iterator/advance.hpp>
|
||||
#include <boost/fusion/iterator/deref.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#include <boost/type_traits/is_base_of.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
@ -53,52 +51,48 @@ namespace boost { namespace fusion
|
||||
namespace vector_detail
|
||||
{
|
||||
struct each_elem {};
|
||||
struct copy_or_move {};
|
||||
template <typename I> struct from_sequence {};
|
||||
|
||||
template <typename Sequence>
|
||||
struct make_indices_from_seq
|
||||
: detail::make_index_sequence<
|
||||
fusion::result_of::size<typename remove_reference<Sequence>::type>::value
|
||||
template <
|
||||
typename This, typename T, typename T_, std::size_t Size, bool IsSeq
|
||||
>
|
||||
struct can_convert_impl : false_type {};
|
||||
|
||||
template <typename This, typename T, typename Sequence, std::size_t Size>
|
||||
struct can_convert_impl<This, T, Sequence, Size, true> : true_type {};
|
||||
|
||||
template <typename This, typename Sequence, typename T>
|
||||
struct can_convert_impl<This, Sequence, T, 1, true>
|
||||
: integral_constant<
|
||||
bool
|
||||
, !is_convertible<
|
||||
Sequence
|
||||
, typename fusion::extension::value_at_impl<vector_tag>::
|
||||
template apply< This, mpl::int_<0> >::type
|
||||
>::value
|
||||
>
|
||||
{};
|
||||
|
||||
template <typename T>
|
||||
struct pure : remove_cv<typename remove_reference<T>::type> {};
|
||||
|
||||
template <typename Sequence, typename This, int = result_of::size<This>::value>
|
||||
struct is_convertible_to_first
|
||||
: boost::is_convertible<Sequence, typename result_of::value_at_c<This, 0>::type>
|
||||
template <typename This, typename T, typename T_, std::size_t Size>
|
||||
struct can_convert
|
||||
: can_convert_impl<
|
||||
This, T, T_, Size, traits::is_sequence<T_>::value
|
||||
>
|
||||
{};
|
||||
|
||||
template <typename Sequence, typename This>
|
||||
struct is_convertible_to_first<Sequence, This, 0>
|
||||
: mpl::false_
|
||||
template <typename T, bool IsSeq, std::size_t Size>
|
||||
struct is_longer_sequence_impl : false_type {};
|
||||
|
||||
template <typename Sequence, std::size_t Size>
|
||||
struct is_longer_sequence_impl<Sequence, true, Size>
|
||||
: integral_constant<
|
||||
bool, (fusion::result_of::size<Sequence>::value >= Size)
|
||||
>
|
||||
{};
|
||||
|
||||
template <typename This, typename ...T>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline each_elem
|
||||
dispatch(T const&...) BOOST_NOEXCEPT { return each_elem(); }
|
||||
|
||||
template <typename This>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline copy_or_move
|
||||
dispatch(This const&) BOOST_NOEXCEPT { return copy_or_move(); }
|
||||
|
||||
template <typename This, typename Sequence>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline from_sequence<
|
||||
typename lazy_enable_if_c<
|
||||
(traits::is_sequence<typename remove_reference<Sequence>::type>::value &&
|
||||
!is_same<This, typename pure<Sequence>::type>::value &&
|
||||
!is_convertible_to_first<Sequence, This>::value)
|
||||
, make_indices_from_seq<Sequence>
|
||||
>::type
|
||||
>
|
||||
dispatch(Sequence&&) BOOST_NOEXCEPT
|
||||
{ return from_sequence<typename make_indices_from_seq<Sequence>::type>(); }
|
||||
|
||||
template<typename T, std::size_t Size>
|
||||
struct is_longer_sequence
|
||||
: is_longer_sequence_impl<T, traits::is_sequence<T>::value, Size>
|
||||
{};
|
||||
|
||||
// forward_at_c allows to access Nth element even if ForwardSequence
|
||||
// since fusion::at_c requires RandomAccessSequence.
|
||||
@ -163,22 +157,17 @@ namespace boost { namespace fusion
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
template <
|
||||
typename U
|
||||
, typename = typename boost::disable_if<
|
||||
is_base_of<store, typename remove_reference<U>::type>
|
||||
>::type
|
||||
>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
store(U&& rhs
|
||||
, typename disable_if<is_same<typename pure<U>::type, store>, detail::enabler_>::type = detail::enabler)
|
||||
store(U&& rhs)
|
||||
: elem(std::forward<U>(rhs))
|
||||
{}
|
||||
|
||||
template <typename U>
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
typename disable_if<is_same<typename pure<U>::type, store>, store&>::type
|
||||
operator=(U&& rhs)
|
||||
{
|
||||
elem = std::forward<U>(rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
T & get() { return elem; }
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
@ -206,21 +195,17 @@ namespace boost { namespace fusion
|
||||
vector_data()
|
||||
{}
|
||||
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
vector_data(copy_or_move, vector_data const& rhs)
|
||||
: store<I, T>(static_cast<store<I, T> const&>(rhs))...
|
||||
{}
|
||||
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
vector_data(copy_or_move, vector_data&& rhs)
|
||||
: store<I, T>(std::forward<store<I, T> >(rhs))...
|
||||
{}
|
||||
|
||||
template <typename Sequence>
|
||||
template <
|
||||
typename Sequence
|
||||
, typename Sequence_ = typename remove_reference<Sequence>::type
|
||||
, typename = typename boost::enable_if<
|
||||
can_convert<vector_data, Sequence, Sequence_, sizeof...(I)>
|
||||
>::type
|
||||
>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
explicit
|
||||
vector_data(from_sequence<detail::index_sequence<I...> >, Sequence&& rhs)
|
||||
: store<I, T>(forward_at_c<I>(rhs))...
|
||||
vector_data(each_elem, Sequence&& rhs)
|
||||
: store<I, T>(forward_at_c<I>(std::forward<Sequence>(rhs)))...
|
||||
{}
|
||||
|
||||
template <typename ...U>
|
||||
@ -230,6 +215,14 @@ namespace boost { namespace fusion
|
||||
: store<I, T>(std::forward<U>(var))...
|
||||
{}
|
||||
|
||||
template <typename Sequence>
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
void
|
||||
assign_sequence(Sequence&& seq)
|
||||
{
|
||||
assign(std::forward<Sequence>(seq), detail::index_sequence<I...>());
|
||||
}
|
||||
|
||||
template <typename Sequence>
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
void
|
||||
@ -294,15 +287,36 @@ namespace boost { namespace fusion
|
||||
vector()
|
||||
{}
|
||||
|
||||
// rvalue-references is required here in order to forward any arguments to
|
||||
// base: vector(T const&...) doesn't work with trailing void_ and
|
||||
// vector(U const&...) cannot forward any arguments to base.
|
||||
template <typename... U>
|
||||
template <
|
||||
typename... U
|
||||
, typename = typename boost::enable_if_c<(
|
||||
sizeof...(U) >= 1 &&
|
||||
fusion::detail::and_<is_convertible<U, T>...>::value &&
|
||||
!fusion::detail::and_<
|
||||
is_base_of<vector, typename remove_reference<U>::type>...
|
||||
>::value
|
||||
)>::type
|
||||
>
|
||||
// XXX: constexpr become error due to pull-request #79, booooo!!
|
||||
// In the (near) future release, should be fixed.
|
||||
/* BOOST_CONSTEXPR */ BOOST_FUSION_GPU_ENABLED
|
||||
vector(U&&... u)
|
||||
: base(vector_detail::dispatch<vector>(std::forward<U>(u)...), std::forward<U>(u)...)
|
||||
explicit vector(U&&... u)
|
||||
: base(vector_detail::each_elem(), std::forward<U>(u)...)
|
||||
{}
|
||||
|
||||
template <
|
||||
typename Sequence
|
||||
, typename Sequence_ = typename remove_reference<Sequence>::type
|
||||
, typename = typename boost::enable_if_c<(
|
||||
!is_base_of<vector, Sequence_>::value &&
|
||||
vector_detail::is_longer_sequence<
|
||||
Sequence_, sizeof...(T)
|
||||
>::value
|
||||
)>::type
|
||||
>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
vector(Sequence&& seq)
|
||||
: base(vector_detail::each_elem(), std::forward<Sequence>(seq))
|
||||
{}
|
||||
|
||||
template <typename Sequence>
|
||||
@ -310,10 +324,7 @@ namespace boost { namespace fusion
|
||||
vector&
|
||||
operator=(Sequence&& rhs)
|
||||
{
|
||||
typedef typename
|
||||
vector_detail::make_indices_from_seq<Sequence>::type
|
||||
indices;
|
||||
base::assign(std::forward<Sequence>(rhs), indices());
|
||||
base::assign_sequence(std::forward<Sequence>(rhs));
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
39
include/boost/fusion/support/detail/and.hpp
Normal file
39
include/boost/fusion/support/detail/and.hpp
Normal file
@ -0,0 +1,39 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 Lee Clagett
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#ifndef FUSION_AND_07152016_1625
|
||||
#define FUSION_AND_07152016_1625
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
#error fusion::detail::and_ requires variadic templates
|
||||
#endif
|
||||
|
||||
namespace boost { namespace fusion { namespace detail {
|
||||
template<typename ...Cond>
|
||||
struct and_impl : false_type {};
|
||||
|
||||
template<typename ...T>
|
||||
struct and_impl<integral_constant<T, true>...> : true_type {};
|
||||
|
||||
// This specialization is necessary to avoid MSVC-12 variadics bug.
|
||||
template<bool ...Cond>
|
||||
struct and_impl1 : and_impl<integral_constant<bool, Cond>...> {};
|
||||
|
||||
/* fusion::detail::and_ differs from mpl::and_ in the following ways:
|
||||
- The empty set is valid and returns true
|
||||
- A single element set is valid and returns the identity
|
||||
- There is no upper bound on the set size
|
||||
- The conditions are evaluated at once, and are not short-circuited. This
|
||||
reduces instantations when returning true; the implementation is not
|
||||
recursive. */
|
||||
template<typename ...Cond>
|
||||
struct and_ : and_impl1<Cond::value...> {};
|
||||
}}}
|
||||
|
||||
#endif // FUSION_AND_07152016_1625
|
@ -20,12 +20,15 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// C++11 interface
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/value_at.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
||||
#include <boost/fusion/sequence/comparison.hpp>
|
||||
#include <boost/fusion/sequence/io.hpp>
|
||||
#include <boost/fusion/support/detail/and.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
@ -39,23 +42,49 @@ namespace boost { namespace fusion
|
||||
tuple()
|
||||
: base_type() {}
|
||||
|
||||
template <typename ...U>
|
||||
template <
|
||||
typename ...U
|
||||
, typename = typename boost::enable_if_c<
|
||||
sizeof...(U) >= sizeof...(T)
|
||||
>::type
|
||||
>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
tuple(tuple<U...> const& other)
|
||||
: base_type(other) {}
|
||||
|
||||
template <typename ...U>
|
||||
template <
|
||||
typename ...U
|
||||
, typename = typename boost::enable_if_c<
|
||||
sizeof...(U) >= sizeof...(T)
|
||||
>::type
|
||||
>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
tuple(tuple<U...>&& other)
|
||||
: base_type(std::move(other)) {}
|
||||
|
||||
template <typename ...U>
|
||||
template <
|
||||
typename ...U
|
||||
, typename = typename boost::enable_if_c<(
|
||||
fusion::detail::and_<is_convertible<U, T>...>::value &&
|
||||
sizeof...(U) >= 1
|
||||
)>::type
|
||||
>
|
||||
/*BOOST_CONSTEXPR*/ BOOST_FUSION_GPU_ENABLED
|
||||
explicit
|
||||
tuple(U&&... args)
|
||||
: base_type(std::forward<U>(args)...) {}
|
||||
|
||||
template <typename U>
|
||||
template<typename U1, typename U2>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
tuple(std::pair<U1, U2> const& other)
|
||||
: base_type(other.first, other.second) {}
|
||||
|
||||
template<typename U1, typename U2>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
tuple(std::pair<U1, U2>&& other)
|
||||
: base_type(std::move(other.first), std::move(other.second)) {}
|
||||
|
||||
template<typename U>
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
tuple& operator=(U&& rhs)
|
||||
{
|
||||
|
@ -126,7 +126,7 @@ namespace boost { namespace fusion {
|
||||
zip_view(
|
||||
const Sequences& seqs)
|
||||
: sequences_(seqs)
|
||||
{};
|
||||
{}
|
||||
|
||||
sequences sequences_;
|
||||
};
|
||||
|
57
test/Jamfile
57
test/Jamfile
@ -1,5 +1,6 @@
|
||||
##==============================================================================
|
||||
# Copyright (c) 2003-2006 Joel de Guzman
|
||||
# Copyright (c) 2013 Mateusz Loskot
|
||||
#
|
||||
# Use, modification and distribution is subject to the Boost Software
|
||||
# License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -121,8 +122,10 @@ project
|
||||
[ run sequence/std_pair.cpp : : : : ]
|
||||
[ run sequence/boost_array.cpp : : : : ]
|
||||
[ run sequence/array.cpp : : : : ]
|
||||
[ run sequence/std_array.cpp : : : : ]
|
||||
[ run sequence/tuple_comparison.cpp : : : : ]
|
||||
[ run sequence/tuple_construction.cpp : : : : ]
|
||||
[ run sequence/tuple_conversion.cpp : : : : ]
|
||||
[ run sequence/tuple_copy.cpp : : : : ]
|
||||
[ run sequence/tuple_element.cpp : : : : ]
|
||||
[ run sequence/tuple_make.cpp : : : : ]
|
||||
@ -131,9 +134,24 @@ project
|
||||
[ run sequence/tuple_nest.cpp : : : : ]
|
||||
[ run sequence/tuple_hash.cpp : : : : ]
|
||||
[ run sequence/tuple_tie.cpp : : : : ]
|
||||
[
|
||||
run sequence/tuple_traits.cpp
|
||||
:
|
||||
:
|
||||
:
|
||||
: sequence/tuple_traits/maybe_variadic_tuple
|
||||
]
|
||||
[
|
||||
run sequence/tuple_traits.cpp
|
||||
:
|
||||
:
|
||||
: <define>BOOST_FUSION_DISABLE_VARIADIC_VECTOR
|
||||
: sequence/tuple_traits/no_variadic_tuple
|
||||
]
|
||||
[ run sequence/transform_view.cpp : : : : ]
|
||||
[ run sequence/vector_comparison.cpp : : : : ]
|
||||
[ run sequence/vector_construction.cpp : : : : ]
|
||||
[ run sequence/vector_conversion.cpp : : : : ]
|
||||
[ run sequence/vector_copy.cpp : : : : ]
|
||||
[ run sequence/vector_iterator.cpp : : : : ]
|
||||
[ run sequence/vector_make.cpp : : : : ]
|
||||
@ -144,6 +162,20 @@ project
|
||||
[ run sequence/vector_nest.cpp : : : : ]
|
||||
[ run sequence/vector_hash.cpp : : : : ]
|
||||
[ run sequence/vector_tie.cpp : : : : ]
|
||||
[
|
||||
run sequence/vector_traits.cpp
|
||||
:
|
||||
:
|
||||
:
|
||||
: sequence/vector_traits/maybe_variadic_vector
|
||||
]
|
||||
[
|
||||
run sequence/vector_traits.cpp
|
||||
:
|
||||
:
|
||||
: <define>BOOST_FUSION_DISABLE_VARIADIC_VECTOR
|
||||
: sequence/vector_traits/no_variadic_vector
|
||||
]
|
||||
[ run sequence/vector_value_at.cpp : : : : ]
|
||||
[ run sequence/zip_view.cpp : : : : ]
|
||||
[ run sequence/zip_view2.cpp : : : : ]
|
||||
@ -151,24 +183,48 @@ project
|
||||
[ run sequence/repetitive_view.cpp : : : : ]
|
||||
[ run sequence/deduce_sequence.cpp : : : : ]
|
||||
[ run sequence/adapt_adt_named.cpp : : : : ]
|
||||
[ run sequence/adapt_adt_named_empty.cpp : : : : ]
|
||||
[ run sequence/adapt_adt.cpp : : : : ]
|
||||
[ run sequence/adapt_adt_empty.cpp : : : : ]
|
||||
[ run sequence/adapt_assoc_adt_named.cpp : : : : ]
|
||||
[ run sequence/adapt_assoc_adt_named_empty.cpp : : : : ]
|
||||
[ run sequence/adapt_assoc_adt.cpp : : : : ]
|
||||
[ run sequence/adapt_assoc_adt_empty.cpp : : : : ]
|
||||
[ run sequence/adapt_assoc_struct_named.cpp : : : : ]
|
||||
[ run sequence/adapt_assoc_struct_named_empty.cpp : : : : ]
|
||||
[ run sequence/adapt_assoc_struct.cpp : : : : ]
|
||||
[ run sequence/adapt_assoc_struct_empty.cpp : : : : ]
|
||||
[ run sequence/adapt_assoc_tpl_adt.cpp : : : : ]
|
||||
[ run sequence/adapt_assoc_tpl_adt_empty.cpp : : : : ]
|
||||
[ run sequence/adapt_assoc_tpl_struct.cpp : : : : ]
|
||||
[ run sequence/adapt_assoc_tpl_struct_empty.cpp : : : : ]
|
||||
[ run sequence/adapt_struct_named.cpp : : : : ]
|
||||
[ run sequence/adapt_struct_named_empty.cpp : : : : ]
|
||||
[ run sequence/adapt_struct.cpp : : : : ]
|
||||
[ run sequence/adapt_struct_empty.cpp : : : : ]
|
||||
[ run sequence/adapt_tpl_adt.cpp : : : : ]
|
||||
[ run sequence/adapt_tpl_adt_empty.cpp : : : : ]
|
||||
[ run sequence/adapt_tpl_struct.cpp : : : : ]
|
||||
[ run sequence/adapt_tpl_struct_empty.cpp : : : : ]
|
||||
[ run sequence/adt_attribute_proxy.cpp : : : : ]
|
||||
[ run sequence/define_struct.cpp : : : : ]
|
||||
[ run sequence/define_struct_empty.cpp : : : : ]
|
||||
[ run sequence/define_struct_move.cpp : : : : ]
|
||||
[ run sequence/define_struct_inline.cpp : : : : ]
|
||||
[ run sequence/define_struct_inline_empty.cpp : : : : ]
|
||||
[ run sequence/define_struct_inline_move.cpp : : : : ]
|
||||
[ run sequence/define_assoc_struct.cpp : : : : ]
|
||||
[ run sequence/define_assoc_struct_empty.cpp : : : : ]
|
||||
[ run sequence/define_assoc_struct_move.cpp : : : : ]
|
||||
[ run sequence/define_tpl_struct.cpp : : : : ]
|
||||
[ run sequence/define_tpl_struct_empty.cpp : : : : ]
|
||||
[ run sequence/define_tpl_struct_move.cpp : : : : ]
|
||||
[ run sequence/define_tpl_struct_inline.cpp : : : : ]
|
||||
[ run sequence/define_tpl_struct_inline_empty.cpp : : : : ]
|
||||
[ run sequence/define_tpl_struct_inline_move.cpp : : : : ]
|
||||
[ run sequence/define_assoc_tpl_struct.cpp : : : : ]
|
||||
[ run sequence/define_assoc_tpl_struct_empty.cpp : : : : ]
|
||||
[ run sequence/define_assoc_tpl_struct_move.cpp : : : : ]
|
||||
[ run sequence/std_tuple.cpp : : : : ]
|
||||
[ run sequence/std_tuple_iterator.cpp : : : : ]
|
||||
[ run sequence/ref_vector.cpp : : : : ]
|
||||
@ -197,6 +253,7 @@ project
|
||||
[ compile support/pair_vector.cpp : : : : ]
|
||||
[ compile support/pair_nest.cpp : : : : ]
|
||||
[ compile support/index_sequence.cpp : : : : ]
|
||||
[ compile support/and.cpp : : : : ]
|
||||
|
||||
# [ compile-fail xxx.cpp : : : : ]
|
||||
|
||||
|
86
test/sequence/adapt_adt_empty.cpp
Normal file
86
test/sequence/adapt_adt_empty.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/adapted/adt/adapt_adt.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/empty.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/not_equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less_equal.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <iostream>
|
||||
|
||||
class empty_adt{};
|
||||
BOOST_FUSION_ADAPT_ADT(empty_adt,)
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_adt>));
|
||||
empty_adt e;
|
||||
|
||||
std::cout << e << std::endl;
|
||||
BOOST_TEST(e == make_vector());
|
||||
|
||||
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_adt>::value == 0);
|
||||
BOOST_MPL_ASSERT((fusion::result_of::empty<empty_adt>));
|
||||
|
||||
BOOST_MPL_ASSERT((fusion::result_of::equal_to<
|
||||
fusion::result_of::begin<empty_adt>::type,
|
||||
fusion::result_of::end<empty_adt>::type>));
|
||||
}
|
||||
|
||||
{
|
||||
fusion::vector<> v;
|
||||
empty_adt e;
|
||||
BOOST_TEST(v == e);
|
||||
BOOST_TEST_NOT(v != e);
|
||||
BOOST_TEST_NOT(v < e);
|
||||
BOOST_TEST(v <= e);
|
||||
BOOST_TEST_NOT(e > v);
|
||||
BOOST_TEST(e >= v);
|
||||
}
|
||||
|
||||
{
|
||||
empty_adt e;
|
||||
|
||||
// conversion from empty_adt to vector
|
||||
fusion::vector<> v(e);
|
||||
v = e;
|
||||
|
||||
// FIXME
|
||||
// conversion from empty_adt to list
|
||||
//fusion::list<> l(e);
|
||||
//l = e;
|
||||
}
|
||||
|
||||
BOOST_MPL_ASSERT((mpl::is_sequence<empty_adt>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
87
test/sequence/adapt_adt_named_empty.cpp
Normal file
87
test/sequence/adapt_adt_named_empty.cpp
Normal file
@ -0,0 +1,87 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/adapted/adt/adapt_adt_named.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/empty.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/not_equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less_equal.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <iostream>
|
||||
|
||||
class empty_adt{};
|
||||
BOOST_FUSION_ADAPT_ADT_NAMED(::empty_adt,empty_adt,)
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
empty_adt empty;
|
||||
{
|
||||
BOOST_MPL_ASSERT((traits::is_view<adapted::empty_adt>));
|
||||
adapted::empty_adt e(empty);
|
||||
|
||||
std::cout << e << std::endl;
|
||||
BOOST_TEST(e == make_vector());
|
||||
|
||||
BOOST_STATIC_ASSERT(fusion::result_of::size<adapted::empty_adt>::value == 0);
|
||||
BOOST_MPL_ASSERT((fusion::result_of::empty<adapted::empty_adt>));
|
||||
|
||||
BOOST_MPL_ASSERT((fusion::result_of::equal_to<
|
||||
fusion::result_of::begin<adapted::empty_adt>::type,
|
||||
fusion::result_of::end<adapted::empty_adt>::type>));
|
||||
}
|
||||
|
||||
{
|
||||
fusion::vector<> v;
|
||||
adapted::empty_adt e(empty);
|
||||
BOOST_TEST(v == e);
|
||||
BOOST_TEST_NOT(v != e);
|
||||
BOOST_TEST_NOT(v < e);
|
||||
BOOST_TEST(v <= e);
|
||||
BOOST_TEST_NOT(e > v);
|
||||
BOOST_TEST(e >= v);
|
||||
}
|
||||
|
||||
{
|
||||
adapted::empty_adt e(empty);
|
||||
|
||||
// conversion from empty_adt to vector
|
||||
fusion::vector<> v(e);
|
||||
v = e;
|
||||
|
||||
// FIXME
|
||||
// conversion from empty_adt to list
|
||||
//fusion::list<> l(e);
|
||||
//l = e;
|
||||
}
|
||||
|
||||
BOOST_MPL_ASSERT((mpl::is_sequence<adapted::empty_adt>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
88
test/sequence/adapt_assoc_adt_empty.cpp
Normal file
88
test/sequence/adapt_assoc_adt_empty.cpp
Normal file
@ -0,0 +1,88 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/adapted/adt/adapt_assoc_adt.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/empty.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/not_equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less_equal.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <iostream>
|
||||
|
||||
class empty_adt{};
|
||||
BOOST_FUSION_ADAPT_ASSOC_ADT(empty_adt,)
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_adt>));
|
||||
empty_adt e;
|
||||
|
||||
std::cout << e << std::endl;
|
||||
BOOST_TEST(e == make_vector());
|
||||
|
||||
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_adt>::value == 0);
|
||||
BOOST_MPL_ASSERT((fusion::result_of::empty<empty_adt>));
|
||||
|
||||
BOOST_MPL_ASSERT((fusion::result_of::equal_to<
|
||||
fusion::result_of::begin<empty_adt>::type,
|
||||
fusion::result_of::end<empty_adt>::type>));
|
||||
}
|
||||
|
||||
{
|
||||
fusion::vector<> v;
|
||||
empty_adt e;
|
||||
BOOST_TEST(v == e);
|
||||
BOOST_TEST_NOT(e != v);
|
||||
BOOST_TEST_NOT(v < e);
|
||||
BOOST_TEST(v <= e);
|
||||
BOOST_TEST_NOT(e > v);
|
||||
BOOST_TEST(e >= v);
|
||||
}
|
||||
|
||||
{
|
||||
empty_adt e;
|
||||
|
||||
// conversion from empty_adt to vector
|
||||
fusion::vector<> v(e);
|
||||
v = e;
|
||||
|
||||
// FIXME
|
||||
// conversion from empty_adt to list
|
||||
//fusion::list<> l(e);
|
||||
//l = e;
|
||||
}
|
||||
|
||||
BOOST_MPL_ASSERT((mpl::is_sequence<empty_adt>));
|
||||
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_adt, void>));
|
||||
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_adt, int>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
89
test/sequence/adapt_assoc_adt_named_empty.cpp
Normal file
89
test/sequence/adapt_assoc_adt_named_empty.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/adapted/adt/adapt_assoc_adt_named.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/empty.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/not_equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less_equal.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <iostream>
|
||||
|
||||
class empty_adt{};
|
||||
BOOST_FUSION_ADAPT_ASSOC_ADT_NAMED(::empty_adt,empty_adt,)
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
empty_adt empty;
|
||||
{
|
||||
BOOST_MPL_ASSERT((traits::is_view<adapted::empty_adt>));
|
||||
adapted::empty_adt e(empty);
|
||||
|
||||
std::cout << e << std::endl;
|
||||
BOOST_TEST(e == make_vector());
|
||||
|
||||
BOOST_STATIC_ASSERT(fusion::result_of::size<adapted::empty_adt>::value == 0);
|
||||
BOOST_MPL_ASSERT((fusion::result_of::empty<adapted::empty_adt>));
|
||||
|
||||
BOOST_MPL_ASSERT((fusion::result_of::equal_to<
|
||||
fusion::result_of::begin<adapted::empty_adt>::type,
|
||||
fusion::result_of::end<adapted::empty_adt>::type>));
|
||||
}
|
||||
|
||||
{
|
||||
fusion::vector<> v;
|
||||
adapted::empty_adt e(empty);
|
||||
BOOST_TEST(v == e);
|
||||
BOOST_TEST_NOT(e != v);
|
||||
BOOST_TEST_NOT(v < e);
|
||||
BOOST_TEST(v <= e);
|
||||
BOOST_TEST_NOT(e > v);
|
||||
BOOST_TEST(e >= v);
|
||||
}
|
||||
|
||||
{
|
||||
adapted::empty_adt e(empty);
|
||||
|
||||
// conversion from empty_adt to vector
|
||||
fusion::vector<> v(e);
|
||||
v = e;
|
||||
|
||||
// FIXME
|
||||
// conversion from empty_adt to list
|
||||
//fusion::list<> l(e);
|
||||
//l = e;
|
||||
}
|
||||
|
||||
BOOST_MPL_ASSERT((mpl::is_sequence<adapted::empty_adt>));
|
||||
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<adapted::empty_adt, void>));
|
||||
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<adapted::empty_adt, int>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
88
test/sequence/adapt_assoc_struct_empty.cpp
Normal file
88
test/sequence/adapt_assoc_struct_empty.cpp
Normal file
@ -0,0 +1,88 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/adapted/struct/adapt_assoc_struct.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/empty.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/not_equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less_equal.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <iostream>
|
||||
|
||||
class empty_struct{};
|
||||
BOOST_FUSION_ADAPT_ASSOC_STRUCT(empty_struct,)
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_struct>));
|
||||
empty_struct e;
|
||||
|
||||
std::cout << e << std::endl;
|
||||
BOOST_TEST(e == make_vector());
|
||||
|
||||
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_struct>::value == 0);
|
||||
BOOST_MPL_ASSERT((fusion::result_of::empty<empty_struct>));
|
||||
|
||||
BOOST_MPL_ASSERT((fusion::result_of::equal_to<
|
||||
fusion::result_of::begin<empty_struct>::type,
|
||||
fusion::result_of::end<empty_struct>::type>));
|
||||
}
|
||||
|
||||
{
|
||||
fusion::vector<> v;
|
||||
empty_struct e;
|
||||
BOOST_TEST(v <= e);
|
||||
BOOST_TEST_NOT(e > v);
|
||||
BOOST_TEST_NOT(v < e);
|
||||
BOOST_TEST(v <= e);
|
||||
BOOST_TEST_NOT(e > v);
|
||||
BOOST_TEST(e >= v);
|
||||
}
|
||||
|
||||
{
|
||||
empty_struct e;
|
||||
|
||||
// conversion from empty_struct to vector
|
||||
fusion::vector<> v(e);
|
||||
v = e;
|
||||
|
||||
// FIXME
|
||||
// conversion from empty_struct to list
|
||||
//fusion::list<> l(e);
|
||||
//l = e;
|
||||
}
|
||||
|
||||
BOOST_MPL_ASSERT((mpl::is_sequence<empty_struct>));
|
||||
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_struct, void>));
|
||||
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_struct, int>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
89
test/sequence/adapt_assoc_struct_named_empty.cpp
Normal file
89
test/sequence/adapt_assoc_struct_named_empty.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/adapted/struct/adapt_assoc_struct_named.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/empty.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/not_equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less_equal.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <iostream>
|
||||
|
||||
class empty_struct{};
|
||||
BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED(::empty_struct,empty_struct,)
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
empty_struct empty;
|
||||
{
|
||||
BOOST_MPL_ASSERT((traits::is_view<adapted::empty_struct>));
|
||||
adapted::empty_struct e(empty);
|
||||
|
||||
std::cout << e << std::endl;
|
||||
BOOST_TEST(e == make_vector());
|
||||
|
||||
BOOST_STATIC_ASSERT(fusion::result_of::size<adapted::empty_struct>::value == 0);
|
||||
BOOST_MPL_ASSERT((fusion::result_of::empty<adapted::empty_struct>));
|
||||
|
||||
BOOST_MPL_ASSERT((fusion::result_of::equal_to<
|
||||
fusion::result_of::begin<adapted::empty_struct>::type,
|
||||
fusion::result_of::end<adapted::empty_struct>::type>));
|
||||
}
|
||||
|
||||
{
|
||||
fusion::vector<> v;
|
||||
adapted::empty_struct e(empty);
|
||||
BOOST_TEST(v <= e);
|
||||
BOOST_TEST_NOT(e > v);
|
||||
BOOST_TEST_NOT(v < e);
|
||||
BOOST_TEST(v <= e);
|
||||
BOOST_TEST_NOT(e > v);
|
||||
BOOST_TEST(e >= v);
|
||||
}
|
||||
|
||||
{
|
||||
adapted::empty_struct e(empty);
|
||||
|
||||
// conversion from empty_struct to vector
|
||||
fusion::vector<> v(e);
|
||||
v = e;
|
||||
|
||||
// FIXME
|
||||
// conversion from empty_struct to list
|
||||
//fusion::list<> l(e);
|
||||
//l = e;
|
||||
}
|
||||
|
||||
BOOST_MPL_ASSERT((mpl::is_sequence<adapted::empty_struct>));
|
||||
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<adapted::empty_struct, void>));
|
||||
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<adapted::empty_struct, int>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
89
test/sequence/adapt_assoc_tpl_adt_empty.cpp
Normal file
89
test/sequence/adapt_assoc_tpl_adt_empty.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/adapted/adt/adapt_assoc_adt.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/empty.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/not_equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less_equal.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <iostream>
|
||||
|
||||
template <typename T>
|
||||
class empty_adt{};
|
||||
BOOST_FUSION_ADAPT_ASSOC_TPL_ADT((T), (empty_adt)(T),)
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_adt<void> >));
|
||||
empty_adt<void> e;
|
||||
|
||||
std::cout << e << std::endl;
|
||||
BOOST_TEST(e == make_vector());
|
||||
|
||||
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_adt<void> >::value == 0);
|
||||
BOOST_MPL_ASSERT((fusion::result_of::empty<empty_adt<void> >));
|
||||
|
||||
BOOST_MPL_ASSERT((fusion::result_of::equal_to<
|
||||
fusion::result_of::begin<empty_adt<void> >::type,
|
||||
fusion::result_of::end<empty_adt<void> >::type>));
|
||||
}
|
||||
|
||||
{
|
||||
fusion::vector<> v;
|
||||
empty_adt<void> e;
|
||||
BOOST_TEST(v <= e);
|
||||
BOOST_TEST_NOT(e > v);
|
||||
BOOST_TEST_NOT(v < e);
|
||||
BOOST_TEST(v <= e);
|
||||
BOOST_TEST_NOT(e > v);
|
||||
BOOST_TEST(e >= v);
|
||||
}
|
||||
|
||||
{
|
||||
empty_adt<void> e;
|
||||
|
||||
// conversion from empty_adt to vector
|
||||
fusion::vector<> v(e);
|
||||
v = e;
|
||||
|
||||
// FIXME
|
||||
// conversion from empty_adt to list
|
||||
//fusion::list<> l(e);
|
||||
//l = e;
|
||||
}
|
||||
|
||||
BOOST_MPL_ASSERT((mpl::is_sequence<empty_adt<void> >));
|
||||
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_adt<void>, void>));
|
||||
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_adt<void>, int>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
89
test/sequence/adapt_assoc_tpl_struct_empty.cpp
Normal file
89
test/sequence/adapt_assoc_tpl_struct_empty.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/adapted/struct/adapt_assoc_struct.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/empty.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/not_equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less_equal.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <iostream>
|
||||
|
||||
template <typename T>
|
||||
class empty_struct{};
|
||||
BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT((T), (empty_struct)(T),)
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_struct<void> >));
|
||||
empty_struct<void> e;
|
||||
|
||||
std::cout << e << std::endl;
|
||||
BOOST_TEST(e == make_vector());
|
||||
|
||||
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_struct<void> >::value == 0);
|
||||
BOOST_MPL_ASSERT((fusion::result_of::empty<empty_struct<void> >));
|
||||
|
||||
BOOST_MPL_ASSERT((fusion::result_of::equal_to<
|
||||
fusion::result_of::begin<empty_struct<void> >::type,
|
||||
fusion::result_of::end<empty_struct<void> >::type>));
|
||||
}
|
||||
|
||||
{
|
||||
fusion::vector<> v;
|
||||
empty_struct<void> e;
|
||||
BOOST_TEST(v <= e);
|
||||
BOOST_TEST_NOT(e > v);
|
||||
BOOST_TEST_NOT(v < e);
|
||||
BOOST_TEST(v <= e);
|
||||
BOOST_TEST_NOT(e > v);
|
||||
BOOST_TEST(e >= v);
|
||||
}
|
||||
|
||||
{
|
||||
empty_struct<void> e;
|
||||
|
||||
// conversion from empty_struct to vector
|
||||
fusion::vector<> v(e);
|
||||
v = e;
|
||||
|
||||
// FIXME
|
||||
// conversion from empty_struct to list
|
||||
//fusion::list<> l(e);
|
||||
//l = e;
|
||||
}
|
||||
|
||||
BOOST_MPL_ASSERT((mpl::is_sequence<empty_struct<void> >));
|
||||
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_struct<void>, void>));
|
||||
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_struct<void>, int>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
86
test/sequence/adapt_struct_empty.cpp
Normal file
86
test/sequence/adapt_struct_empty.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/adapted/struct/adapt_struct.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/empty.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/not_equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less_equal.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <iostream>
|
||||
|
||||
class empty_struct{};
|
||||
BOOST_FUSION_ADAPT_STRUCT(empty_struct,)
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_struct>));
|
||||
empty_struct e;
|
||||
|
||||
std::cout << e << std::endl;
|
||||
BOOST_TEST(e == make_vector());
|
||||
|
||||
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_struct>::value == 0);
|
||||
BOOST_MPL_ASSERT((fusion::result_of::empty<empty_struct>));
|
||||
|
||||
BOOST_MPL_ASSERT((fusion::result_of::equal_to<
|
||||
fusion::result_of::begin<empty_struct>::type,
|
||||
fusion::result_of::end<empty_struct>::type>));
|
||||
}
|
||||
|
||||
{
|
||||
fusion::vector<> v;
|
||||
empty_struct e;
|
||||
BOOST_TEST(v == e);
|
||||
BOOST_TEST_NOT(e != v);
|
||||
BOOST_TEST_NOT(v < e);
|
||||
BOOST_TEST(v <= e);
|
||||
BOOST_TEST_NOT(e > v);
|
||||
BOOST_TEST(e >= v);
|
||||
}
|
||||
|
||||
{
|
||||
empty_struct e;
|
||||
|
||||
// conversion from empty_struct to vector
|
||||
fusion::vector<> v(e);
|
||||
v = e;
|
||||
|
||||
// FIXME
|
||||
// conversion from empty_struct to list
|
||||
//fusion::list<> l(e);
|
||||
//l = e;
|
||||
}
|
||||
|
||||
BOOST_MPL_ASSERT((mpl::is_sequence<empty_struct>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
87
test/sequence/adapt_struct_named_empty.cpp
Normal file
87
test/sequence/adapt_struct_named_empty.cpp
Normal file
@ -0,0 +1,87 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/adapted/struct/adapt_struct_named.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/empty.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/not_equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less_equal.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <iostream>
|
||||
|
||||
class empty_struct{};
|
||||
BOOST_FUSION_ADAPT_STRUCT_NAMED(::empty_struct,empty_struct,)
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
empty_struct empty;
|
||||
{
|
||||
BOOST_MPL_ASSERT((traits::is_view<adapted::empty_struct>));
|
||||
adapted::empty_struct e(empty);
|
||||
|
||||
std::cout << e << std::endl;
|
||||
BOOST_TEST(e == make_vector());
|
||||
|
||||
BOOST_STATIC_ASSERT(fusion::result_of::size<adapted::empty_struct>::value == 0);
|
||||
BOOST_MPL_ASSERT((fusion::result_of::empty<adapted::empty_struct>));
|
||||
|
||||
BOOST_MPL_ASSERT((fusion::result_of::equal_to<
|
||||
fusion::result_of::begin<adapted::empty_struct>::type,
|
||||
fusion::result_of::end<adapted::empty_struct>::type>));
|
||||
}
|
||||
|
||||
{
|
||||
fusion::vector<> v;
|
||||
adapted::empty_struct e(empty);
|
||||
BOOST_TEST(v == e);
|
||||
BOOST_TEST_NOT(e != v);
|
||||
BOOST_TEST_NOT(v < e);
|
||||
BOOST_TEST(v <= e);
|
||||
BOOST_TEST_NOT(e > v);
|
||||
BOOST_TEST(e >= v);
|
||||
}
|
||||
|
||||
{
|
||||
adapted::empty_struct e(empty);
|
||||
|
||||
// conversion from empty_struct to vector
|
||||
fusion::vector<> v(e);
|
||||
v = e;
|
||||
|
||||
// FIXME
|
||||
// conversion from empty_struct to list
|
||||
//fusion::list<> l(e);
|
||||
//l = e;
|
||||
}
|
||||
|
||||
BOOST_MPL_ASSERT((mpl::is_sequence<adapted::empty_struct>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
87
test/sequence/adapt_tpl_adt_empty.cpp
Normal file
87
test/sequence/adapt_tpl_adt_empty.cpp
Normal file
@ -0,0 +1,87 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/adapted/adt/adapt_adt.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/empty.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/not_equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less_equal.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <iostream>
|
||||
|
||||
template <typename T>
|
||||
class empty_adt{};
|
||||
BOOST_FUSION_ADAPT_TPL_ADT((T), (empty_adt)(T),)
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_adt<void> >));
|
||||
empty_adt<void> e;
|
||||
|
||||
std::cout << e << std::endl;
|
||||
BOOST_TEST(e == make_vector());
|
||||
|
||||
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_adt<void> >::value == 0);
|
||||
BOOST_MPL_ASSERT((fusion::result_of::empty<empty_adt<void> >));
|
||||
|
||||
BOOST_MPL_ASSERT((fusion::result_of::equal_to<
|
||||
fusion::result_of::begin<empty_adt<void> >::type,
|
||||
fusion::result_of::end<empty_adt<void> >::type>));
|
||||
}
|
||||
|
||||
{
|
||||
fusion::vector<> v;
|
||||
empty_adt<void> e;
|
||||
BOOST_TEST(v == e);
|
||||
BOOST_TEST_NOT(v != e);
|
||||
BOOST_TEST_NOT(v < e);
|
||||
BOOST_TEST(v <= e);
|
||||
BOOST_TEST_NOT(e > v);
|
||||
BOOST_TEST(e >= v);
|
||||
}
|
||||
|
||||
{
|
||||
empty_adt<void> e;
|
||||
|
||||
// conversion from empty_adt to vector
|
||||
fusion::vector<> v(e);
|
||||
v = e;
|
||||
|
||||
// FIXME
|
||||
// conversion from empty_adt to list
|
||||
//fusion::list<> l(e);
|
||||
//l = e;
|
||||
}
|
||||
|
||||
BOOST_MPL_ASSERT((mpl::is_sequence<empty_adt<void> >));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
87
test/sequence/adapt_tpl_struct_empty.cpp
Normal file
87
test/sequence/adapt_tpl_struct_empty.cpp
Normal file
@ -0,0 +1,87 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/adapted/struct/adapt_struct.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/empty.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/not_equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less_equal.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <iostream>
|
||||
|
||||
template <typename T>
|
||||
class empty_struct{};
|
||||
BOOST_FUSION_ADAPT_TPL_STRUCT((T), (empty_struct)(T),)
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_struct<void> >));
|
||||
empty_struct<void> e;
|
||||
|
||||
std::cout << e << std::endl;
|
||||
BOOST_TEST(e == make_vector());
|
||||
|
||||
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_struct<void> >::value == 0);
|
||||
BOOST_MPL_ASSERT((fusion::result_of::empty<empty_struct<void> >));
|
||||
|
||||
BOOST_MPL_ASSERT((fusion::result_of::equal_to<
|
||||
fusion::result_of::begin<empty_struct<void> >::type,
|
||||
fusion::result_of::end<empty_struct<void> >::type>));
|
||||
}
|
||||
|
||||
{
|
||||
fusion::vector<> v;
|
||||
empty_struct<void> e;
|
||||
BOOST_TEST(v == e);
|
||||
BOOST_TEST_NOT(v != e);
|
||||
BOOST_TEST_NOT(v < e);
|
||||
BOOST_TEST(v <= e);
|
||||
BOOST_TEST_NOT(v > e);
|
||||
BOOST_TEST(v >= e);
|
||||
}
|
||||
|
||||
{
|
||||
empty_struct<void> e;
|
||||
|
||||
// conversion from empty_struct to vector
|
||||
fusion::vector<> v(e);
|
||||
v = e;
|
||||
|
||||
// FIXME
|
||||
// conversion from empty_struct to list
|
||||
//fusion::list<> l(e);
|
||||
//l = e;
|
||||
}
|
||||
|
||||
BOOST_MPL_ASSERT((mpl::is_sequence<empty_struct<void> >));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
322
test/sequence/conversion.hpp
Normal file
322
test/sequence/conversion.hpp
Normal file
@ -0,0 +1,322 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 Lee Clagett
|
||||
|
||||
Use modification and distribution are subject to the Boost Software
|
||||
License, Version 1.0. (See accompanyintg file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt).
|
||||
==============================================================================*/
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/adapted/boost_tuple.hpp>
|
||||
#include <boost/fusion/adapted/std_pair.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TUPLE) \
|
||||
&& !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
# include <boost/fusion/adapted/std_tuple.hpp>
|
||||
#endif
|
||||
#include <boost/fusion/container/deque.hpp>
|
||||
#include <boost/fusion/container/list.hpp>
|
||||
#include <boost/fusion/tuple.hpp>
|
||||
#include <boost/fusion/container/vector.hpp>
|
||||
|
||||
#include "fixture.hpp"
|
||||
|
||||
template <template <typename> class Scenario>
|
||||
void test()
|
||||
{
|
||||
using namespace test_detail;
|
||||
|
||||
// Note the trunction conversion tests from each containter
|
||||
// ... bug or feature?
|
||||
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
boost::fusion::push_back(FUSION_SEQUENCE<int>(300), 400)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible> > >(
|
||||
boost::fusion::push_back(FUSION_SEQUENCE<int>(200), 400)
|
||||
, FUSION_SEQUENCE<convertible>(200)
|
||||
)
|
||||
));
|
||||
|
||||
BOOST_TEST((run<Scenario<FUSION_SEQUENCE<> > >(boost::fusion::vector<>())));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<> > >(
|
||||
boost::fusion::vector<int>(100), boost::fusion::vector<>()
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible> > >(
|
||||
boost::fusion::vector<int>(110)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible> > >(
|
||||
boost::fusion::vector<int, int>(200, 100)
|
||||
, boost::fusion::vector<convertible>(200)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
boost::fusion::vector<int, int>(200, 400)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
boost::fusion::vector<int, int, int>(500, 400, 100)
|
||||
, boost::fusion::vector<convertible, int>(500, 400)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
boost::fusion::push_back(
|
||||
boost::fusion::vector<int>(500), 400
|
||||
)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
boost::fusion::push_back(
|
||||
boost::fusion::vector<int, int>(500, 400), 100
|
||||
)
|
||||
, boost::fusion::vector<convertible, int>(500, 400)
|
||||
)
|
||||
));
|
||||
|
||||
BOOST_TEST((run<Scenario< FUSION_SEQUENCE<> > >(boost::fusion::deque<>())));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<> > >(
|
||||
boost::fusion::deque<int>(100), boost::fusion::deque<>()
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible> > >(
|
||||
boost::fusion::deque<int>(500)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible> > >(
|
||||
boost::fusion::deque<int, int>(500, 100)
|
||||
, boost::fusion::deque<convertible>(500)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
boost::fusion::deque<int, int>(500, 400)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
boost::fusion::deque<int, int, int>(500, 400, 100)
|
||||
, boost::fusion::deque<convertible, int>(500, 400)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
boost::fusion::push_back(
|
||||
boost::fusion::deque<int>(500), 400
|
||||
)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
boost::fusion::push_back(
|
||||
boost::fusion::deque<int, int>(500, 400), 100
|
||||
)
|
||||
, boost::fusion::deque<convertible, int>(500, 400)
|
||||
)
|
||||
));
|
||||
|
||||
BOOST_TEST((run< Scenario< FUSION_SEQUENCE<> > >(boost::fusion::list<>())));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<> > >(
|
||||
boost::fusion::list<int>(100), boost::fusion::list<>()
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible> > >(
|
||||
boost::fusion::list<int>(500)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible> > >(
|
||||
boost::fusion::list<int, int>(500, 100)
|
||||
, boost::fusion::list<convertible>(500)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
boost::fusion::list<int, int>(500, 400)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
boost::fusion::list<int, int, int>(500, 400, 100)
|
||||
, boost::fusion::list<convertible, int>(500, 400)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
boost::fusion::push_back(
|
||||
boost::fusion::list<int>(500), 400
|
||||
)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
boost::fusion::push_back(
|
||||
boost::fusion::list<int, int>(500, 400), 100
|
||||
)
|
||||
, boost::fusion::list<convertible, int>(500, 400)
|
||||
)
|
||||
));
|
||||
|
||||
BOOST_TEST((run<Scenario< FUSION_SEQUENCE<> > >(boost::fusion::tuple<>())));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<> > >(
|
||||
boost::fusion::tuple<int>(100), boost::fusion::tuple<>()
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible> > >(
|
||||
boost::fusion::tuple<int>(500)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible> > >(
|
||||
boost::fusion::tuple<int, int>(500, 100)
|
||||
, boost::fusion::tuple<convertible>(500)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
boost::fusion::tuple<int, int>(500, 400)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
boost::fusion::tuple<int, int, int>(500, 400, 100)
|
||||
, boost::fusion::tuple<convertible, int>(500, 400)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
boost::fusion::push_back(
|
||||
boost::fusion::tuple<int>(500), 400
|
||||
)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
boost::fusion::push_back(
|
||||
boost::fusion::tuple<int, int>(500, 400), 100
|
||||
)
|
||||
, boost::fusion::tuple<convertible, int>(500, 400)
|
||||
)
|
||||
));
|
||||
|
||||
BOOST_TEST((run< Scenario< FUSION_SEQUENCE<> > >(boost::tuple<>())));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<> > >(
|
||||
boost::tuple<int>(100), boost::tuple<>()
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible> > >(
|
||||
boost::tuple<int>(500)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible> > >(
|
||||
boost::tuple<int, int>(500, 100)
|
||||
, boost::tuple<convertible>(500)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
boost::tuple<int, int>(500, 400)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
boost::tuple<int, int, int>(500, 400, 100)
|
||||
, boost::tuple<convertible, int>(500, 400)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
boost::fusion::push_back(boost::tuple<int>(500), 400)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
boost::fusion::push_back(
|
||||
boost::tuple<int, int>(500, 400), 100
|
||||
)
|
||||
, boost::tuple<convertible, int>(500, 400)
|
||||
)
|
||||
));
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TUPLE) \
|
||||
&& !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
BOOST_TEST((run< Scenario< FUSION_SEQUENCE<> > >(std::tuple<>())));
|
||||
BOOST_TEST((
|
||||
run<Scenario<FUSION_SEQUENCE<> > >(std::tuple<int>(100), std::tuple<>())
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible> > >(
|
||||
std::tuple<int>(500)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible> > >(
|
||||
std::tuple<int, int>(500, 100)
|
||||
, std::tuple<convertible>(500)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
std::tuple<int, int>(500, 400)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
std::tuple<int, int, int>(500, 400, 100)
|
||||
, std::tuple<convertible, int>(500, 400)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
boost::fusion::push_back(std::tuple<int>(500), 400)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
boost::fusion::push_back(
|
||||
std::tuple<int, int>(500, 400), 100
|
||||
)
|
||||
, std::tuple<convertible, int>(500, 400)
|
||||
)
|
||||
));
|
||||
#endif
|
||||
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
std::pair<int, int>(500, 400)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<> > >(
|
||||
std::pair<int, int>(500, 400)
|
||||
, boost::fusion::vector<>()
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible> > >(
|
||||
std::pair<int, int>(500, 400)
|
||||
, boost::fusion::vector<convertible>(500)
|
||||
)
|
||||
));
|
||||
}
|
@ -5,6 +5,8 @@
|
||||
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 <string>
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
@ -15,6 +17,8 @@
|
||||
#include <boost/mpl/equal.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
#include "fixture.hpp"
|
||||
|
||||
#if !defined(FUSION_AT)
|
||||
#define FUSION_AT at_c
|
||||
#endif
|
||||
@ -36,12 +40,6 @@ namespace test_detail
|
||||
struct DD { operator CC() const { return CC(); }; };
|
||||
}
|
||||
|
||||
boost::fusion::FUSION_SEQUENCE<double, double, double, double>
|
||||
foo(int i)
|
||||
{
|
||||
return boost::fusion::FUSION_MAKE(i, i+1, i+2, i+3);
|
||||
}
|
||||
|
||||
void test_mpl()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
@ -60,6 +58,7 @@ void test_mpl()
|
||||
BOOST_STATIC_ASSERT(equal::value);
|
||||
}
|
||||
|
||||
template <template <typename> class Scenario>
|
||||
void
|
||||
test()
|
||||
{
|
||||
@ -77,6 +76,9 @@ test()
|
||||
BOOST_TEST((double)FUSION_AT<0>(t1) == FUSION_AT<0>(t3));
|
||||
BOOST_TEST(FUSION_AT<1>(t1) == FUSION_AT<1>(t3)[0]);
|
||||
|
||||
BOOST_TEST(FUSION_AT<0>(t1) == 4);
|
||||
BOOST_TEST(FUSION_AT<1>(t1) == 'a');
|
||||
|
||||
// testing copy and assignment with implicit conversions
|
||||
// between elements testing tie
|
||||
|
||||
@ -91,8 +93,62 @@ test()
|
||||
BOOST_TEST(c=='a');
|
||||
BOOST_TEST(d>5.4 && d<5.6);
|
||||
|
||||
// returning a tuple with conversion
|
||||
foo(2);
|
||||
|
||||
test_mpl();
|
||||
|
||||
|
||||
BOOST_TEST((run< Scenario< FUSION_SEQUENCE<> > >(FUSION_SEQUENCE<>())));
|
||||
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<int> > >(FUSION_SEQUENCE<int>(500))
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible> > >(
|
||||
FUSION_SEQUENCE<int>(500)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<int> > >(
|
||||
FUSION_SEQUENCE<int, int>(500, 100)
|
||||
, FUSION_SEQUENCE<int>(500)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible> > >(
|
||||
FUSION_SEQUENCE<int, int>(500, 100)
|
||||
, FUSION_SEQUENCE<convertible>(500)
|
||||
)
|
||||
));
|
||||
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<int, int> > >(
|
||||
FUSION_SEQUENCE<int, int>(500, 600)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
|
||||
FUSION_SEQUENCE<convertible, int>(100, 500)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<int, convertible> > >(
|
||||
FUSION_SEQUENCE<int, convertible>(500, 600)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, convertible> > >(
|
||||
FUSION_SEQUENCE<int, int>(400, 500)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<int, int> > >(
|
||||
FUSION_SEQUENCE<int, int, int>(500, 100, 323)
|
||||
, FUSION_SEQUENCE<int, int>(500, 100)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<convertible, convertible> > >(
|
||||
FUSION_SEQUENCE<int, int, int>(500, 600, 100)
|
||||
, FUSION_SEQUENCE<convertible, convertible>(500, 600)
|
||||
)
|
||||
));
|
||||
}
|
||||
|
@ -29,6 +29,8 @@ BOOST_FUSION_DEFINE_ASSOC_STRUCT(
|
||||
(int, y, ns::y_member)
|
||||
)
|
||||
|
||||
BOOST_FUSION_DEFINE_ASSOC_STRUCT(BOOST_PP_EMPTY(), empty_struct, )
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
|
77
test/sequence/define_assoc_struct_empty.cpp
Normal file
77
test/sequence/define_assoc_struct_empty.cpp
Normal file
@ -0,0 +1,77 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container.hpp>
|
||||
#include <boost/fusion/sequence.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/adapted/struct/define_assoc_struct.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <iostream>
|
||||
|
||||
BOOST_FUSION_DEFINE_ASSOC_STRUCT(BOOST_PP_EMPTY(), empty_struct, )
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost;
|
||||
using namespace boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_struct>));
|
||||
empty_struct e;
|
||||
|
||||
std::cout << e << std::endl;
|
||||
BOOST_TEST(e == make_vector());
|
||||
|
||||
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_struct>::value == 0);
|
||||
BOOST_STATIC_ASSERT(fusion::result_of::empty<empty_struct>::value);
|
||||
}
|
||||
|
||||
{
|
||||
vector<> v;
|
||||
empty_struct e;
|
||||
BOOST_TEST(v == e);
|
||||
BOOST_TEST_NOT(v != e);
|
||||
BOOST_TEST_NOT(v < e);
|
||||
BOOST_TEST(v <= e);
|
||||
BOOST_TEST_NOT(v > e);
|
||||
BOOST_TEST(v >= e);
|
||||
}
|
||||
|
||||
{
|
||||
empty_struct e;
|
||||
|
||||
// conversion from empty_struct to vector
|
||||
vector<> v(e);
|
||||
v = e;
|
||||
|
||||
// conversion from empty_struct to list
|
||||
//list<> l(e);
|
||||
//l = e;
|
||||
}
|
||||
|
||||
{ // begin/end
|
||||
typedef fusion::result_of::begin<empty_struct>::type b;
|
||||
typedef fusion::result_of::end<empty_struct>::type e;
|
||||
|
||||
BOOST_MPL_ASSERT((fusion::result_of::equal_to<b, e>));
|
||||
}
|
||||
|
||||
BOOST_MPL_ASSERT((mpl::is_sequence<empty_struct>));
|
||||
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_struct, void>));
|
||||
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_struct, int>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
78
test/sequence/define_assoc_struct_move.cpp
Normal file
78
test/sequence/define_assoc_struct_move.cpp
Normal file
@ -0,0 +1,78 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 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>
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/adapted/struct/define_assoc_struct.hpp>
|
||||
#include <utility>
|
||||
|
||||
struct key_type;
|
||||
struct wrapper
|
||||
{
|
||||
int value;
|
||||
|
||||
wrapper() : value(42) {}
|
||||
wrapper(wrapper&& other) : value(other.value) { other.value = 0; }
|
||||
wrapper(wrapper const& other) : value(other.value) {}
|
||||
|
||||
wrapper& operator=(wrapper&& other) { value = other.value; other.value = 0; return *this; }
|
||||
wrapper& operator=(wrapper const& other) { value = other.value; return *this; }
|
||||
};
|
||||
BOOST_FUSION_DEFINE_ASSOC_STRUCT((ns), value, (wrapper, w, key_type))
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
{
|
||||
ns::value x;
|
||||
ns::value y(x); // copy
|
||||
|
||||
BOOST_TEST(x.w.value == 42);
|
||||
BOOST_TEST(y.w.value == 42);
|
||||
|
||||
++y.w.value;
|
||||
|
||||
BOOST_TEST(x.w.value == 42);
|
||||
BOOST_TEST(y.w.value == 43);
|
||||
|
||||
y = x; // copy assign
|
||||
|
||||
BOOST_TEST(x.w.value == 42);
|
||||
BOOST_TEST(y.w.value == 42);
|
||||
}
|
||||
|
||||
{
|
||||
ns::value x;
|
||||
ns::value y(std::move(x)); // move
|
||||
|
||||
BOOST_TEST(x.w.value == 0);
|
||||
BOOST_TEST(y.w.value == 42);
|
||||
|
||||
++y.w.value;
|
||||
|
||||
BOOST_TEST(x.w.value == 0);
|
||||
BOOST_TEST(y.w.value == 43);
|
||||
|
||||
y = std::move(x); // move assign
|
||||
|
||||
BOOST_TEST(x.w.value == 0);
|
||||
BOOST_TEST(y.w.value == 0);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
@ -31,6 +31,8 @@ BOOST_FUSION_DEFINE_ASSOC_TPL_STRUCT(
|
||||
(int, y, ns::y_member)
|
||||
)
|
||||
|
||||
BOOST_FUSION_DEFINE_ASSOC_TPL_STRUCT((M), BOOST_PP_EMPTY(), empty_struct, )
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
|
77
test/sequence/define_assoc_tpl_struct_empty.cpp
Normal file
77
test/sequence/define_assoc_tpl_struct_empty.cpp
Normal file
@ -0,0 +1,77 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container.hpp>
|
||||
#include <boost/fusion/sequence.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/adapted/struct/define_assoc_struct.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <iostream>
|
||||
|
||||
BOOST_FUSION_DEFINE_ASSOC_TPL_STRUCT((M), BOOST_PP_EMPTY(), empty_struct, )
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost;
|
||||
using namespace boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_struct<void> >));
|
||||
empty_struct<void> e;
|
||||
|
||||
std::cout << e << std::endl;
|
||||
BOOST_TEST(e == make_vector());
|
||||
|
||||
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_struct<void> >::value == 0);
|
||||
BOOST_STATIC_ASSERT(fusion::result_of::empty<empty_struct<void> >::value);
|
||||
}
|
||||
|
||||
{
|
||||
vector<> v;
|
||||
empty_struct<void> e;
|
||||
BOOST_TEST(v == e);
|
||||
BOOST_TEST_NOT(v != e);
|
||||
BOOST_TEST_NOT(v < e);
|
||||
BOOST_TEST(v <= e);
|
||||
BOOST_TEST_NOT(v > e);
|
||||
BOOST_TEST(v >= e);
|
||||
}
|
||||
|
||||
{
|
||||
empty_struct<void> e;
|
||||
|
||||
// conversion from empty_struct to vector
|
||||
vector<> v(e);
|
||||
v = e;
|
||||
|
||||
// conversion from empty_struct to list
|
||||
//list<> l(e);
|
||||
//l = e;
|
||||
}
|
||||
|
||||
{ // begin/end
|
||||
typedef fusion::result_of::begin<empty_struct<void> >::type b;
|
||||
typedef fusion::result_of::end<empty_struct<void> >::type e;
|
||||
|
||||
BOOST_MPL_ASSERT((fusion::result_of::equal_to<b, e>));
|
||||
}
|
||||
|
||||
BOOST_MPL_ASSERT((mpl::is_sequence<empty_struct<void> >));
|
||||
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_struct<void>, void>));
|
||||
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_struct<void>, int>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
78
test/sequence/define_assoc_tpl_struct_move.cpp
Normal file
78
test/sequence/define_assoc_tpl_struct_move.cpp
Normal file
@ -0,0 +1,78 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 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>
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/adapted/struct/define_assoc_struct.hpp>
|
||||
#include <utility>
|
||||
|
||||
struct key_type;
|
||||
struct wrapper
|
||||
{
|
||||
int value;
|
||||
|
||||
wrapper() : value(42) {}
|
||||
wrapper(wrapper&& other) : value(other.value) { other.value = 0; }
|
||||
wrapper(wrapper const& other) : value(other.value) {}
|
||||
|
||||
wrapper& operator=(wrapper&& other) { value = other.value; other.value = 0; return *this; }
|
||||
wrapper& operator=(wrapper const& other) { value = other.value; return *this; }
|
||||
};
|
||||
BOOST_FUSION_DEFINE_ASSOC_TPL_STRUCT((W), (ns), value, (W, w, key_type))
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
{
|
||||
ns::value<wrapper> x;
|
||||
ns::value<wrapper> y(x); // copy
|
||||
|
||||
BOOST_TEST(x.w.value == 42);
|
||||
BOOST_TEST(y.w.value == 42);
|
||||
|
||||
++y.w.value;
|
||||
|
||||
BOOST_TEST(x.w.value == 42);
|
||||
BOOST_TEST(y.w.value == 43);
|
||||
|
||||
y = x; // copy assign
|
||||
|
||||
BOOST_TEST(x.w.value == 42);
|
||||
BOOST_TEST(y.w.value == 42);
|
||||
}
|
||||
|
||||
{
|
||||
ns::value<wrapper> x;
|
||||
ns::value<wrapper> y(std::move(x)); // move
|
||||
|
||||
BOOST_TEST(x.w.value == 0);
|
||||
BOOST_TEST(y.w.value == 42);
|
||||
|
||||
++y.w.value;
|
||||
|
||||
BOOST_TEST(x.w.value == 0);
|
||||
BOOST_TEST(y.w.value == 43);
|
||||
|
||||
y = std::move(x); // move assign
|
||||
|
||||
BOOST_TEST(x.w.value == 0);
|
||||
BOOST_TEST(y.w.value == 0);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
@ -33,6 +33,8 @@ BOOST_FUSION_DEFINE_STRUCT(
|
||||
|
||||
BOOST_FUSION_DEFINE_STRUCT(BOOST_PP_EMPTY(), s, (int, m))
|
||||
|
||||
BOOST_FUSION_DEFINE_STRUCT(BOOST_PP_EMPTY(), empty_struct, )
|
||||
|
||||
// Testing non-constexpr compatible types
|
||||
BOOST_FUSION_DEFINE_STRUCT(
|
||||
(ns),
|
||||
|
75
test/sequence/define_struct_empty.cpp
Normal file
75
test/sequence/define_struct_empty.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container.hpp>
|
||||
#include <boost/fusion/sequence.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/adapted/struct/define_struct.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <iostream>
|
||||
|
||||
BOOST_FUSION_DEFINE_STRUCT(BOOST_PP_EMPTY(), empty_struct, )
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost;
|
||||
using namespace boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_struct>));
|
||||
empty_struct e;
|
||||
|
||||
std::cout << e << std::endl;
|
||||
BOOST_TEST(e == make_vector());
|
||||
|
||||
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_struct>::value == 0);
|
||||
BOOST_STATIC_ASSERT(fusion::result_of::empty<empty_struct>::value);
|
||||
}
|
||||
|
||||
{
|
||||
vector<> v;
|
||||
empty_struct e;
|
||||
BOOST_TEST(v == e);
|
||||
BOOST_TEST_NOT(v != e);
|
||||
BOOST_TEST_NOT(v < e);
|
||||
BOOST_TEST(v <= e);
|
||||
BOOST_TEST_NOT(v > e);
|
||||
BOOST_TEST(v >= e);
|
||||
}
|
||||
|
||||
{
|
||||
empty_struct e;
|
||||
|
||||
// conversion from empty_struct to vector
|
||||
vector<> v(e);
|
||||
v = e;
|
||||
|
||||
// conversion from empty_struct to list
|
||||
//list<> l(e);
|
||||
//l = e;
|
||||
}
|
||||
|
||||
{ // begin/end
|
||||
typedef fusion::result_of::begin<empty_struct>::type b;
|
||||
typedef fusion::result_of::end<empty_struct>::type e;
|
||||
|
||||
BOOST_MPL_ASSERT((fusion::result_of::equal_to<b, e>));
|
||||
}
|
||||
|
||||
BOOST_MPL_ASSERT((mpl::is_sequence<empty_struct>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
75
test/sequence/define_struct_inline_empty.cpp
Normal file
75
test/sequence/define_struct_inline_empty.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container.hpp>
|
||||
#include <boost/fusion/sequence.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/adapted/struct/define_struct_inline.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <iostream>
|
||||
|
||||
BOOST_FUSION_DEFINE_STRUCT_INLINE(empty_struct, )
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost;
|
||||
using namespace boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_struct>));
|
||||
empty_struct e;
|
||||
|
||||
std::cout << e << std::endl;
|
||||
BOOST_TEST(e == make_vector());
|
||||
|
||||
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_struct>::value == 0);
|
||||
BOOST_STATIC_ASSERT(fusion::result_of::empty<empty_struct>::value);
|
||||
}
|
||||
|
||||
{
|
||||
vector<> v;
|
||||
empty_struct e;
|
||||
BOOST_TEST(v == e);
|
||||
BOOST_TEST_NOT(v != e);
|
||||
BOOST_TEST_NOT(v < e);
|
||||
BOOST_TEST(v <= e);
|
||||
BOOST_TEST_NOT(v > e);
|
||||
BOOST_TEST(v >= e);
|
||||
}
|
||||
|
||||
{
|
||||
empty_struct e;
|
||||
|
||||
// conversion from empty_struct to vector
|
||||
vector<> v(e);
|
||||
v = e;
|
||||
|
||||
// conversion from empty_struct to list
|
||||
//list<> l(e);
|
||||
//l = e;
|
||||
}
|
||||
|
||||
{ // begin/end
|
||||
typedef fusion::result_of::begin<empty_struct>::type b;
|
||||
typedef fusion::result_of::end<empty_struct>::type e;
|
||||
|
||||
BOOST_MPL_ASSERT((fusion::result_of::equal_to<b, e>));
|
||||
}
|
||||
|
||||
BOOST_MPL_ASSERT((mpl::is_sequence<empty_struct>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
81
test/sequence/define_struct_inline_move.cpp
Normal file
81
test/sequence/define_struct_inline_move.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 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>
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/adapted/struct/define_struct_inline.hpp>
|
||||
#include <utility>
|
||||
|
||||
struct wrapper
|
||||
{
|
||||
int value;
|
||||
|
||||
wrapper() : value(42) {}
|
||||
wrapper(wrapper&& other) : value(other.value) { other.value = 0; }
|
||||
wrapper(wrapper const& other) : value(other.value) {}
|
||||
|
||||
wrapper& operator=(wrapper&& other) { value = other.value; other.value = 0; return *this; }
|
||||
wrapper& operator=(wrapper const& other) { value = other.value; return *this; }
|
||||
};
|
||||
|
||||
namespace ns
|
||||
{
|
||||
BOOST_FUSION_DEFINE_STRUCT_INLINE(value, (wrapper, w))
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
{
|
||||
ns::value x;
|
||||
ns::value y(x); // copy
|
||||
|
||||
BOOST_TEST(x.w.value == 42);
|
||||
BOOST_TEST(y.w.value == 42);
|
||||
|
||||
++y.w.value;
|
||||
|
||||
BOOST_TEST(x.w.value == 42);
|
||||
BOOST_TEST(y.w.value == 43);
|
||||
|
||||
y = x; // copy assign
|
||||
|
||||
BOOST_TEST(x.w.value == 42);
|
||||
BOOST_TEST(y.w.value == 42);
|
||||
}
|
||||
|
||||
{
|
||||
ns::value x;
|
||||
ns::value y(std::move(x)); // move
|
||||
|
||||
BOOST_TEST(x.w.value == 0);
|
||||
BOOST_TEST(y.w.value == 42);
|
||||
|
||||
++y.w.value;
|
||||
|
||||
BOOST_TEST(x.w.value == 0);
|
||||
BOOST_TEST(y.w.value == 43);
|
||||
|
||||
y = std::move(x); // move assign
|
||||
|
||||
BOOST_TEST(x.w.value == 0);
|
||||
BOOST_TEST(y.w.value == 0);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
77
test/sequence/define_struct_move.cpp
Normal file
77
test/sequence/define_struct_move.cpp
Normal file
@ -0,0 +1,77 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 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>
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/adapted/struct/define_struct.hpp>
|
||||
#include <utility>
|
||||
|
||||
struct wrapper
|
||||
{
|
||||
int value;
|
||||
|
||||
wrapper() : value(42) {}
|
||||
wrapper(wrapper&& other) : value(other.value) { other.value = 0; }
|
||||
wrapper(wrapper const& other) : value(other.value) {}
|
||||
|
||||
wrapper& operator=(wrapper&& other) { value = other.value; other.value = 0; return *this; }
|
||||
wrapper& operator=(wrapper const& other) { value = other.value; return *this; }
|
||||
};
|
||||
BOOST_FUSION_DEFINE_STRUCT((ns), value, (wrapper, w))
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
{
|
||||
ns::value x;
|
||||
ns::value y(x); // copy
|
||||
|
||||
BOOST_TEST(x.w.value == 42);
|
||||
BOOST_TEST(y.w.value == 42);
|
||||
|
||||
++y.w.value;
|
||||
|
||||
BOOST_TEST(x.w.value == 42);
|
||||
BOOST_TEST(y.w.value == 43);
|
||||
|
||||
y = x; // copy assign
|
||||
|
||||
BOOST_TEST(x.w.value == 42);
|
||||
BOOST_TEST(y.w.value == 42);
|
||||
}
|
||||
|
||||
{
|
||||
ns::value x;
|
||||
ns::value y(std::move(x)); // move
|
||||
|
||||
BOOST_TEST(x.w.value == 0);
|
||||
BOOST_TEST(y.w.value == 42);
|
||||
|
||||
++y.w.value;
|
||||
|
||||
BOOST_TEST(x.w.value == 0);
|
||||
BOOST_TEST(y.w.value == 43);
|
||||
|
||||
y = std::move(x); // move assign
|
||||
|
||||
BOOST_TEST(x.w.value == 0);
|
||||
BOOST_TEST(y.w.value == 0);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
@ -27,6 +27,8 @@ BOOST_FUSION_DEFINE_TPL_STRUCT(
|
||||
|
||||
BOOST_FUSION_DEFINE_TPL_STRUCT((M), BOOST_PP_EMPTY(), s, (M, m))
|
||||
|
||||
BOOST_FUSION_DEFINE_TPL_STRUCT((M), BOOST_PP_EMPTY(), empty_struct, )
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
|
75
test/sequence/define_tpl_struct_empty.cpp
Normal file
75
test/sequence/define_tpl_struct_empty.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container.hpp>
|
||||
#include <boost/fusion/sequence.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/adapted/struct/define_struct.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <iostream>
|
||||
|
||||
BOOST_FUSION_DEFINE_TPL_STRUCT((M), BOOST_PP_EMPTY(), empty_struct, )
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost;
|
||||
using namespace boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_struct<void> >));
|
||||
empty_struct<void> e;
|
||||
|
||||
std::cout << e << std::endl;
|
||||
BOOST_TEST(e == make_vector());
|
||||
|
||||
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_struct<void> >::value == 0);
|
||||
BOOST_STATIC_ASSERT(fusion::result_of::empty<empty_struct<void> >::value);
|
||||
}
|
||||
|
||||
{
|
||||
vector<> v;
|
||||
empty_struct<void> e;
|
||||
BOOST_TEST(v == e);
|
||||
BOOST_TEST_NOT(v != e);
|
||||
BOOST_TEST_NOT(v < e);
|
||||
BOOST_TEST(v <= e);
|
||||
BOOST_TEST_NOT(v > e);
|
||||
BOOST_TEST(v >= e);
|
||||
}
|
||||
|
||||
{
|
||||
empty_struct<void> e;
|
||||
|
||||
// conversion from empty_struct to vector
|
||||
vector<> v(e);
|
||||
v = e;
|
||||
|
||||
// conversion from empty_struct to list
|
||||
//list<> l(e);
|
||||
//l = e;
|
||||
}
|
||||
|
||||
{ // begin/end
|
||||
typedef fusion::result_of::begin<empty_struct<void> >::type b;
|
||||
typedef fusion::result_of::end<empty_struct<void> >::type e;
|
||||
|
||||
BOOST_MPL_ASSERT((fusion::result_of::equal_to<b, e>));
|
||||
}
|
||||
|
||||
BOOST_MPL_ASSERT((mpl::is_sequence<empty_struct<void> >));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
75
test/sequence/define_tpl_struct_inline_empty.cpp
Normal file
75
test/sequence/define_tpl_struct_inline_empty.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container.hpp>
|
||||
#include <boost/fusion/sequence.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/adapted/struct/define_struct_inline.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <iostream>
|
||||
|
||||
BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE((M), empty_struct, )
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost;
|
||||
using namespace boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_struct<void> >));
|
||||
empty_struct<void> e;
|
||||
|
||||
std::cout << e << std::endl;
|
||||
BOOST_TEST(e == make_vector());
|
||||
|
||||
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_struct<void> >::value == 0);
|
||||
BOOST_STATIC_ASSERT(fusion::result_of::empty<empty_struct<void> >::value);
|
||||
}
|
||||
|
||||
{
|
||||
vector<> v;
|
||||
empty_struct<void> e;
|
||||
BOOST_TEST(v == e);
|
||||
BOOST_TEST_NOT(v != e);
|
||||
BOOST_TEST_NOT(v < e);
|
||||
BOOST_TEST(v <= e);
|
||||
BOOST_TEST_NOT(v > e);
|
||||
BOOST_TEST(v >= e);
|
||||
}
|
||||
|
||||
{
|
||||
empty_struct<void> e;
|
||||
|
||||
// conversion from empty_struct to vector
|
||||
vector<> v(e);
|
||||
v = e;
|
||||
|
||||
// conversion from empty_struct to list
|
||||
//list<> l(e);
|
||||
//l = e;
|
||||
}
|
||||
|
||||
{ // begin/end
|
||||
typedef fusion::result_of::begin<empty_struct<void> >::type b;
|
||||
typedef fusion::result_of::end<empty_struct<void> >::type e;
|
||||
|
||||
BOOST_MPL_ASSERT((fusion::result_of::equal_to<b, e>));
|
||||
}
|
||||
|
||||
BOOST_MPL_ASSERT((mpl::is_sequence<empty_struct<void> >));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
81
test/sequence/define_tpl_struct_inline_move.cpp
Normal file
81
test/sequence/define_tpl_struct_inline_move.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 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>
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/adapted/struct/define_struct_inline.hpp>
|
||||
#include <utility>
|
||||
|
||||
struct wrapper
|
||||
{
|
||||
int value;
|
||||
|
||||
wrapper() : value(42) {}
|
||||
wrapper(wrapper&& other) : value(other.value) { other.value = 0; }
|
||||
wrapper(wrapper const& other) : value(other.value) {}
|
||||
|
||||
wrapper& operator=(wrapper&& other) { value = other.value; other.value = 0; return *this; }
|
||||
wrapper& operator=(wrapper const& other) { value = other.value; return *this; }
|
||||
};
|
||||
|
||||
namespace ns
|
||||
{
|
||||
BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE((W), value, (W, w))
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
{
|
||||
ns::value<wrapper> x;
|
||||
ns::value<wrapper> y(x); // copy
|
||||
|
||||
BOOST_TEST(x.w.value == 42);
|
||||
BOOST_TEST(y.w.value == 42);
|
||||
|
||||
++y.w.value;
|
||||
|
||||
BOOST_TEST(x.w.value == 42);
|
||||
BOOST_TEST(y.w.value == 43);
|
||||
|
||||
y = x; // copy assign
|
||||
|
||||
BOOST_TEST(x.w.value == 42);
|
||||
BOOST_TEST(y.w.value == 42);
|
||||
}
|
||||
|
||||
{
|
||||
ns::value<wrapper> x;
|
||||
ns::value<wrapper> y(std::move(x)); // move
|
||||
|
||||
BOOST_TEST(x.w.value == 0);
|
||||
BOOST_TEST(y.w.value == 42);
|
||||
|
||||
++y.w.value;
|
||||
|
||||
BOOST_TEST(x.w.value == 0);
|
||||
BOOST_TEST(y.w.value == 43);
|
||||
|
||||
y = std::move(x); // move assign
|
||||
|
||||
BOOST_TEST(x.w.value == 0);
|
||||
BOOST_TEST(y.w.value == 0);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
77
test/sequence/define_tpl_struct_move.cpp
Normal file
77
test/sequence/define_tpl_struct_move.cpp
Normal file
@ -0,0 +1,77 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 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>
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/adapted/struct/define_struct.hpp>
|
||||
#include <utility>
|
||||
|
||||
struct wrapper
|
||||
{
|
||||
int value;
|
||||
|
||||
wrapper() : value(42) {}
|
||||
wrapper(wrapper&& other) : value(other.value) { other.value = 0; }
|
||||
wrapper(wrapper const& other) : value(other.value) {}
|
||||
|
||||
wrapper& operator=(wrapper&& other) { value = other.value; other.value = 0; return *this; }
|
||||
wrapper& operator=(wrapper const& other) { value = other.value; return *this; }
|
||||
};
|
||||
BOOST_FUSION_DEFINE_TPL_STRUCT((W), (ns), value, (W, w))
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
{
|
||||
ns::value<wrapper> x;
|
||||
ns::value<wrapper> y(x); // copy
|
||||
|
||||
BOOST_TEST(x.w.value == 42);
|
||||
BOOST_TEST(y.w.value == 42);
|
||||
|
||||
++y.w.value;
|
||||
|
||||
BOOST_TEST(x.w.value == 42);
|
||||
BOOST_TEST(y.w.value == 43);
|
||||
|
||||
y = x; // copy assign
|
||||
|
||||
BOOST_TEST(x.w.value == 42);
|
||||
BOOST_TEST(y.w.value == 42);
|
||||
}
|
||||
|
||||
{
|
||||
ns::value<wrapper> x;
|
||||
ns::value<wrapper> y(std::move(x)); // move
|
||||
|
||||
BOOST_TEST(x.w.value == 0);
|
||||
BOOST_TEST(y.w.value == 42);
|
||||
|
||||
++y.w.value;
|
||||
|
||||
BOOST_TEST(x.w.value == 0);
|
||||
BOOST_TEST(y.w.value == 43);
|
||||
|
||||
y = std::move(x); // move assign
|
||||
|
||||
BOOST_TEST(x.w.value == 0);
|
||||
BOOST_TEST(y.w.value == 0);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
@ -13,10 +13,30 @@
|
||||
#define FUSION_SEQUENCE deque
|
||||
#include "copy.hpp"
|
||||
|
||||
using namespace test_detail;
|
||||
|
||||
// c++11 deque has bug, cannot properly copy-assign from a const value
|
||||
template <typename T>
|
||||
struct skip_const_lvalue_assignment
|
||||
{
|
||||
template <typename Source, typename Expected>
|
||||
bool operator()(Source const& source, Expected const& expected) const
|
||||
{
|
||||
return
|
||||
run< can_implicit_construct<T> >(source, expected) &&
|
||||
run< can_construct<T> >(source, expected) &&
|
||||
run< can_rvalue_assign<T> >(source, expected) &&
|
||||
run< can_lvalue_assign<T> >(source, expected);
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
#if defined(BOOST_FUSION_HAS_VARIADIC_DEQUE)
|
||||
test<skip_const_lvalue_assignment>();
|
||||
#else
|
||||
test<can_copy>();
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
@ -7,13 +7,37 @@
|
||||
#include <boost/fusion/container/deque/deque.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE deque
|
||||
#define FUSION_SEQUENCE boost::fusion::deque
|
||||
#include "nest.hpp"
|
||||
|
||||
/* deque has a few issues:
|
||||
- sequence conversion constructor is explicit
|
||||
- assignment sequence conversion has bug in base class
|
||||
- c++11 direct assignment from lvalue has bug */
|
||||
template <typename T>
|
||||
struct skip_issues
|
||||
{
|
||||
template <typename Source, typename Expected>
|
||||
bool operator()(Source const& source, Expected const& expected) const
|
||||
{
|
||||
using namespace test_detail;
|
||||
return
|
||||
#if defined(BOOST_FUSION_HAS_VARIADIC_DEQUE)
|
||||
run< can_construct<T> >(source, expected) &&
|
||||
run< can_implicit_construct<T> >(source, expected) &&
|
||||
run< can_rvalue_assign<T> >(source, expected) &&
|
||||
run< can_convert_using<can_construct>::to<T> >(source, expected) &&
|
||||
#else
|
||||
run< can_copy<T> >(source, expected) &&
|
||||
#endif
|
||||
run< can_construct_from_elements<T> >(source, expected);
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
test<skip_issues>();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
216
test/sequence/fixture.hpp
Normal file
216
test/sequence/fixture.hpp
Normal file
@ -0,0 +1,216 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 Lee Clagett
|
||||
|
||||
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/comparison.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
|
||||
namespace test_detail
|
||||
{
|
||||
struct convertible
|
||||
{
|
||||
convertible() : value_() {}
|
||||
convertible(int value) : value_(value) {}
|
||||
int value_;
|
||||
};
|
||||
|
||||
bool operator==(convertible const& lhs, convertible const& rhs)
|
||||
{
|
||||
return lhs.value_ == rhs.value_;
|
||||
}
|
||||
|
||||
bool operator!=(convertible const& lhs, convertible const& rhs)
|
||||
{
|
||||
return lhs.value_ != rhs.value_;
|
||||
}
|
||||
|
||||
// Testing conversion at function call allows for testing mutable lvalue,
|
||||
// const lvalue, and rvalue as the source. mpl::identity prevents deduction
|
||||
template <typename T>
|
||||
T implicit_construct(typename boost::mpl::identity<T>::type source)
|
||||
{
|
||||
return source;
|
||||
}
|
||||
|
||||
template <typename F, typename Source, typename Expected>
|
||||
bool run(Source const& source, Expected const& expected)
|
||||
{
|
||||
return F()(source, expected);
|
||||
}
|
||||
|
||||
template <typename F, typename Source>
|
||||
bool run(Source const& source)
|
||||
{
|
||||
return run<F>(source, source);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct can_rvalue_implicit_construct
|
||||
{
|
||||
template<typename Source, typename Expected>
|
||||
bool operator()(Source const& source, Expected const& expected) const
|
||||
{
|
||||
return expected == implicit_construct<T>(implicit_construct<Source>(source));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct can_lvalue_implicit_construct
|
||||
{
|
||||
template <typename Source, typename Expected>
|
||||
bool operator()(Source source, Expected const& expected) const
|
||||
{
|
||||
return expected == implicit_construct<T>(source);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct can_const_lvalue_implicit_construct
|
||||
{
|
||||
template <typename Source, typename Expected>
|
||||
bool operator()(Source const& source, Expected const& expected) const
|
||||
{
|
||||
return expected == implicit_construct<T>(source);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct can_implicit_construct
|
||||
{
|
||||
template <typename Source, typename Expected>
|
||||
bool operator()(Source const& source, Expected const& expected) const
|
||||
{
|
||||
return
|
||||
run< can_rvalue_implicit_construct<T> >(source, expected) &&
|
||||
run< can_lvalue_implicit_construct<T> >(source, expected) &&
|
||||
run< can_const_lvalue_implicit_construct<T> >(source, expected);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct can_rvalue_construct
|
||||
{
|
||||
template<typename Source, typename Expected>
|
||||
bool operator()(Source const& source, Expected const& expected) const
|
||||
{
|
||||
return expected == T(implicit_construct<Source>(source));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct can_lvalue_construct
|
||||
{
|
||||
template <typename Source, typename Expected>
|
||||
bool operator()(Source source, Expected const& expected) const
|
||||
{
|
||||
return expected == T(source);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct can_const_lvalue_construct
|
||||
{
|
||||
template <typename Source, typename Expected>
|
||||
bool operator()(Source const& source, Expected const& expected) const
|
||||
{
|
||||
return expected == T(source);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct can_construct
|
||||
{
|
||||
template <typename Source, typename Expected>
|
||||
bool operator()(Source const& source, Expected const& expected) const
|
||||
{
|
||||
return
|
||||
run< can_rvalue_construct<T> >(source, expected) &&
|
||||
run< can_lvalue_construct<T> >(source, expected) &&
|
||||
run< can_const_lvalue_construct<T> >(source, expected);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct can_rvalue_assign
|
||||
{
|
||||
template <typename Source, typename Expected>
|
||||
bool operator()(Source const& source, Expected const& expected) const
|
||||
{
|
||||
bool result = true;
|
||||
{
|
||||
T seq;
|
||||
result &= (seq == expected || seq != expected);
|
||||
|
||||
seq = implicit_construct<Source>(source);
|
||||
result &= (seq == expected);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct can_lvalue_assign
|
||||
{
|
||||
|
||||
template <typename Source, typename Expected>
|
||||
bool operator()(Source source, Expected const& expected) const
|
||||
{
|
||||
bool result = true;
|
||||
{
|
||||
T seq;
|
||||
result &= (seq == expected || seq != expected);
|
||||
|
||||
seq = source;
|
||||
result &= (seq == expected);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct can_const_lvalue_assign
|
||||
{
|
||||
template <typename Source, typename Expected>
|
||||
bool operator()(Source const& source, Expected const& expected) const
|
||||
{
|
||||
bool result = true;
|
||||
{
|
||||
T seq;
|
||||
result &= (seq == expected || seq != expected);
|
||||
|
||||
seq = source;
|
||||
result &= (seq == expected);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct can_assign
|
||||
{
|
||||
template <typename Source, typename Expected>
|
||||
bool operator()(Source const& source, Expected const& expected) const
|
||||
{
|
||||
return
|
||||
run< can_rvalue_assign<T> >(source, expected) &&
|
||||
run< can_lvalue_assign<T> >(source, expected) &&
|
||||
run< can_const_lvalue_assign<T> >(source, expected);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct can_copy
|
||||
{
|
||||
template <typename Source, typename Expected>
|
||||
bool operator()(Source const& source, Expected const& expected) const
|
||||
{
|
||||
return
|
||||
run< can_construct<T> >(source, expected) &&
|
||||
run< can_implicit_construct<T> >(source, expected) &&
|
||||
run< can_assign<T> >(source, expected);
|
||||
}
|
||||
};
|
||||
} // test_detail
|
@ -15,7 +15,7 @@
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
test<test_detail::can_copy>();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
@ -7,13 +7,30 @@
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE list
|
||||
#define FUSION_SEQUENCE boost::fusion::list
|
||||
#include "nest.hpp"
|
||||
|
||||
/* list has a few issues:
|
||||
- sequence conversion constructor has bug when first element is a sequence
|
||||
- assignment sequence conversion has bug in base class */
|
||||
template <typename T>
|
||||
struct skip_issues
|
||||
{
|
||||
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_construct_from_elements<T> >(source, expected);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
test<skip_issues>();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
@ -7,52 +7,315 @@
|
||||
|
||||
#include <utility>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/fusion/include/adapt_struct.hpp>
|
||||
#include <boost/fusion/include/as_deque.hpp>
|
||||
#include <boost/fusion/include/as_list.hpp>
|
||||
#include <boost/fusion/include/as_vector.hpp>
|
||||
#include <boost/fusion/include/begin.hpp>
|
||||
#include <boost/fusion/include/is_sequence.hpp>
|
||||
#include <boost/fusion/include/size.hpp>
|
||||
#include <boost/fusion/include/value_of.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
|
||||
template <typename C>
|
||||
void test_copy()
|
||||
#include "fixture.hpp"
|
||||
|
||||
namespace test_detail
|
||||
{
|
||||
C src;
|
||||
C dst = src;
|
||||
(void)dst;
|
||||
}
|
||||
struct adapted_sequence
|
||||
{
|
||||
adapted_sequence() : value_() {}
|
||||
explicit adapted_sequence(int value) : value_(value) {}
|
||||
int value_;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
template <typename C>
|
||||
void test_move()
|
||||
{
|
||||
C src;
|
||||
C dst = std::move(src);
|
||||
(void)dst;
|
||||
}
|
||||
#endif
|
||||
bool operator==(adapted_sequence const& lhs, adapted_sequence const& rhs)
|
||||
{
|
||||
return lhs.value_ == rhs.value_;
|
||||
}
|
||||
|
||||
template <typename C>
|
||||
void test_all()
|
||||
{
|
||||
test_copy<C>();
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
test_move<C>();
|
||||
#endif
|
||||
}
|
||||
bool operator!=(adapted_sequence const& lhs, adapted_sequence const& rhs)
|
||||
{
|
||||
return lhs.value_ != rhs.value_;
|
||||
}
|
||||
|
||||
template <template <typename> class Scenario>
|
||||
struct can_convert_using
|
||||
{
|
||||
template <typename T>
|
||||
struct to
|
||||
{
|
||||
static bool can_convert_(boost::true_type /* skip */)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool can_convert_(boost::false_type /* skip */)
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
return
|
||||
run<Scenario<T> >(typename result_of::as_deque<T>::type()) &&
|
||||
run<Scenario<T> >(typename result_of::as_list<T>::type()) &&
|
||||
run<Scenario<T> >(typename result_of::as_vector<T>::type());
|
||||
}
|
||||
|
||||
template <typename Source, typename Expected>
|
||||
bool operator()(Source const&, Expected const&) const
|
||||
{
|
||||
// bug when converting single element sequences in C++03 and
|
||||
// C++11...
|
||||
// not_<not_<is_convertible<sequence<sequence<int>>, int >
|
||||
// is invalid check
|
||||
typedef typename ::boost::fusion::result_of::size<T>::type seq_size;
|
||||
return can_convert_(
|
||||
boost::integral_constant<bool, seq_size::value == 1>()
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct can_construct_from_elements
|
||||
{
|
||||
template <typename Source, typename Expected>
|
||||
bool operator()(Source const&, Expected const&) const
|
||||
{
|
||||
// constructing a nested sequence of one is the complicated case to
|
||||
// disambiguate from a conversion-copy, so focus on that
|
||||
typedef typename boost::fusion::result_of::size<T>::type seq_size;
|
||||
return can_construct_(
|
||||
boost::integral_constant<int, seq_size::value>()
|
||||
);
|
||||
}
|
||||
|
||||
template <int Size>
|
||||
static bool can_construct_(boost::integral_constant<int, Size>)
|
||||
{
|
||||
return Size == 0 || Size == 2 || Size == 3;
|
||||
}
|
||||
|
||||
static bool can_construct_(boost::integral_constant<int, 1>)
|
||||
{
|
||||
typedef typename ::boost::remove_reference<
|
||||
typename ::boost::remove_const<
|
||||
typename ::boost::fusion::result_of::value_of<
|
||||
typename ::boost::fusion::result_of::begin<T>::type
|
||||
>::type
|
||||
>::type
|
||||
>::type element;
|
||||
|
||||
return run< can_construct<T> >(element(), T());
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct can_nest
|
||||
{
|
||||
template <typename Source, typename Expected>
|
||||
bool operator()(Source const& source, Expected const& expected)
|
||||
{
|
||||
return
|
||||
run< can_copy<T> >(source, expected);
|
||||
run< can_convert_using<can_copy>::to<T> >(source, expected) &&
|
||||
run< can_construct_from_elements<T> >(source, expected);
|
||||
}
|
||||
};
|
||||
} // test_detail
|
||||
|
||||
|
||||
BOOST_FUSION_ADAPT_STRUCT(test_detail::adapted_sequence, (int, data))
|
||||
|
||||
template <template <typename> class Scenario>
|
||||
void
|
||||
test()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace test_detail;
|
||||
|
||||
test_all<FUSION_SEQUENCE<FUSION_SEQUENCE<> > >();
|
||||
test_all<FUSION_SEQUENCE<FUSION_SEQUENCE<>, int> >();
|
||||
test_all<FUSION_SEQUENCE<int, FUSION_SEQUENCE<> > >();
|
||||
test_all<FUSION_SEQUENCE<int, FUSION_SEQUENCE<>, float> >();
|
||||
BOOST_TEST(boost::fusion::traits::is_sequence<adapted_sequence>::value);
|
||||
BOOST_TEST(boost::fusion::size(adapted_sequence()) == 1);
|
||||
|
||||
test_all<FUSION_SEQUENCE<FUSION_SEQUENCE<int> > >();
|
||||
test_all<FUSION_SEQUENCE<FUSION_SEQUENCE<int>, int> >();
|
||||
test_all<FUSION_SEQUENCE<int, FUSION_SEQUENCE<int> > >();
|
||||
test_all<FUSION_SEQUENCE<int, FUSION_SEQUENCE<int>, float> >();
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE< FUSION_SEQUENCE<> > > >(
|
||||
FUSION_SEQUENCE< FUSION_SEQUENCE<> >()
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario<FUSION_SEQUENCE<FUSION_SEQUENCE<>, int> > >(
|
||||
FUSION_SEQUENCE< FUSION_SEQUENCE<>, int>(FUSION_SEQUENCE<>(), 325)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<int, FUSION_SEQUENCE<> > > >(
|
||||
FUSION_SEQUENCE< int, FUSION_SEQUENCE<> >(325, FUSION_SEQUENCE<>())
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario<FUSION_SEQUENCE<int, FUSION_SEQUENCE<>, float> > >(
|
||||
FUSION_SEQUENCE<int, FUSION_SEQUENCE<> , float>(
|
||||
325, FUSION_SEQUENCE<>(), 2.0f
|
||||
)
|
||||
)
|
||||
));
|
||||
|
||||
test_all<FUSION_SEQUENCE<FUSION_SEQUENCE<int, float> > >();
|
||||
test_all<FUSION_SEQUENCE<FUSION_SEQUENCE<int, float>, int> >();
|
||||
test_all<FUSION_SEQUENCE<int, FUSION_SEQUENCE<int, float> > >();
|
||||
test_all<FUSION_SEQUENCE<int, FUSION_SEQUENCE<int, float>, float> >();
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE< FUSION_SEQUENCE<int> > > >(
|
||||
FUSION_SEQUENCE< FUSION_SEQUENCE<int> >(FUSION_SEQUENCE<int>(400))
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<adapted_sequence> > >(
|
||||
FUSION_SEQUENCE<adapted_sequence>(adapted_sequence(400))
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario<FUSION_SEQUENCE<FUSION_SEQUENCE<int>, int> > >(
|
||||
FUSION_SEQUENCE<FUSION_SEQUENCE<int>, int>(
|
||||
FUSION_SEQUENCE<int>(325), 400
|
||||
)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario<FUSION_SEQUENCE<adapted_sequence, int> > >(
|
||||
FUSION_SEQUENCE<adapted_sequence, int>(adapted_sequence(325), 400)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE< int, FUSION_SEQUENCE<int> > > >(
|
||||
FUSION_SEQUENCE< int, FUSION_SEQUENCE<int> >(
|
||||
325, FUSION_SEQUENCE<int>(400)
|
||||
)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<int, adapted_sequence> > >(
|
||||
FUSION_SEQUENCE<int, adapted_sequence>(325, adapted_sequence(450))
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<int, FUSION_SEQUENCE<int>, int> > >(
|
||||
FUSION_SEQUENCE<int, FUSION_SEQUENCE<int>, int>(
|
||||
500, FUSION_SEQUENCE<int>(350), 200
|
||||
)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<int, adapted_sequence, int> > >(
|
||||
FUSION_SEQUENCE<int, adapted_sequence, int>(
|
||||
300, adapted_sequence(500), 400)
|
||||
)
|
||||
));
|
||||
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE< FUSION_SEQUENCE<int, int> > > >(
|
||||
FUSION_SEQUENCE< FUSION_SEQUENCE<int, int> >(
|
||||
FUSION_SEQUENCE<int, int>(450, 500)
|
||||
)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE<FUSION_SEQUENCE<int, int>, int> > >(
|
||||
FUSION_SEQUENCE<FUSION_SEQUENCE<int, int>, int>(
|
||||
FUSION_SEQUENCE<int, int>(450, 500), 150
|
||||
)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario< FUSION_SEQUENCE< int, FUSION_SEQUENCE<int, int> > > >(
|
||||
FUSION_SEQUENCE< int, FUSION_SEQUENCE<int, int> >(
|
||||
450, FUSION_SEQUENCE<int, int>(500, 150)
|
||||
)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run<Scenario< FUSION_SEQUENCE<int, FUSION_SEQUENCE<int, int>, int> > >(
|
||||
FUSION_SEQUENCE<int, FUSION_SEQUENCE<int, int>, int>(
|
||||
150, FUSION_SEQUENCE<int, int>(250, 350), 450
|
||||
)
|
||||
)
|
||||
));
|
||||
|
||||
BOOST_TEST((
|
||||
run<Scenario<FUSION_SEQUENCE<FUSION_SEQUENCE<>, FUSION_SEQUENCE<> > > >(
|
||||
FUSION_SEQUENCE< FUSION_SEQUENCE<>, FUSION_SEQUENCE<> >(
|
||||
FUSION_SEQUENCE<>(), FUSION_SEQUENCE<>()
|
||||
)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run<Scenario<FUSION_SEQUENCE<FUSION_SEQUENCE<int>, FUSION_SEQUENCE<> > > >(
|
||||
FUSION_SEQUENCE< FUSION_SEQUENCE<int>, FUSION_SEQUENCE<> >(
|
||||
FUSION_SEQUENCE<int>(150), FUSION_SEQUENCE<>()
|
||||
)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run<Scenario<FUSION_SEQUENCE<FUSION_SEQUENCE<>, FUSION_SEQUENCE<int> > > >(
|
||||
FUSION_SEQUENCE< FUSION_SEQUENCE<>, FUSION_SEQUENCE<int> >(
|
||||
FUSION_SEQUENCE<>(), FUSION_SEQUENCE<int>(500)
|
||||
)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run<Scenario<FUSION_SEQUENCE<FUSION_SEQUENCE<int>, FUSION_SEQUENCE<int> > > >(
|
||||
FUSION_SEQUENCE< FUSION_SEQUENCE<int>, FUSION_SEQUENCE<int> >(
|
||||
FUSION_SEQUENCE<int>(155), FUSION_SEQUENCE<int>(255)
|
||||
)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario<
|
||||
FUSION_SEQUENCE< FUSION_SEQUENCE<int, int>, FUSION_SEQUENCE<int> >
|
||||
> >(
|
||||
FUSION_SEQUENCE< FUSION_SEQUENCE<int, int>, FUSION_SEQUENCE<int> >(
|
||||
FUSION_SEQUENCE<int, int>(222, 333), FUSION_SEQUENCE<int>(444)
|
||||
)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario<
|
||||
FUSION_SEQUENCE< FUSION_SEQUENCE<int>, FUSION_SEQUENCE<int, int> >
|
||||
> >(
|
||||
FUSION_SEQUENCE< FUSION_SEQUENCE<int>, FUSION_SEQUENCE<int, int> >(
|
||||
FUSION_SEQUENCE<int>(100), FUSION_SEQUENCE<int, int>(300, 400)
|
||||
)
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< Scenario<
|
||||
FUSION_SEQUENCE< FUSION_SEQUENCE<int, int>, FUSION_SEQUENCE<int, int> >
|
||||
> >(
|
||||
FUSION_SEQUENCE< FUSION_SEQUENCE<int, int>, FUSION_SEQUENCE<int, int> >(
|
||||
FUSION_SEQUENCE<int, int>(600, 700)
|
||||
, FUSION_SEQUENCE<int, int>(800, 900)
|
||||
)
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
// Ignore desired scenario, and cheat to make these work
|
||||
BOOST_TEST((
|
||||
run< can_lvalue_construct< FUSION_SEQUENCE<FUSION_SEQUENCE<>&> > >(
|
||||
FUSION_SEQUENCE<>()
|
||||
, FUSION_SEQUENCE< FUSION_SEQUENCE<> >()
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< can_construct< FUSION_SEQUENCE<const FUSION_SEQUENCE<>&> > >(
|
||||
FUSION_SEQUENCE<>()
|
||||
, FUSION_SEQUENCE< FUSION_SEQUENCE<> >()
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< can_lvalue_construct< FUSION_SEQUENCE<FUSION_SEQUENCE<int>&> > >(
|
||||
FUSION_SEQUENCE<int>(300)
|
||||
, FUSION_SEQUENCE< FUSION_SEQUENCE<int> >(FUSION_SEQUENCE<int>(300))
|
||||
)
|
||||
));
|
||||
BOOST_TEST((
|
||||
run< can_construct< FUSION_SEQUENCE<const FUSION_SEQUENCE<int>&> > >(
|
||||
FUSION_SEQUENCE<int>(400)
|
||||
, FUSION_SEQUENCE< FUSION_SEQUENCE<int> >(FUSION_SEQUENCE<int>(400))
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
|
49
test/sequence/std_array.cpp
Normal file
49
test/sequence/std_array.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
//
|
||||
// Copyright (C) 2013 Mateusz Loskot <mateusz@loskot.net>
|
||||
//
|
||||
// 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>
|
||||
#ifdef BOOST_NO_CXX11_HDR_ARRAY
|
||||
int main() {}
|
||||
#else
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(disable:4180)
|
||||
#endif
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/fusion/adapted/std_array.hpp>
|
||||
#include <array>
|
||||
|
||||
#include <boost/fusion/sequence/intrinsic.hpp>
|
||||
#include <boost/fusion/support/is_sequence.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/fusion/iterator.hpp>
|
||||
|
||||
#include <boost/mpl/assert.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
typedef std::array<int,3> array_type;
|
||||
|
||||
BOOST_MPL_ASSERT((traits::is_sequence<array_type>));
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_view<array_type>));
|
||||
|
||||
array_type arr = {{1,2,3}};
|
||||
|
||||
BOOST_TEST(*boost::fusion::begin(arr) == 1);
|
||||
BOOST_TEST(*boost::fusion::next(boost::fusion::begin(arr)) == 2);
|
||||
BOOST_TEST(*advance_c<2>(boost::fusion::begin(arr)) == 3);
|
||||
BOOST_TEST(prior(boost::fusion::next(boost::fusion::begin(arr))) == boost::fusion::begin(arr));
|
||||
BOOST_TEST(*prior(boost::fusion::end(arr)) == 3);
|
||||
BOOST_TEST(at_c<2>(arr) == 3);
|
||||
BOOST_TEST(boost::fusion::size(arr) == 3);
|
||||
BOOST_TEST(distance(boost::fusion::begin(arr), boost::fusion::end(arr)) == 3);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
#endif
|
251
test/sequence/traits.hpp
Normal file
251
test/sequence/traits.hpp
Normal file
@ -0,0 +1,251 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2016 Lee Clagett
|
||||
|
||||
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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/list.hpp>
|
||||
#include <boost/fusion/container/vector.hpp>
|
||||
#include <boost/type_traits/add_const.hpp>
|
||||
#include <boost/type_traits/add_reference.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#include <boost/type_traits/is_constructible.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
|
||||
struct convertible
|
||||
{
|
||||
convertible(int) {}
|
||||
};
|
||||
|
||||
template <typename From, typename To>
|
||||
bool is_convertible(bool has_conversion)
|
||||
{
|
||||
typedef typename boost::remove_reference<
|
||||
typename boost::remove_const<From>::type
|
||||
>::type from_rvalue;
|
||||
typedef typename boost::add_reference<from_rvalue>::type from_lvalue;
|
||||
typedef typename boost::add_const<from_lvalue>::type from_const_lvalue;
|
||||
|
||||
return
|
||||
boost::is_convertible<from_rvalue, To>::value == has_conversion &&
|
||||
boost::is_convertible<from_lvalue, To>::value == has_conversion &&
|
||||
boost::is_convertible<from_const_lvalue, To>::value == has_conversion;
|
||||
}
|
||||
|
||||
// is_constructible has a few requirements
|
||||
#if !defined(BOOST_NO_CXX11_DECLTYPE) && \
|
||||
!defined(BOOST_NO_CXX11_TEMPLATES) && \
|
||||
!defined(BOOST_NO_SFINAE_EXPR)
|
||||
|
||||
#define FUSION_TEST_HAS_CONSTRUCTIBLE
|
||||
|
||||
template <typename To, typename... Args>
|
||||
bool is_lvalue_constructible(bool has_constructor)
|
||||
{
|
||||
return has_constructor ==
|
||||
boost::is_constructible<
|
||||
To
|
||||
, typename boost::add_reference<Args>::type...
|
||||
>::value;
|
||||
}
|
||||
|
||||
template <typename To, typename... Args>
|
||||
bool is_constructible_impl(bool has_constructor)
|
||||
{
|
||||
return
|
||||
boost::is_constructible<To, Args...>::value == has_constructor &&
|
||||
is_lvalue_constructible<To, Args...>(has_constructor) &&
|
||||
is_lvalue_constructible<
|
||||
To, typename boost::add_const<Args>::type...
|
||||
>(has_constructor);
|
||||
}
|
||||
|
||||
template <typename To, typename... Args>
|
||||
bool is_constructible(bool has_constructor)
|
||||
{
|
||||
return
|
||||
is_constructible_impl<
|
||||
To
|
||||
, typename boost::remove_reference<
|
||||
typename boost::remove_const<Args>::type
|
||||
>::type...
|
||||
>(has_constructor);
|
||||
}
|
||||
|
||||
void test_constructible()
|
||||
{
|
||||
BOOST_TEST((is_constructible< FUSION_SEQUENCE<> >(true)));
|
||||
|
||||
BOOST_TEST((is_constructible< FUSION_SEQUENCE<int> >(true)));
|
||||
BOOST_TEST((is_constructible<FUSION_SEQUENCE<int>, int>(true)));
|
||||
|
||||
BOOST_TEST((is_constructible<FUSION_SEQUENCE<convertible>, int>(true)));
|
||||
BOOST_TEST((
|
||||
is_constructible<FUSION_SEQUENCE<convertible>, convertible>(true)
|
||||
));
|
||||
|
||||
BOOST_TEST((
|
||||
is_constructible<FUSION_SEQUENCE<int, int>, int, int>(true)
|
||||
));
|
||||
|
||||
BOOST_TEST((
|
||||
is_constructible<FUSION_SEQUENCE<convertible, int>, int, int>(true)
|
||||
));
|
||||
BOOST_TEST((
|
||||
is_constructible<
|
||||
FUSION_SEQUENCE<convertible, int>, convertible, int
|
||||
>(true)
|
||||
));
|
||||
|
||||
BOOST_TEST((
|
||||
is_constructible<FUSION_SEQUENCE<int, convertible>, int, int>(true)
|
||||
));
|
||||
BOOST_TEST((
|
||||
is_constructible<
|
||||
FUSION_SEQUENCE<int, convertible>, int, convertible
|
||||
>(true)
|
||||
));
|
||||
|
||||
BOOST_TEST((
|
||||
is_constructible<
|
||||
FUSION_SEQUENCE<convertible, convertible>, int, int
|
||||
>(true)
|
||||
));
|
||||
BOOST_TEST((
|
||||
is_constructible<
|
||||
FUSION_SEQUENCE<convertible, convertible>, convertible, int
|
||||
>(true)
|
||||
));
|
||||
BOOST_TEST((
|
||||
is_constructible<
|
||||
FUSION_SEQUENCE<convertible, convertible>, int, convertible
|
||||
>(true)
|
||||
));
|
||||
BOOST_TEST((
|
||||
is_constructible<
|
||||
FUSION_SEQUENCE<convertible, convertible>, convertible, convertible
|
||||
>(true)
|
||||
));
|
||||
}
|
||||
|
||||
#endif // is_constructible is available
|
||||
|
||||
void test_convertible(bool has_seq_conversion)
|
||||
{
|
||||
BOOST_TEST((is_convertible<int, FUSION_SEQUENCE<> >(false)));
|
||||
BOOST_TEST((is_convertible<int, FUSION_SEQUENCE<int> >(false)));
|
||||
BOOST_TEST((is_convertible<int, FUSION_SEQUENCE<const int&> >(false)));
|
||||
BOOST_TEST((is_convertible<int, FUSION_SEQUENCE<convertible> >(false)));
|
||||
BOOST_TEST((
|
||||
is_convertible<int, FUSION_SEQUENCE<const convertible&> >(false)
|
||||
));
|
||||
BOOST_TEST((is_convertible<int, FUSION_SEQUENCE<int, int> >(false)));
|
||||
BOOST_TEST((
|
||||
is_convertible<int, FUSION_SEQUENCE<const int&, const int&> >(false)
|
||||
));
|
||||
BOOST_TEST((is_convertible<int, FUSION_SEQUENCE<convertible, int> >(false)));
|
||||
BOOST_TEST((
|
||||
is_convertible<int, FUSION_SEQUENCE<const convertible&, const int&> >(false)
|
||||
));
|
||||
BOOST_TEST((is_convertible<int, FUSION_SEQUENCE<int, convertible> >(false)));
|
||||
BOOST_TEST((
|
||||
is_convertible<int, FUSION_SEQUENCE<const int&, const convertible&> >(false)
|
||||
));
|
||||
BOOST_TEST((
|
||||
is_convertible<int, FUSION_SEQUENCE<convertible, convertible> >(false)
|
||||
));
|
||||
BOOST_TEST((
|
||||
is_convertible<
|
||||
int, FUSION_SEQUENCE<const convertible&, const convertible&>
|
||||
>(false)
|
||||
));
|
||||
|
||||
BOOST_TEST((is_convertible<FUSION_SEQUENCE<>, FUSION_SEQUENCE<> >(true)));
|
||||
BOOST_TEST((
|
||||
is_convertible<FUSION_SEQUENCE<int>, FUSION_SEQUENCE<int> >(true)
|
||||
));
|
||||
BOOST_TEST((
|
||||
is_convertible<FUSION_SEQUENCE<int>, FUSION_SEQUENCE<const int&> >(true)
|
||||
));
|
||||
BOOST_TEST((
|
||||
is_convertible<FUSION_SEQUENCE<int>, FUSION_SEQUENCE<convertible> >(true)
|
||||
));
|
||||
BOOST_TEST((
|
||||
is_convertible<FUSION_SEQUENCE<int, int>, FUSION_SEQUENCE<int, int> >(true)
|
||||
));
|
||||
BOOST_TEST((
|
||||
is_convertible<
|
||||
FUSION_SEQUENCE<int, int>, FUSION_SEQUENCE<const int&, const int&>
|
||||
>(true)
|
||||
));
|
||||
BOOST_TEST((
|
||||
is_convertible<
|
||||
FUSION_SEQUENCE<int, int>, FUSION_SEQUENCE<convertible, int>
|
||||
>(true)
|
||||
));
|
||||
BOOST_TEST((
|
||||
is_convertible<
|
||||
FUSION_SEQUENCE<int, int>, FUSION_SEQUENCE<int, convertible>
|
||||
>(true)
|
||||
));
|
||||
BOOST_TEST((
|
||||
is_convertible<
|
||||
FUSION_SEQUENCE<int, int>
|
||||
, FUSION_SEQUENCE<convertible, convertible>
|
||||
>(true)
|
||||
));
|
||||
|
||||
BOOST_TEST((
|
||||
is_convertible<
|
||||
FUSION_ALT_SEQUENCE<>, FUSION_SEQUENCE<>
|
||||
>(has_seq_conversion)
|
||||
));
|
||||
BOOST_TEST((
|
||||
is_convertible<
|
||||
FUSION_ALT_SEQUENCE<int>, FUSION_SEQUENCE<int>
|
||||
>(has_seq_conversion)
|
||||
));
|
||||
BOOST_TEST((
|
||||
is_convertible<
|
||||
FUSION_ALT_SEQUENCE<int>, FUSION_SEQUENCE<const int&>
|
||||
>(has_seq_conversion)
|
||||
));
|
||||
BOOST_TEST((
|
||||
is_convertible<
|
||||
FUSION_ALT_SEQUENCE<int>, FUSION_SEQUENCE<convertible>
|
||||
>(has_seq_conversion)
|
||||
));
|
||||
BOOST_TEST((
|
||||
is_convertible<
|
||||
FUSION_ALT_SEQUENCE<int, int>, FUSION_SEQUENCE<int, int>
|
||||
>(has_seq_conversion)
|
||||
));
|
||||
BOOST_TEST((
|
||||
is_convertible<
|
||||
FUSION_ALT_SEQUENCE<int, int>
|
||||
, FUSION_SEQUENCE<const int&, const int&>
|
||||
>(has_seq_conversion)
|
||||
));
|
||||
BOOST_TEST((
|
||||
is_convertible<
|
||||
FUSION_ALT_SEQUENCE<int, int>, FUSION_SEQUENCE<convertible, int>
|
||||
>(has_seq_conversion)
|
||||
));
|
||||
BOOST_TEST((
|
||||
is_convertible<
|
||||
FUSION_ALT_SEQUENCE<int, int>, FUSION_SEQUENCE<int, convertible>
|
||||
>(has_seq_conversion)
|
||||
));
|
||||
BOOST_TEST((
|
||||
is_convertible<
|
||||
FUSION_ALT_SEQUENCE<int, int>
|
||||
, FUSION_SEQUENCE<convertible, convertible>
|
||||
>(has_seq_conversion)
|
||||
));
|
||||
}
|
||||
|
@ -13,9 +13,37 @@
|
||||
#define FUSION_AT get
|
||||
#include "construction.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
|
||||
|
||||
struct test_conversion
|
||||
{
|
||||
test_conversion(int value) : value_(value) {}
|
||||
|
||||
int value_;
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
const tuple<int, test_conversion> instance(std::pair<int, int>(1, 9));
|
||||
BOOST_TEST(boost::fusion::get<0>(instance) == 1);
|
||||
BOOST_TEST(boost::fusion::get<1>(instance).value_ == 9);
|
||||
}
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
const std::pair<int, int> init(16, 4);
|
||||
const tuple<int, test_conversion> instance(init);
|
||||
BOOST_TEST(boost::fusion::get<0>(instance) == 16);
|
||||
BOOST_TEST(boost::fusion::get<1>(instance).value_ == 4);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
51
test/sequence/tuple_conversion.cpp
Normal file
51
test/sequence/tuple_conversion.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
/*=============================================================================
|
||||
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();
|
||||
}
|
@ -16,7 +16,7 @@
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
test<test_detail::can_copy>();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
86
test/sequence/tuple_traits.cpp
Normal file
86
test/sequence/tuple_traits.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 Lee Clagett
|
||||
|
||||
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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector.hpp>
|
||||
#include <boost/fusion/tuple/tuple.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/type_traits/is_constructible.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE boost::fusion::tuple
|
||||
#define FUSION_ALT_SEQUENCE boost::fusion::vector
|
||||
#include "traits.hpp"
|
||||
|
||||
struct not_convertible {};
|
||||
|
||||
/* Some construction differences in fusion::tuple from std::tuple:
|
||||
- Construction from elements cannot call an explicit constructor.
|
||||
- There is no implicit construction from elements.
|
||||
- Construction from std::pair is _enabled_ when tuple is not of size 2.
|
||||
- Construction from tuple is _enabled_ when destination tuple is of
|
||||
different size.
|
||||
- Implicit construction from std::pair can call explicit constructors on
|
||||
elements.
|
||||
- Implicit construction from tuple can call explicit constructors on
|
||||
elements.
|
||||
|
||||
These differences are historical. Matching the behavior of std::tuple
|
||||
could break existing code, however, switching to fusion::vector would
|
||||
restore the historical behavior. */
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
test_convertible(false /* no conversion construction */ );
|
||||
|
||||
BOOST_TEST((is_convertible<std::pair<int, int>, tuple<int, int> >(true)));
|
||||
BOOST_TEST((
|
||||
is_convertible<std::pair<int, int>, tuple<convertible, int> >(true)
|
||||
));
|
||||
BOOST_TEST((
|
||||
is_convertible<std::pair<int, int>, tuple<int, convertible> >(true)
|
||||
));
|
||||
BOOST_TEST((
|
||||
is_convertible<
|
||||
std::pair<int, int>, tuple<convertible, convertible>
|
||||
>(true)
|
||||
));
|
||||
|
||||
#if defined(FUSION_TEST_HAS_CONSTRUCTIBLE)
|
||||
test_constructible();
|
||||
|
||||
BOOST_TEST((is_constructible< tuple<> >(true)));
|
||||
BOOST_TEST((is_constructible<tuple<>, int>(false)));
|
||||
|
||||
BOOST_TEST((is_constructible< tuple<int> >(true)));
|
||||
BOOST_TEST((is_constructible<tuple<int>, int>(true)));
|
||||
BOOST_TEST((is_constructible<tuple<convertible>, int>(true)));
|
||||
BOOST_TEST((is_constructible<tuple<not_convertible>, int>(false)));
|
||||
BOOST_TEST((is_constructible< tuple<int>, vector<int> >(false)));
|
||||
BOOST_TEST((is_constructible<tuple<int>, int, int>(false)));
|
||||
|
||||
BOOST_TEST((is_constructible< tuple<int, int> >(true)));
|
||||
BOOST_TEST((is_constructible<tuple<int, int>, int, int>(true)));
|
||||
BOOST_TEST((
|
||||
is_constructible<tuple<convertible, convertible>, int, int>(true)
|
||||
));
|
||||
BOOST_TEST((is_constructible<tuple<int, not_convertible>, int, int>(false)));
|
||||
BOOST_TEST((is_constructible<tuple<not_convertible, int>, int, int>(false)));
|
||||
BOOST_TEST((
|
||||
is_constructible<tuple<not_convertible, not_convertible>, int, int>(false)
|
||||
));
|
||||
#if defined(BOOST_FUSION_HAS_VARIADIC_VECTOR)
|
||||
// C++03 fusion::tuple has constructors that can never be used
|
||||
BOOST_TEST((is_constructible<tuple<int, int>, int>(false)));
|
||||
#endif
|
||||
BOOST_TEST((is_constructible<tuple<int, int>, int, int, int>(false)));
|
||||
|
||||
#endif // FUSION_TEST_HAS_CONSTRUCTIBLE
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
19
test/sequence/vector_conversion.cpp
Normal file
19
test/sequence/vector_conversion.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
/*=============================================================================
|
||||
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/container/vector.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE boost::fusion::vector
|
||||
#include "conversion.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
test<test_detail::can_copy>();
|
||||
return boost::report_errors();
|
||||
}
|
@ -15,7 +15,7 @@
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
test<test_detail::can_copy>();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
@ -7,13 +7,13 @@
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE vector
|
||||
#define FUSION_SEQUENCE boost::fusion::vector
|
||||
#include "nest.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
test<test_detail::can_nest>();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
32
test/sequence/vector_traits.cpp
Normal file
32
test/sequence/vector_traits.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2016 Lee Clagett
|
||||
|
||||
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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/list.hpp>
|
||||
#include <boost/fusion/container/vector.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE boost::fusion::vector
|
||||
#define FUSION_ALT_SEQUENCE boost::fusion::list
|
||||
#include "traits.hpp"
|
||||
|
||||
int main() {
|
||||
test_convertible(true /* has conversion construction */ );
|
||||
|
||||
// C++11 models overly aggressive (bug) implicit conversion from C++03
|
||||
BOOST_TEST((
|
||||
is_convertible<
|
||||
boost::fusion::list<int>
|
||||
, boost::fusion::vector< boost::fusion::list<int> >
|
||||
>(true)
|
||||
));
|
||||
|
||||
#if defined(FUSION_TEST_HAS_CONSTRUCTIBLE)
|
||||
test_constructible();
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
33
test/support/and.cpp
Normal file
33
test/support/and.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 Lee Clagett
|
||||
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>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/support/detail/and.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
|
||||
int main() {
|
||||
using namespace boost;
|
||||
using namespace boost::fusion::detail;
|
||||
|
||||
BOOST_TEST((and_<>::value));
|
||||
BOOST_TEST(!(and_<false_type>::value));
|
||||
BOOST_TEST((and_<true_type>::value));
|
||||
BOOST_TEST(!(and_<true_type, false_type>::value));
|
||||
BOOST_TEST((and_<true_type, true_type>::value));
|
||||
BOOST_TEST(!(and_<true_type, true_type, false_type>::value));
|
||||
BOOST_TEST((and_<true_type, true_type, true_type>::value));
|
||||
BOOST_TEST((and_<true_type, mpl::true_>::value));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user