forked from boostorg/fusion
Compare commits
6 Commits
boost-1.67
...
optimizati
Author | SHA1 | Date | |
---|---|---|---|
4e57acbce7 | |||
44ef9e56e6 | |||
e3b053f969 | |||
11a3f250b8 | |||
d8f608c8f1 | |||
2aea153be0 |
@ -8,7 +8,6 @@
|
||||
#define FUSION_CATEGORY_OF_07202005_0308
|
||||
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <boost/fusion/support/detail/category_of.hpp>
|
||||
#include <boost/fusion/support/tag_of.hpp>
|
||||
#include <boost/type_traits/is_base_of.hpp>
|
||||
|
||||
@ -44,7 +43,10 @@ namespace boost { namespace fusion
|
||||
struct category_of_impl
|
||||
{
|
||||
template<typename T>
|
||||
struct apply : detail::fusion_category_of<T> {};
|
||||
struct apply
|
||||
{
|
||||
typedef typename T::category type;
|
||||
};
|
||||
};
|
||||
|
||||
template <>
|
||||
|
@ -15,6 +15,7 @@
|
||||
#endif
|
||||
|
||||
namespace boost { namespace fusion { namespace detail {
|
||||
#if defined(BOOST_NO_CXX17_FOLD_EXPRESSIONS)
|
||||
template<typename ...Cond>
|
||||
struct and_impl : false_type {};
|
||||
|
||||
@ -34,6 +35,10 @@ namespace boost { namespace fusion { namespace detail {
|
||||
recursive. */
|
||||
template<typename ...Cond>
|
||||
struct and_ : and_impl1<Cond::value...> {};
|
||||
#else
|
||||
template <typename ...Cond>
|
||||
struct and_ : integral_constant<bool, ((bool)Cond::value && ...)> {};
|
||||
#endif
|
||||
}}}
|
||||
|
||||
#endif // FUSION_AND_07152016_1625
|
||||
|
@ -1,19 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
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(FUSION_CATEGORY_OF_07212005_1025)
|
||||
#define FUSION_CATEGORY_OF_07212005_1025
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <typename T>
|
||||
struct fusion_category_of
|
||||
{
|
||||
typedef typename T::category type;
|
||||
};
|
||||
}}}
|
||||
|
||||
#endif
|
@ -9,19 +9,17 @@
|
||||
#define FUSION_DETAIL_IS_MPL_SEQUENCE_29122006_1105
|
||||
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <boost/fusion/support/sequence_base.hpp>
|
||||
#include <boost/fusion/support/detail/is_native_fusion_sequence.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/type_traits/is_complete.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <typename T>
|
||||
struct is_mpl_sequence
|
||||
: mpl::and_<
|
||||
mpl::not_<mpl::and_<is_complete<T>, is_convertible<T, from_sequence_convertible_type> > >
|
||||
mpl::not_<is_native_fusion_sequence<T> >
|
||||
, mpl::is_sequence<T> >
|
||||
{};
|
||||
}}}
|
||||
|
@ -0,0 +1,27 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2018 Kohei Takahashi
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
==============================================================================*/
|
||||
#ifndef BOOST_FUSION_IS_NATIVE_FUSION_SEQUENCE
|
||||
#define BOOST_FUSION_IS_NATIVE_FUSION_SEQUENCE
|
||||
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <boost/fusion/support/sequence_base.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/type_traits/is_complete.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <typename Sequence>
|
||||
struct is_native_fusion_sequence
|
||||
: mpl::and_<
|
||||
is_complete<Sequence>
|
||||
, is_convertible<Sequence, detail::from_sequence_convertible_type>
|
||||
>
|
||||
{};
|
||||
}}}
|
||||
|
||||
#endif
|
@ -1,19 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
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(FUSION_IS_VIEW_03202006_0018)
|
||||
#define FUSION_IS_VIEW_03202006_0018
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <typename T>
|
||||
struct fusion_is_view
|
||||
{
|
||||
typedef typename T::is_view type;
|
||||
};
|
||||
}}}
|
||||
|
||||
#endif
|
@ -1,16 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
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(FUSION_UNKNOWN_KEY_09242005_1219)
|
||||
#define FUSION_UNKNOWN_KEY_09242005_1219
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <int index>
|
||||
struct unknown_key {};
|
||||
}}}
|
||||
|
||||
#endif
|
@ -10,13 +10,10 @@
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <boost/fusion/support/sequence_base.hpp>
|
||||
#include <boost/fusion/support/tag_of.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/fusion/support/detail/is_native_fusion_sequence.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/mpl/or.hpp>
|
||||
#include <boost/type_traits/is_complete.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
@ -69,13 +66,7 @@ namespace boost { namespace fusion
|
||||
>
|
||||
{};
|
||||
|
||||
template <typename Sequence, typename Enable = void>
|
||||
struct is_native_fusion_sequence
|
||||
: mpl::and_<
|
||||
is_complete<Sequence>,
|
||||
is_convertible<Sequence, fusion::detail::from_sequence_convertible_type>
|
||||
>
|
||||
{};
|
||||
using detail::is_native_fusion_sequence;
|
||||
}
|
||||
}}
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/fusion/support/detail/is_view.hpp>
|
||||
#include <boost/fusion/support/tag_of.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
@ -28,8 +27,9 @@ namespace boost { namespace fusion
|
||||
{
|
||||
template <typename T>
|
||||
struct apply
|
||||
: detail::fusion_is_view<T>
|
||||
{};
|
||||
{
|
||||
typedef typename T::is_view type;
|
||||
};
|
||||
};
|
||||
|
||||
template <>
|
||||
|
@ -8,15 +8,16 @@
|
||||
#if !defined(FUSION_PAIR_07222005_1203)
|
||||
#define FUSION_PAIR_07222005_1203
|
||||
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <iosfwd>
|
||||
|
||||
#include <utility>
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <boost/fusion/support/detail/access.hpp>
|
||||
#include <boost/fusion/support/detail/as_fusion_element.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/fusion/support/detail/enabler.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/type_traits/is_lvalue_reference.hpp>
|
||||
#include <boost/type_traits/remove_cv_ref.hpp>
|
||||
|
||||
#if defined (BOOST_MSVC)
|
||||
# pragma warning(push)
|
||||
@ -33,54 +34,46 @@ namespace boost { namespace fusion
|
||||
pair()
|
||||
: second() {}
|
||||
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
pair(pair const& rhs)
|
||||
: second(rhs.second) {}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
pair(pair&& rhs)
|
||||
: second(BOOST_FUSION_FWD_ELEM(Second, rhs.second)) {}
|
||||
#endif
|
||||
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
pair(typename detail::call_param<Second>::type val)
|
||||
: second(val) {}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
template <typename Second2>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
pair(Second2&& val
|
||||
, typename boost::disable_if<is_lvalue_reference<Second2> >::type* /* dummy */ = 0
|
||||
, typename boost::enable_if<is_convertible<Second2, Second> >::type* /*dummy*/ = 0
|
||||
) : second(BOOST_FUSION_FWD_ELEM(Second, val)) {}
|
||||
pair(typename remove_cv_ref<Second>::type&& val)
|
||||
: second(BOOST_FUSION_FWD_ELEM(Second, val)) {}
|
||||
#endif
|
||||
|
||||
template <typename Second2>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
pair(pair<First, Second2> const& rhs)
|
||||
pair(pair<First, Second2> const& rhs,
|
||||
typename disable_if<is_same<Second, Second2>, detail::enabler_>::type = detail::enabler,
|
||||
typename enable_if<is_convertible<Second2, Second>, detail::enabler_>::type = detail::enabler)
|
||||
: second(rhs.second) {}
|
||||
|
||||
template <typename Second2>
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
pair& operator=(pair<First, Second2> const& rhs)
|
||||
{
|
||||
second = rhs.second;
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
pair& operator=(pair const& rhs)
|
||||
typename disable_if<is_same<Second, Second2>, pair&>::type
|
||||
operator=(pair<First, Second2> const& rhs)
|
||||
{
|
||||
second = rhs.second;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
template <typename Second2>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
pair(pair<First, Second2>&& rhs,
|
||||
typename disable_if<is_same<Second, Second2>, detail::enabler_>::type = detail::enabler,
|
||||
typename enable_if<is_convertible<Second2, Second>, detail::enabler_>::type = detail::enabler)
|
||||
: second(std::move(rhs.second)) {}
|
||||
|
||||
template <typename Second2>
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
pair& operator=(pair&& rhs)
|
||||
typename disable_if<is_same<Second, Second2>, pair&>::type
|
||||
operator=(pair<First, Second2>&& rhs)
|
||||
{
|
||||
second = BOOST_FUSION_FWD_ELEM(Second, rhs.second);
|
||||
second = std::move(rhs.second);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
@ -255,6 +255,7 @@ project
|
||||
[ run sequence/swap.cpp ]
|
||||
|
||||
[ compile support/is_sequence.cpp ]
|
||||
[ compile support/pair_conversion.cpp ]
|
||||
[ compile support/pair_deque.cpp ]
|
||||
[ compile support/pair_list.cpp ]
|
||||
[ compile support/pair_map.cpp ]
|
||||
@ -266,6 +267,8 @@ project
|
||||
[ compile support/and.cpp
|
||||
: [ requires cxx11_variadic_templates ] ]
|
||||
[ compile support/tag_of.cpp ]
|
||||
[ compile support/pair_trivially_copyable.cpp
|
||||
: [ requires cxx11_hdr_type_traits ] ]
|
||||
|
||||
# [ compile-fail xxx.cpp ]
|
||||
|
||||
|
42
test/support/pair_conversion.cpp
Normal file
42
test/support/pair_conversion.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2018 Kohei Takahashi
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
==============================================================================*/
|
||||
|
||||
#include <utility>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/fusion/support/pair.hpp>
|
||||
|
||||
using namespace boost::fusion;
|
||||
|
||||
struct eat_int
|
||||
{
|
||||
eat_int(int);
|
||||
};
|
||||
|
||||
struct eat_pair
|
||||
{
|
||||
template <typename K, typename V>
|
||||
eat_pair(pair<K, V>);
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
pair<void, int> p;
|
||||
|
||||
pair<void, eat_int> ci(p);
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
pair<void, eat_int> mi(std::move(p));
|
||||
#endif
|
||||
|
||||
// eat_pair can't be converted from int, but can be pair.
|
||||
// So pair(eat_pair) should be called rather than pair(pair<void, eat_pair>).
|
||||
pair<void, eat_pair> cp(p);
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
pair<void, eat_pair> mp(std::move(p));
|
||||
#endif
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2015 Kohei Takahashi
|
||||
Copyright (c) 2015,2018 Kohei Takahashi
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@ -10,15 +10,20 @@
|
||||
using namespace boost::fusion;
|
||||
|
||||
template <typename C>
|
||||
void copy()
|
||||
void copy(C value)
|
||||
{
|
||||
pair<int, C> src;
|
||||
pair<int, C> src(value);
|
||||
pair<int, C> dest = src;
|
||||
boost::ignore_unused(dest);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
copy<pair<void, float> >();
|
||||
copy<pair<void, float> >(42.195f);
|
||||
copy<pair<int, float> >(42.195f);
|
||||
|
||||
float f;
|
||||
pair<void, float&> r(f);
|
||||
copy<pair<void, float&> >(r);
|
||||
}
|
||||
|
||||
|
50
test/support/pair_trivially_copyable.cpp
Normal file
50
test/support/pair_trivially_copyable.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2018 Kohei Takahashi
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
==============================================================================*/
|
||||
|
||||
#include <type_traits>
|
||||
#include <boost/fusion/support/pair.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
|
||||
using namespace boost::fusion;
|
||||
|
||||
struct non_trivially_copyable
|
||||
{
|
||||
non_trivially_copyable(const non_trivially_copyable&);
|
||||
non_trivially_copyable operator=(const non_trivially_copyable&);
|
||||
};
|
||||
|
||||
struct pod { };
|
||||
|
||||
BOOST_MPL_ASSERT_NOT((std::is_trivially_copyable<void>));
|
||||
BOOST_MPL_ASSERT((std::is_trivially_copyable<int>));
|
||||
BOOST_MPL_ASSERT_NOT((std::is_trivially_copyable<non_trivially_copyable>));
|
||||
BOOST_MPL_ASSERT((std::is_trivially_copyable<pod>));
|
||||
BOOST_MPL_ASSERT_NOT((std::is_trivially_copyable<int&>));
|
||||
BOOST_MPL_ASSERT((std::is_trivially_copyable<void*>));
|
||||
|
||||
|
||||
|
||||
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<void, int> >));
|
||||
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<int, int> >));
|
||||
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<non_trivially_copyable, int> >));
|
||||
BOOST_MPL_ASSERT_NOT((std::is_trivially_copyable<pair<int, non_trivially_copyable> >));
|
||||
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<pod, int> >));
|
||||
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<int, pod> >));
|
||||
|
||||
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<void, int&> >));
|
||||
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<int, int&> >));
|
||||
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<non_trivially_copyable, int&> >));
|
||||
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<int, non_trivially_copyable&> >));
|
||||
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<int, pod&> >));
|
||||
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<int, pod&> >));
|
||||
|
||||
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<void, int*> >));
|
||||
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<int, int*> >));
|
||||
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<non_trivially_copyable, int*> >));
|
||||
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<int, non_trivially_copyable*> >));
|
||||
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<int, pod*> >));
|
||||
BOOST_MPL_ASSERT((std::is_trivially_copyable<pair<int, pod*> >));
|
Reference in New Issue
Block a user