How to convert this into lambda expression
14 Mar
2007
14 Mar
'07
9:35 p.m.
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; }
6454
Age (days ago)
6454
Last active (days ago)
0 comments
1 participants
participants (1)
-
Peng Yu