copy.pass.cpp 967 B

12345678910111213141516171819202122232425262728293031323334353637
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is dual licensed under the MIT and the University of Illinois Open
  6. // Source Licenses. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // UNSUPPORTED: c++98, c++03
  10. // <functional>
  11. // template<CopyConstructible Fn, CopyConstructible... Types>
  12. // unspecified bind(Fn, Types...);
  13. // template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
  14. // unspecified bind(Fn, Types...);
  15. // http://llvm.org/bugs/show_bug.cgi?id=16385
  16. #include <functional>
  17. #include <cmath>
  18. #include <cassert>
  19. float _pow(float a, float b)
  20. {
  21. return std::pow(a, b);
  22. }
  23. int main()
  24. {
  25. std::function<float(float, float)> fnc = _pow;
  26. auto task = std::bind(fnc, 2.f, 4.f);
  27. auto task2(task);
  28. assert(task() == 16);
  29. assert(task2() == 16);
  30. }