fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <functional>
  4.  
  5. int main()
  6. {
  7. bool foo = false;
  8. auto b = std::bind2nd(foo ? std::function<bool(int,int)>(std::greater<int>()) : std::function<bool(int,int)>(std::equal_to<int>()), 2);
  9. std::cout << b(4) << std::endl; // true, 4 > 2
  10. }
  11.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
0