fork(1) download
  1. #include <iostream>
  2. class Foo
  3. {
  4. int result;
  5.  
  6. public:
  7. Foo() : result(0) {}
  8. Foo(bool value) : result(value ? 1 : 0) {}
  9. explicit Foo(int value) : result(value) {}
  10. Foo operator+(bool value) const
  11. {
  12. std::cout << "adding " << value << std::endl;
  13. return Foo((result << 1) | (value ? 1 : 0));
  14. }
  15. int get_result() const { return result; }
  16. };
  17.  
  18. int main()
  19. {
  20. Foo x;
  21. x = Foo(true) + false + true;
  22. std::cout << x.get_result() << std::endl;
  23. }
Success #stdin #stdout 0s 2852KB
stdin
Standard input is empty
stdout
adding 0
adding 1
5