calc2b.cpp 649 B

123456789101112131415161718192021222324252627
  1. // Copyright (C) 2016-2018 T. Zachary Laine
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See
  4. // accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. //[ calc2b
  7. #include <boost/yap/expression.hpp>
  8. #include <iostream>
  9. int main ()
  10. {
  11. using namespace boost::yap::literals;
  12. // Displays "5"
  13. std::cout << make_expression_function(1_p + 2.0)(3.0) << std::endl;
  14. // Displays "6"
  15. std::cout << make_expression_function(1_p * 2_p)(3.0, 2.0) << std::endl;
  16. // Displays "0.5"
  17. std::cout << make_expression_function((1_p - 2_p) / 2_p)(3.0, 2.0) << std::endl;
  18. return 0;
  19. }
  20. //]