|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r61013 - in trunk/libs/spirit/example/scheme: . test
From: joel_at_[hidden]
Date: 2010-04-03 04:48:26
Author: djowel
Date: 2010-04-03 04:48:25 EDT (Sat, 03 Apr 2010)
New Revision: 61013
URL: http://svn.boost.org/trac/boost/changeset/61013
Log:
scheme operators
Text files modified:
trunk/libs/spirit/example/scheme/test/utree_test.cpp | 8 +++++++-
trunk/libs/spirit/example/scheme/utree_operators.hpp | 33 +++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 1 deletions(-)
Modified: trunk/libs/spirit/example/scheme/test/utree_test.cpp
==============================================================================
--- trunk/libs/spirit/example/scheme/test/utree_test.cpp (original)
+++ trunk/libs/spirit/example/scheme/test/utree_test.cpp 2010-04-03 04:48:25 EDT (Sat, 03 Apr 2010)
@@ -195,7 +195,7 @@
println(std::cout, vals[2]);
}
- { // arithmetic
+ { // operators
BOOST_ASSERT((utree(456) + utree(123)) == utree(456 + 123));
BOOST_ASSERT((utree(456) + utree(123.456)) == utree(456 + 123.456));
BOOST_ASSERT((utree(456) - utree(123)) == utree(456 - 123));
@@ -205,6 +205,12 @@
BOOST_ASSERT((utree(456) / utree(123)) == utree(456 / 123));
BOOST_ASSERT((utree(456) / utree(123.456)) == utree(456 / 123.456));
BOOST_ASSERT((utree(456) % utree(123)) == utree(456 % 123));
+
+ BOOST_ASSERT((utree(456) & utree(123)) == utree(456 & 123));
+ BOOST_ASSERT((utree(456) | utree(123)) == utree(456 | 123));
+ BOOST_ASSERT((utree(456) ^ utree(123)) == utree(456 ^ 123));
+ BOOST_ASSERT((utree(456) << utree(3)) == utree(456 << 3));
+ BOOST_ASSERT((utree(456) >> utree(2)) == utree(456 >> 2));
}
return 0;
Modified: trunk/libs/spirit/example/scheme/utree_operators.hpp
==============================================================================
--- trunk/libs/spirit/example/scheme/utree_operators.hpp (original)
+++ trunk/libs/spirit/example/scheme/utree_operators.hpp 2010-04-03 04:48:25 EDT (Sat, 03 Apr 2010)
@@ -29,6 +29,12 @@
utree operator/(utree const& a, utree const& b);
utree operator%(utree const& a, utree const& b);
+ utree operator&(utree const& a, utree const& b);
+ utree operator|(utree const& a, utree const& b);
+ utree operator^(utree const& a, utree const& b);
+ utree operator<<(utree const& a, utree const& b);
+ utree operator>>(utree const& a, utree const& b);
+
// Implementation
struct utree_is_equal
{
@@ -326,6 +332,12 @@
SCHEME_CREATE_ARITHMETIC_FUNCTION(divides, a/b);
SCHEME_CREATE_INTEGRAL_FUNCTION(modulus, a%b);
+ SCHEME_CREATE_INTEGRAL_FUNCTION(bitand_, a&b);
+ SCHEME_CREATE_INTEGRAL_FUNCTION(bitor_, a|b);
+ SCHEME_CREATE_INTEGRAL_FUNCTION(bitxor_, a^b);
+ SCHEME_CREATE_INTEGRAL_FUNCTION(shift_left, a<<b);
+ SCHEME_CREATE_INTEGRAL_FUNCTION(shift_right, a>>b);
+
inline utree operator+(utree const& a, utree const& b)
{
return utree::visit(a, b, arithmetic_function_plus);
@@ -350,6 +362,27 @@
{
return utree::visit(a, b, integral_function_modulus);
}
+
+ inline utree operator&(utree const& a, utree const& b)
+ {
+ return utree::visit(a, b, integral_function_bitand_);
+ }
+ inline utree operator|(utree const& a, utree const& b)
+ {
+ return utree::visit(a, b, integral_function_bitor_);
+ }
+ inline utree operator^(utree const& a, utree const& b)
+ {
+ return utree::visit(a, b, integral_function_bitxor_);
+ }
+ inline utree operator<<(utree const& a, utree const& b)
+ {
+ return utree::visit(a, b, integral_function_shift_left);
+ }
+ inline utree operator>>(utree const& a, utree const& b)
+ {
+ return utree::visit(a, b, integral_function_shift_right);
+ }
}
#endif
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk