P
PengYu.UT
Hi,
I have the following code. However, the lambda expression becomes too
complicated, because I put "boost::lambda::" before _1 and _2.
To make it more readable, I can uncomment the commented line
"using ...". However, this would pollute the global namespace, which
is undesirable.
I'm wondering if there is any way to enable a namespace inside a class
just like enable a namespace in another namespace?
Thanks,
Peng
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/core.hpp>
#include <iostream>
//using namespace boost::lambda;
struct A {
int doit() {
int a = 10;
return (boost::lambda::_1 + boost::lambda::_2)(a, a);
}
};
int main() {
A a;
std::cout << a.doit() << std::endl;
}
I have the following code. However, the lambda expression becomes too
complicated, because I put "boost::lambda::" before _1 and _2.
To make it more readable, I can uncomment the commented line
"using ...". However, this would pollute the global namespace, which
is undesirable.
I'm wondering if there is any way to enable a namespace inside a class
just like enable a namespace in another namespace?
Thanks,
Peng
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/core.hpp>
#include <iostream>
//using namespace boost::lambda;
struct A {
int doit() {
int a = 10;
return (boost::lambda::_1 + boost::lambda::_2)(a, a);
}
};
int main() {
A a;
std::cout << a.doit() << std::endl;
}