bind_front.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Demonstrates the use of std::bind_front from cxxomfort backports.
  3. * */
  4. #include <cxxomfort/base.hpp>
  5. #include <cxxomfort/functional.hpp>
  6. #include <cxxomfort/tuple.hpp>
  7. #include <cxxomfort/string.hpp>
  8. #include <cxxomfort/string_view.hpp>
  9. #include <iostream>
  10. #include <iomanip>
  11. #include <iomanip>
  12. #include <cxxomfort/library/type_name.hpp>
  13. #include <cxxomfort/ostream.hpp>
  14. #if (CXXOMFORT_CXX_STD >= 2011 || CXXO_COMPILERSUPPORT_typeof)
  15. #else
  16. #error "This test requires C++>=2011 or at least __typeof__ support."
  17. #endif
  18. using cxxomfort::library::type_name;
  19. struct expr_t {
  20. double operator() (double A, double B, double C) const {
  21. using namespace std;
  22. return A + B - C;
  23. }
  24. };
  25. int main () {
  26. using namespace std;
  27. using cxxomfort::cxxostd::bind_front;
  28. cxxomfort::output_info(stdout);
  29. cout<< endl;
  30. CXXO_AUTO(exprem , bind_front( expr_t(), 1.0, 33.0) );
  31. cout<< type_name< decltype(exprem)>()<< endl;
  32. for (double z= 20.0; z >= 5.0; z-=0.5) {
  33. cout<< exprem(z)<< " \t";
  34. }
  35. cout<< endl;
  36. //cout<< cadenita(string_view("Mundo"))<< endl;
  37. return 0;
  38. }