/Src/Dependencies/Boost/libs/function/example/int_div.cpp

http://hadesmem.googlecode.com/ · C++ · 26 lines · 13 code · 7 blank · 6 comment · 0 complexity · f5b25cd00592156e5f12dd4cb19152f3 MD5 · raw file

  1. // Boost.Function library examples
  2. // Copyright Douglas Gregor 2001-2003. Use, modification and
  3. // distribution is subject to the Boost Software License, Version
  4. // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. // For more information, see http://www.boost.org
  7. #include <iostream>
  8. #include <boost/function.hpp>
  9. struct int_div {
  10. float operator()(int x, int y) const { return ((float)x)/y; };
  11. };
  12. int
  13. main()
  14. {
  15. boost::function<float (int, int)> f;
  16. f = int_div();
  17. std::cout << f(5, 3) << std::endl; // 1.66667
  18. return 0;
  19. }