remove any remaining use of boost::lambda
obsolete now, we can use the lambdas of the stock language
This commit is contained in:
parent
c2ea15695e
commit
561e036e0b
5 changed files with 34 additions and 44 deletions
|
|
@ -59,8 +59,7 @@
|
|||
#include <set>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <boost/utility.hpp>
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
|
||||
|
||||
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<TAR>::access(table_)
|
||||
, var(res) += _1
|
||||
, [&] (Record<TAR>& entry)
|
||||
{
|
||||
res += string(entry);
|
||||
}
|
||||
);
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 <boost/lambda/lambda.hpp>
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <unordered_map>
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ namespace test {
|
|||
PlacementMO::ID derailed_;
|
||||
};
|
||||
|
||||
static Ambush _kinky_;
|
||||
return *reinterpret_cast<Scope*> (&_kinky_);
|
||||
static Ambush _shady_scope_;
|
||||
return *reinterpret_cast<Scope*> (&_shady_scope_);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,8 +29,6 @@
|
|||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
|
@ -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
|
||||
// <functional> 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<typename CO>
|
||||
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<typename CO>
|
||||
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<VecI> 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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue