less_equal.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*=============================================================================
  2. Copyright (c) 1999-2003 Jaakko Jarvi
  3. Copyright (c) 2001-2011 Joel de Guzman
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. ==============================================================================*/
  7. #if !defined(FUSION_LESS_EQUAL_05052005_0432)
  8. #define FUSION_LESS_EQUAL_05052005_0432
  9. #include <boost/fusion/sequence/intrinsic/begin.hpp>
  10. #include <boost/fusion/sequence/intrinsic/end.hpp>
  11. #include <boost/fusion/sequence/intrinsic/size.hpp>
  12. #include <boost/fusion/sequence/comparison/enable_comparison.hpp>
  13. #include <boost/fusion/support/is_sequence.hpp>
  14. #if defined(FUSION_DIRECT_OPERATOR_USAGE)
  15. #include <boost/fusion/sequence/comparison/detail/less_equal.hpp>
  16. #else
  17. #include <boost/fusion/sequence/comparison/less.hpp>
  18. #endif
  19. namespace boost { namespace fusion
  20. {
  21. template <typename Seq1, typename Seq2>
  22. inline bool
  23. less_equal(Seq1 const& a, Seq2 const& b)
  24. {
  25. #if defined(FUSION_DIRECT_OPERATOR_USAGE)
  26. return detail::sequence_less_equal<Seq1 const, Seq2 const>::
  27. call(fusion::begin(a), fusion::begin(b));
  28. #else
  29. return !(b < a);
  30. #endif
  31. }
  32. namespace operators
  33. {
  34. #if defined(BOOST_MSVC) && (BOOST_MSVC <= 1400)
  35. // Workaround for VC8.0 and VC7.1
  36. template <typename Seq1, typename Seq2>
  37. inline bool
  38. operator<=(sequence_base<Seq1> const& a, sequence_base<Seq2> const& b)
  39. {
  40. return less_equal(a.derived(), b.derived());
  41. }
  42. template <typename Seq1, typename Seq2>
  43. inline typename disable_if<traits::is_native_fusion_sequence<Seq2>, bool>::type
  44. operator<=(sequence_base<Seq1> const& a, Seq2 const& b)
  45. {
  46. return less_equal(a.derived(), b);
  47. }
  48. template <typename Seq1, typename Seq2>
  49. inline typename disable_if<traits::is_native_fusion_sequence<Seq1>, bool>::type
  50. operator<=(Seq1 const& a, sequence_base<Seq2> const& b)
  51. {
  52. return less_equal(a, b.derived());
  53. }
  54. #else
  55. // Somehow VC8.0 and VC7.1 does not like this code
  56. // but barfs somewhere else.
  57. template <typename Seq1, typename Seq2>
  58. inline typename
  59. boost::enable_if<
  60. traits::enable_comparison<Seq1, Seq2>
  61. , bool
  62. >::type
  63. operator<=(Seq1 const& a, Seq2 const& b)
  64. {
  65. return fusion::less_equal(a, b);
  66. }
  67. #endif
  68. }
  69. using operators::operator<=;
  70. }}
  71. #endif