$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Peng Yu (pengyu.ut_at_[hidden])
Date: 2007-03-14 17:35:47
Hi,
I have the following code which requires a definition of a class
"not_fun". I want to replace it with lambda expression. Would you
please let me know what the best way would be?
Thanks,
Peng
#include <iostream>
template <bool B>
class not_fun;
template <>
struct not_fun<true> {
static bool doit(bool x) { return x; }
};
template <>
struct not_fun<false> {
static bool doit(bool x) { return !x; }
};
template <bool B>
class A {
public:
A() { }
bool compute(bool b) const {
if(not_fun<B>::doit(b)) // how replace this with lambda expression?
return true;
return false;
}
private:
};
int main()
{
A<true> a;
std::cout << a.compute(true) << std::endl;
}