Boost logo

Boost Users :

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;
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net