forked from boostorg/fusion
better operator handling
[SVN r36126]
This commit is contained in:
@ -18,16 +18,20 @@
|
|||||||
|
|
||||||
namespace boost { namespace fusion { namespace detail
|
namespace boost { namespace fusion { namespace detail
|
||||||
{
|
{
|
||||||
|
template <typename Sequence>
|
||||||
|
struct is_native_fusion_sequence : is_base_of<sequence_root, Sequence> {};
|
||||||
|
|
||||||
template <typename Seq1, typename Seq2>
|
template <typename Seq1, typename Seq2>
|
||||||
struct enable_equality
|
struct enable_equality
|
||||||
: mpl::or_<fusion::traits::is_sequence<Seq1>, fusion::traits::is_sequence<Seq2> >
|
: mpl::or_<is_native_fusion_sequence<Seq1>, is_native_fusion_sequence<Seq2> >
|
||||||
{};
|
{};
|
||||||
|
|
||||||
template <typename Seq1, typename Seq2>
|
template <typename Seq1, typename Seq2>
|
||||||
struct enable_comparison
|
struct enable_comparison
|
||||||
: mpl::and_<
|
: mpl::and_<
|
||||||
mpl::or_<fusion::traits::is_sequence<Seq1>, fusion::traits::is_sequence<Seq2> >,
|
mpl::or_<is_native_fusion_sequence<Seq1>, is_native_fusion_sequence<Seq2> >
|
||||||
mpl::equal_to<result_of::size<Seq1>, result_of::size<Seq2> > >
|
, mpl::equal_to<result_of::size<Seq1>, result_of::size<Seq2> >
|
||||||
|
>
|
||||||
{};
|
{};
|
||||||
|
|
||||||
}}}
|
}}}
|
||||||
|
@ -14,11 +14,21 @@
|
|||||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||||
#include <boost/fusion/sequence/comparison/detail/equal_to.hpp>
|
#include <boost/fusion/sequence/comparison/detail/equal_to.hpp>
|
||||||
#include <boost/fusion/sequence/comparison/detail/enable_comparison.hpp>
|
#include <boost/fusion/sequence/comparison/detail/enable_comparison.hpp>
|
||||||
#include <boost/utility/enable_if.hpp>
|
|
||||||
|
|
||||||
namespace boost { namespace fusion
|
namespace boost { namespace fusion
|
||||||
{
|
{
|
||||||
namespace sequence_operators
|
template <typename Seq1, typename Seq2>
|
||||||
|
inline bool
|
||||||
|
equal_to(Seq1 const& a, Seq2 const& b)
|
||||||
|
{
|
||||||
|
return result_of::size<Seq1>::value == result_of::size<Seq2>::value
|
||||||
|
&& detail::sequence_equal_to<
|
||||||
|
Seq1 const, Seq2 const
|
||||||
|
, result_of::size<Seq1>::value == result_of::size<Seq2>::value>::
|
||||||
|
call(fusion::begin(a), fusion::begin(b));
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace operators
|
||||||
{
|
{
|
||||||
template <typename Seq1, typename Seq2>
|
template <typename Seq1, typename Seq2>
|
||||||
inline typename
|
inline typename
|
||||||
@ -28,14 +38,10 @@ namespace boost { namespace fusion
|
|||||||
>::type
|
>::type
|
||||||
operator==(Seq1 const& a, Seq2 const& b)
|
operator==(Seq1 const& a, Seq2 const& b)
|
||||||
{
|
{
|
||||||
return result_of::size<Seq1>::value == result_of::size<Seq2>::value
|
return fusion::equal_to(a, b);
|
||||||
&& detail::sequence_equal_to<
|
|
||||||
Seq1 const, Seq2 const
|
|
||||||
, result_of::size<Seq1>::value == result_of::size<Seq2>::value>::
|
|
||||||
call(fusion::begin(a), fusion::begin(b));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
using sequence_operators::operator==;
|
using operators::operator==;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||||
|
#include <boost/fusion/sequence/comparison/detail/enable_comparison.hpp>
|
||||||
|
|
||||||
#if defined(FUSION_DIRECT_OPERATOR_USAGE)
|
#if defined(FUSION_DIRECT_OPERATOR_USAGE)
|
||||||
#include <boost/fusion/sequence/comparison/detail/greater.hpp>
|
#include <boost/fusion/sequence/comparison/detail/greater.hpp>
|
||||||
@ -19,18 +20,11 @@
|
|||||||
#include <boost/fusion/sequence/comparison/less.hpp>
|
#include <boost/fusion/sequence/comparison/less.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/fusion/sequence/comparison/detail/enable_comparison.hpp>
|
|
||||||
#include <boost/utility/enable_if.hpp>
|
|
||||||
|
|
||||||
namespace boost { namespace fusion
|
namespace boost { namespace fusion
|
||||||
{
|
{
|
||||||
template <typename Seq1, typename Seq2>
|
template <typename Seq1, typename Seq2>
|
||||||
inline typename
|
inline bool
|
||||||
enable_if<
|
greater(Seq1 const& a, Seq2 const& b)
|
||||||
detail::enable_comparison<Seq1, Seq2>
|
|
||||||
, bool
|
|
||||||
>::type
|
|
||||||
operator>(Seq1 const& a, Seq2 const& b)
|
|
||||||
{
|
{
|
||||||
#if defined(FUSION_DIRECT_OPERATOR_USAGE)
|
#if defined(FUSION_DIRECT_OPERATOR_USAGE)
|
||||||
return detail::sequence_greater<Seq1 const, Seq2 const>::
|
return detail::sequence_greater<Seq1 const, Seq2 const>::
|
||||||
@ -39,6 +33,21 @@ namespace boost { namespace fusion
|
|||||||
return (b < a);
|
return (b < a);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace operators
|
||||||
|
{
|
||||||
|
template <typename Seq1, typename Seq2>
|
||||||
|
inline typename
|
||||||
|
enable_if<
|
||||||
|
detail::enable_comparison<Seq1, Seq2>
|
||||||
|
, bool
|
||||||
|
>::type
|
||||||
|
operator>(Seq1 const& a, Seq2 const& b)
|
||||||
|
{
|
||||||
|
return fusion::greater(a, b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
using operators::operator>;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||||
|
#include <boost/fusion/sequence/comparison/detail/enable_comparison.hpp>
|
||||||
|
|
||||||
#if defined(FUSION_DIRECT_OPERATOR_USAGE)
|
#if defined(FUSION_DIRECT_OPERATOR_USAGE)
|
||||||
#include <boost/fusion/sequence/comparison/detail/greater_equal.hpp>
|
#include <boost/fusion/sequence/comparison/detail/greater_equal.hpp>
|
||||||
@ -19,18 +20,11 @@
|
|||||||
#include <boost/fusion/sequence/comparison/less.hpp>
|
#include <boost/fusion/sequence/comparison/less.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/fusion/sequence/comparison/detail/enable_comparison.hpp>
|
|
||||||
#include <boost/utility/enable_if.hpp>
|
|
||||||
|
|
||||||
namespace boost { namespace fusion
|
namespace boost { namespace fusion
|
||||||
{
|
{
|
||||||
template <typename Seq1, typename Seq2>
|
template <typename Seq1, typename Seq2>
|
||||||
inline typename
|
inline bool
|
||||||
enable_if<
|
greater_equal(Seq1 const& a, Seq2 const& b)
|
||||||
detail::enable_comparison<Seq1, Seq2>
|
|
||||||
, bool
|
|
||||||
>::type
|
|
||||||
operator>=(Seq1 const& a, Seq2 const& b)
|
|
||||||
{
|
{
|
||||||
#if defined(FUSION_DIRECT_OPERATOR_USAGE)
|
#if defined(FUSION_DIRECT_OPERATOR_USAGE)
|
||||||
return detail::sequence_greater_equal<Seq1 const, Seq2 const>::
|
return detail::sequence_greater_equal<Seq1 const, Seq2 const>::
|
||||||
@ -39,6 +33,21 @@ namespace boost { namespace fusion
|
|||||||
return !(a < b);
|
return !(a < b);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace operators
|
||||||
|
{
|
||||||
|
template <typename Seq1, typename Seq2>
|
||||||
|
inline typename
|
||||||
|
enable_if<
|
||||||
|
detail::enable_comparison<Seq1, Seq2>
|
||||||
|
, bool
|
||||||
|
>::type
|
||||||
|
operator>=(Seq1 const& a, Seq2 const& b)
|
||||||
|
{
|
||||||
|
return fusion::greater_equal(a, b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
using operators::operator>=;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -14,10 +14,19 @@
|
|||||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||||
#include <boost/fusion/sequence/comparison/detail/less.hpp>
|
#include <boost/fusion/sequence/comparison/detail/less.hpp>
|
||||||
#include <boost/fusion/sequence/comparison/detail/enable_comparison.hpp>
|
#include <boost/fusion/sequence/comparison/detail/enable_comparison.hpp>
|
||||||
#include <boost/utility/enable_if.hpp>
|
|
||||||
|
|
||||||
namespace boost { namespace fusion
|
namespace boost { namespace fusion
|
||||||
{
|
{
|
||||||
|
template <typename Seq1, typename Seq2>
|
||||||
|
inline bool
|
||||||
|
less(Seq1 const& a, Seq2 const& b)
|
||||||
|
{
|
||||||
|
return detail::sequence_less<Seq1 const, Seq2 const>::
|
||||||
|
call(fusion::begin(a), fusion::begin(b));
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace operators
|
||||||
|
{
|
||||||
template <typename Seq1, typename Seq2>
|
template <typename Seq1, typename Seq2>
|
||||||
inline typename
|
inline typename
|
||||||
enable_if<
|
enable_if<
|
||||||
@ -26,9 +35,10 @@ namespace boost { namespace fusion
|
|||||||
>::type
|
>::type
|
||||||
operator<(Seq1 const& a, Seq2 const& b)
|
operator<(Seq1 const& a, Seq2 const& b)
|
||||||
{
|
{
|
||||||
return detail::sequence_less<Seq1 const, Seq2 const>::
|
return fusion::less(a, b);
|
||||||
call(fusion::begin(a), fusion::begin(b));
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
using operators::operator<;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||||
|
#include <boost/fusion/sequence/comparison/detail/enable_comparison.hpp>
|
||||||
|
|
||||||
#if defined(FUSION_DIRECT_OPERATOR_USAGE)
|
#if defined(FUSION_DIRECT_OPERATOR_USAGE)
|
||||||
#include <boost/fusion/sequence/comparison/detail/less_equal.hpp>
|
#include <boost/fusion/sequence/comparison/detail/less_equal.hpp>
|
||||||
@ -19,18 +20,11 @@
|
|||||||
#include <boost/fusion/sequence/comparison/less.hpp>
|
#include <boost/fusion/sequence/comparison/less.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/fusion/sequence/comparison/detail/enable_comparison.hpp>
|
|
||||||
#include <boost/utility/enable_if.hpp>
|
|
||||||
|
|
||||||
namespace boost { namespace fusion
|
namespace boost { namespace fusion
|
||||||
{
|
{
|
||||||
template <typename Seq1, typename Seq2>
|
template <typename Seq1, typename Seq2>
|
||||||
inline typename
|
inline bool
|
||||||
enable_if<
|
less_equal(Seq1 const& a, Seq2 const& b)
|
||||||
detail::enable_comparison<Seq1, Seq2>
|
|
||||||
, bool
|
|
||||||
>::type
|
|
||||||
operator<=(Seq1 const& a, Seq2 const& b)
|
|
||||||
{
|
{
|
||||||
#if defined(FUSION_DIRECT_OPERATOR_USAGE)
|
#if defined(FUSION_DIRECT_OPERATOR_USAGE)
|
||||||
return detail::sequence_less_equal<Seq1 const, Seq2 const>::
|
return detail::sequence_less_equal<Seq1 const, Seq2 const>::
|
||||||
@ -39,6 +33,49 @@ namespace boost { namespace fusion
|
|||||||
return !(b < a);
|
return !(b < a);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace operators
|
||||||
|
{
|
||||||
|
#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1400)
|
||||||
|
// Workaround for VC8.0 and VC7.1
|
||||||
|
template <typename Seq1, typename Seq2>
|
||||||
|
inline bool
|
||||||
|
operator<=(sequence_base<Seq1> const& a, sequence_base<Seq2> const& b)
|
||||||
|
{
|
||||||
|
return less_equal(a.derived(), b.derived());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Seq1, typename Seq2>
|
||||||
|
inline typename disable_if<detail::is_native_fusion_sequence<Seq2>, bool>::type
|
||||||
|
operator<=(sequence_base<Seq1> const& a, Seq2 const& b)
|
||||||
|
{
|
||||||
|
return less_equal(a.derived(), b);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Seq1, typename Seq2>
|
||||||
|
inline typename disable_if<detail::is_native_fusion_sequence<Seq1>, bool>::type
|
||||||
|
operator<=(Seq1 const& a, sequence_base<Seq2> const& b)
|
||||||
|
{
|
||||||
|
return less_equal(a, b.derived());
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
// Somehow VC8.0 and VC7.1 does not like this code
|
||||||
|
// but barfs somewhere else.
|
||||||
|
|
||||||
|
template <typename Seq1, typename Seq2>
|
||||||
|
inline typename
|
||||||
|
enable_if<
|
||||||
|
detail::enable_comparison<Seq1, Seq2>
|
||||||
|
, bool
|
||||||
|
>::type
|
||||||
|
operator<=(Seq1 const& a, Seq2 const& b)
|
||||||
|
{
|
||||||
|
return fusion::less_equal(a, b);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
using operators::operator<=;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||||
|
#include <boost/fusion/sequence/comparison/detail/enable_comparison.hpp>
|
||||||
|
|
||||||
#if defined(FUSION_DIRECT_OPERATOR_USAGE)
|
#if defined(FUSION_DIRECT_OPERATOR_USAGE)
|
||||||
#include <boost/fusion/sequence/comparison/detail/not_equal_to.hpp>
|
#include <boost/fusion/sequence/comparison/detail/not_equal_to.hpp>
|
||||||
@ -19,20 +20,11 @@
|
|||||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/fusion/sequence/comparison/detail/enable_comparison.hpp>
|
|
||||||
#include <boost/utility/enable_if.hpp>
|
|
||||||
|
|
||||||
namespace boost { namespace fusion
|
namespace boost { namespace fusion
|
||||||
{
|
{
|
||||||
namespace sequence_operators
|
|
||||||
{
|
|
||||||
template <typename Seq1, typename Seq2>
|
template <typename Seq1, typename Seq2>
|
||||||
inline typename
|
inline bool
|
||||||
enable_if<
|
not_equal_to(Seq1 const& a, Seq2 const& b)
|
||||||
detail::enable_equality<Seq1, Seq2>
|
|
||||||
, bool
|
|
||||||
>::type
|
|
||||||
operator!=(Seq1 const& a, Seq2 const& b)
|
|
||||||
{
|
{
|
||||||
#if defined(FUSION_DIRECT_OPERATOR_USAGE)
|
#if defined(FUSION_DIRECT_OPERATOR_USAGE)
|
||||||
return result_of::size<Seq1>::value != result_of::size<Seq2>::value
|
return result_of::size<Seq1>::value != result_of::size<Seq2>::value
|
||||||
@ -44,9 +36,21 @@ namespace boost { namespace fusion
|
|||||||
return !(a == b);
|
return !(a == b);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
using sequence_operators::operator!=;
|
namespace operators
|
||||||
|
{
|
||||||
|
template <typename Seq1, typename Seq2>
|
||||||
|
inline typename
|
||||||
|
enable_if<
|
||||||
|
detail::enable_equality<Seq1, Seq2>
|
||||||
|
, bool
|
||||||
|
>::type
|
||||||
|
operator!=(Seq1 const& a, Seq2 const& b)
|
||||||
|
{
|
||||||
|
return fusion::not_equal_to(a, b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
using operators::operator!=;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,12 +12,20 @@
|
|||||||
|
|
||||||
#include <istream>
|
#include <istream>
|
||||||
#include <boost/fusion/sequence/io/detail/in.hpp>
|
#include <boost/fusion/sequence/io/detail/in.hpp>
|
||||||
#include <boost/fusion/support/is_sequence.hpp>
|
#include <boost/fusion/support/sequence_base.hpp>
|
||||||
#include <boost/utility/enable_if.hpp>
|
|
||||||
#include <boost/mpl/or.hpp>
|
|
||||||
|
|
||||||
namespace boost { namespace fusion
|
namespace boost { namespace fusion
|
||||||
{
|
{
|
||||||
|
template <typename Sequence>
|
||||||
|
inline std::istream&
|
||||||
|
in(std::istream& is, Sequence& seq)
|
||||||
|
{
|
||||||
|
detail::read_sequence(is, seq);
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace operators
|
||||||
|
{
|
||||||
template <typename Sequence>
|
template <typename Sequence>
|
||||||
inline typename
|
inline typename
|
||||||
enable_if<
|
enable_if<
|
||||||
@ -26,9 +34,10 @@ namespace boost { namespace fusion
|
|||||||
>::type
|
>::type
|
||||||
operator>>(std::istream& is, Sequence& seq)
|
operator>>(std::istream& is, Sequence& seq)
|
||||||
{
|
{
|
||||||
detail::read_sequence(is, seq);
|
return fusion::in(is, seq);
|
||||||
return is;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
using operators::operator>>;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -18,6 +18,16 @@
|
|||||||
|
|
||||||
namespace boost { namespace fusion
|
namespace boost { namespace fusion
|
||||||
{
|
{
|
||||||
|
template <typename Sequence>
|
||||||
|
inline std::ostream&
|
||||||
|
out(std::ostream& os, Sequence& seq)
|
||||||
|
{
|
||||||
|
detail::print_sequence(os, seq);
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace operators
|
||||||
|
{
|
||||||
template <typename Sequence>
|
template <typename Sequence>
|
||||||
inline typename
|
inline typename
|
||||||
enable_if<
|
enable_if<
|
||||||
@ -26,9 +36,10 @@ namespace boost { namespace fusion
|
|||||||
>::type
|
>::type
|
||||||
operator<<(std::ostream& os, Sequence const& seq)
|
operator<<(std::ostream& os, Sequence const& seq)
|
||||||
{
|
{
|
||||||
detail::print_sequence(os, seq);
|
return fusion::out(os, seq);
|
||||||
return os;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
using operators::operator<<;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user