pointer_to_unary_function.pass.cpp 707 B

1234567891011121314151617181920212223242526
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // <functional>
  10. // pointer_to_unary_function
  11. #include <functional>
  12. #include <type_traits>
  13. #include <cassert>
  14. double unary_f(int i) {return 0.5 - i;}
  15. int main()
  16. {
  17. typedef std::pointer_to_unary_function<int, double> F;
  18. static_assert((std::is_base_of<std::unary_function<int, double>, F>::value), "");
  19. const F f(unary_f);
  20. assert(f(36) == -35.5);
  21. }