From 561e036e0b55aa2f7a4258750b38887affe752ce Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Mon, 12 May 2014 01:12:45 +0200 Subject: [PATCH] remove any remaining use of boost::lambda obsolete now, we can use the lambdas of the stock language --- src/common/query/defs-registry.hpp | 11 +++-- src/proc/mobject/session/placement-index.cpp | 9 ++-- .../mobject/session/test-scope-invalid.hpp | 4 +- tests/library/cmdline-wrapper-test.cpp | 9 +--- tests/library/util-foreach-test.cpp | 45 +++++++++---------- 5 files changed, 34 insertions(+), 44 deletions(-) diff --git a/src/common/query/defs-registry.hpp b/src/common/query/defs-registry.hpp index 0e58c03b7..c3a7db7be 100644 --- a/src/common/query/defs-registry.hpp +++ b/src/common/query/defs-registry.hpp @@ -59,8 +59,7 @@ #include #include #include -#include -#include +#include namespace lumiera{ @@ -69,10 +68,7 @@ namespace query { using lib::P; using lib::ClassLock; using std::weak_ptr; - using std::string; - using boost::lambda::_1; - using boost::lambda::var; namespace impl { @@ -336,7 +332,10 @@ namespace query { { string res; util::for_each ( Slot::access(table_) - , var(res) += _1 + , [&] (Record& entry) + { + res += string(entry); + } ); return res; } diff --git a/src/proc/mobject/session/placement-index.cpp b/src/proc/mobject/session/placement-index.cpp index 1a100c9aa..c21dd5208 100644 --- a/src/proc/mobject/session/placement-index.cpp +++ b/src/proc/mobject/session/placement-index.cpp @@ -28,7 +28,7 @@ ** considered to be part of the session. ** ** Simple hash based implementation. Seems adequate for now (12/09). - ** A main table associates Placement-ID to an Placement \em instance, which is contained + ** A main table associates Placement-ID to a Placement \em instance, which is contained ** and managed within this index. A second hashtable allows to reverse lookup the scope ** associations, especially for enumerating the contents of a scope. The latter is done ** by wrapping up an STL iterator range into a "Lumiera Forward Iterator" (adapter). @@ -59,7 +59,6 @@ #include "lib/iter-source.hpp" #include "include/logging.h" -#include #include #include #include @@ -74,7 +73,6 @@ namespace session { using boost::hash; using boost::noncopyable; - using boost::lambda::var; using std::shared_ptr; using std::unordered_map; using std::unordered_multimap; @@ -578,8 +576,6 @@ namespace session { ,LUMIERA_ERROR_INDEX_CORRUPTED) { } }; - - boost::lambda::placeholder1_type _1_; } @@ -632,7 +628,8 @@ namespace session { return; // because root is it's own scope iterator elementsInScope = tab.queryScopeContents(theScope); - bool properlyRegistered = has_any (elementsInScope, _1_ == var(theElement)); + auto equalsTheElement = [&](PMO& entry) { return entry == theElement; }; + bool properlyRegistered = has_any (elementsInScope, equalsTheElement); VERIFY ( properlyRegistered, "(1.8) Elements", "Element not registered as member of the enclosing scope: "+ theElement); } diff --git a/tests/core/proc/mobject/session/test-scope-invalid.hpp b/tests/core/proc/mobject/session/test-scope-invalid.hpp index 4aec3296d..cadc0267a 100644 --- a/tests/core/proc/mobject/session/test-scope-invalid.hpp +++ b/tests/core/proc/mobject/session/test-scope-invalid.hpp @@ -53,8 +53,8 @@ namespace test { PlacementMO::ID derailed_; }; - static Ambush _kinky_; - return *reinterpret_cast (&_kinky_); + static Ambush _shady_scope_; + return *reinterpret_cast (&_shady_scope_); } } diff --git a/tests/library/cmdline-wrapper-test.cpp b/tests/library/cmdline-wrapper-test.cpp index 50b03836a..127b4c7a3 100644 --- a/tests/library/cmdline-wrapper-test.cpp +++ b/tests/library/cmdline-wrapper-test.cpp @@ -29,8 +29,6 @@ #include #include -#include - using util::for_each; using std::string; using std::cout; @@ -41,9 +39,6 @@ using std::endl; namespace lib { namespace test{ - using boost::lambda::_1; - using boost::lambda::var; - /** @test for lib::Cmdline, wrapping various example cmdlines */ @@ -57,7 +52,7 @@ namespace test{ testLine("spam"); testLine("\nspam"); testLine("eat more spam"); - testLine(" oo _O()O_ ä + €"); + testLine(" oo _O()O_ ☭ + €"); testLine("Ω\tooΩ\toΩo\tΩoo"); testStandardCmdlineformat(); @@ -70,7 +65,7 @@ namespace test{ int i=0; Cmdline theCmdline (cmdline); - for_each(theCmdline, (cout << var(i)++ << "|" << _1 << "|\n")); + for_each(theCmdline, [&](string const& arg) { cout << i++ << "|" << arg << "|\n";}); cout << "-->" << theCmdline << endl; // consistency checks diff --git a/tests/library/util-foreach-test.cpp b/tests/library/util-foreach-test.cpp index 6f8183264..66e420f69 100644 --- a/tests/library/util-foreach-test.cpp +++ b/tests/library/util-foreach-test.cpp @@ -27,7 +27,6 @@ #include -#include #include #include #include @@ -45,8 +44,6 @@ using std::ref; using std::cout; using std::endl; -using namespace boost::lambda; - namespace util { namespace test { @@ -60,11 +57,8 @@ namespace test { uint NUM_ELMS = 10; - - // need explicit definitions here, because we use - // and boost::lambda at the same time - std::_Placeholder<1> _1; - boost::lambda::placeholder1_type _1_; + // Placeholder for argument in bind-expressions + std::_Placeholder<1> _1; VecI @@ -351,7 +345,7 @@ namespace test { } - /** @test use a lambda-expression, to be invoked for each element */ + /** @test use lambda-expressions, to be invoked for each element */ template void check_foreach_lambda (CO coll) @@ -359,29 +353,29 @@ namespace test { ANNOUNCE (check_foreach_lambda); uint sum(0); - for_each (coll, var(sum) += _1_ ); + for_each (coll, [&sum] (uint entry) { sum += entry; }); CHECK (sum == (NUM_ELMS+1) * NUM_ELMS/2); - CHECK (!and_all (coll, _1_ - 1 )); - CHECK ( has_any (coll, _1_ + 1 )); + CHECK (!and_all (coll, [] (uint elm) { return elm - 1; })); + CHECK ( has_any (coll, [] (uint elm) { return elm + 1; })); } /** @test verify the logic of universal and existential quantisation. - * We use a predicate generated on-the-fly as lambda expression */ + * Using lambda expressions as predicates */ template void check_existence_quant (CO coll) { ANNOUNCE (check_existence_quant); - CHECK ( and_all (coll, 0 < _1_ )); - CHECK (!and_all (coll, 1 < _1_ )); + CHECK ( and_all (coll, [] (uint elm) { return 0 < elm; })); + CHECK (!and_all (coll, [] (uint elm) { return 1 < elm; })); - CHECK ( has_any (coll, 0 < _1_ )); - CHECK ( has_any (coll, _1_ >= NUM_ELMS )); - CHECK (!has_any (coll, _1_ > NUM_ELMS )); + CHECK ( has_any (coll, [] (uint elm) { return 0 < elm; })); + CHECK ( has_any (coll, [] (uint elm) { return elm >= NUM_ELMS; })); + CHECK (!has_any (coll, [] (uint elm) { return elm > NUM_ELMS; })); } @@ -442,23 +436,28 @@ namespace test { #define SHOW_CONTAINER for_each (coll, plainFunc); _NL_ + int counter = NUM_ELMS; + auto assign_and_decrement = [&] (int& entry) + { + entry = counter--; + }; + // use a const reference to pass the container... VecI const& passByConstRef (coll); - int counter = NUM_ELMS; - for_each (passByConstRef, _1_ = var(counter)-- ); + for_each (passByConstRef, assign_and_decrement ); SHOW_CONTAINER // indeed got modifications into the original container! CHECK (0 == counter); // passing anonymous temporary - for_each (buildTestNumberz(NUM_ELMS), _1_ = var(counter)-- ); + for_each (buildTestNumberz(NUM_ELMS), assign_and_decrement ); // passing a smart-ptr managed copy std::shared_ptr bySmartPtr (new VecI (coll)); - for_each (bySmartPtr, _1_ = var(counter)-- ); + for_each (bySmartPtr, assign_and_decrement ); // both didn't influence the original container SHOW_CONTAINER @@ -468,7 +467,7 @@ namespace test { // passing the container by pointer is also possible const VecI * const passByConstPointer (&coll); - for_each (passByConstPointer, _1_ = var(counter)-- ); + for_each (passByConstPointer, assign_and_decrement ); SHOW_CONTAINER // ...and does indeed influence the original container }