diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2014-12-12 13:46:41 -0800 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2014-12-12 13:46:41 -0800 |
commit | eae38f7d57be5576199294b501e082c6d850473c (patch) | |
tree | 2ca2cac78beeb339676d9a405462f3ed83776fa3 /indra/llcommon/tests/llsdserialize_test.cpp | |
parent | 7282d29bf82deaeb5649b09f062d42c04df6eb55 (diff) |
Eliminate use of boost::lambda with boost::function (Trac #10864).
https://svn.boost.org/trac/boost/ticket/10864
I've used boost::lambda with boost::function in a number of creative ways over
the years. But the clang 6 shipped with Xcode 6 seems to have somehow broken
lambda + function in Boost 1.57. boost::phoenix is a partial workaround.
Sadly, lambda's comma-operator overload doesn't seem to be supported,
necessitating a couple ugly workarounds.
With real lambdas now supported by current compilers, I'm sure the Boost
community has little incentive to repair the lambda + function problem.
Presumably we'll be able to use such features ourselves Real Soon Now...
Diffstat (limited to 'indra/llcommon/tests/llsdserialize_test.cpp')
-rwxr-xr-x | indra/llcommon/tests/llsdserialize_test.cpp | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/indra/llcommon/tests/llsdserialize_test.cpp b/indra/llcommon/tests/llsdserialize_test.cpp index b5893135ea..afd4e7c8c1 100755 --- a/indra/llcommon/tests/llsdserialize_test.cpp +++ b/indra/llcommon/tests/llsdserialize_test.cpp @@ -46,9 +46,9 @@ typedef U32 uint32_t; #include "boost/range.hpp" #include "boost/foreach.hpp" #include "boost/function.hpp" -#include "boost/lambda/lambda.hpp" -#include "boost/lambda/bind.hpp" -namespace lambda = boost::lambda; +#include "boost/phoenix/bind/bind_function.hpp" +#include "boost/phoenix/core/argument.hpp" +using namespace boost::phoenix; #include "../llsd.h" #include "../llsdserialize.h" @@ -1612,6 +1612,20 @@ namespace tut "print 'Running on', sys.platform\n"); } + // helper for test<3> + static void writeLLSDArray(std::ostream& out, const LLSD& array) + { + BOOST_FOREACH(LLSD item, llsd::inArray(array)) + { + LLSDSerialize::toNotation(item, out); + // It's important to separate with newlines because Python's llsd + // module doesn't support parsing from a file stream, only from a + // string, so we have to know how much of the file to read into a + // string. + out << '\n'; + } + } + template<> template<> void TestPythonCompatibleObject::test<3>() { @@ -1639,26 +1653,16 @@ namespace tut " assert False, 'Too many data items'\n"; // Create an llsdXXXXXX file containing 'data' serialized to - // notation. It's important to separate with newlines because Python's - // llsd module doesn't support parsing from a file stream, only from a - // string, so we have to know how much of the file to read into a - // string. + // notation. NamedTempFile file("llsd", // NamedTempFile's boost::function constructor // takes a callable. To this callable it passes the // std::ostream with which it's writing the - // NamedTempFile. This lambda-based expression - // first calls LLSD::Serialize() with that ostream, - // then streams a newline to it, etc. - (lambda::bind(LLSDSerialize::toNotation, cdata[0], lambda::_1), - lambda::_1 << '\n', - lambda::bind(LLSDSerialize::toNotation, cdata[1], lambda::_1), - lambda::_1 << '\n', - lambda::bind(LLSDSerialize::toNotation, cdata[2], lambda::_1), - lambda::_1 << '\n')); + // NamedTempFile. + bind(writeLLSDArray, placeholders::arg1, cdata)); python("read C++ notation", - lambda::_1 << + placeholders::arg1 << import_llsd << "def parse_each(iterable):\n" " for item in iterable:\n" @@ -1679,7 +1683,7 @@ namespace tut NamedTempFile file("llsd", ""); python("write Python notation", - lambda::_1 << + placeholders::arg1 << "from __future__ import with_statement\n" << import_llsd << "DATA = [\n" |