deduct_F.fail.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  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. // <functional>
  10. // template<class F>
  11. // function(F) -> function<see-below>;
  12. // UNSUPPORTED: c++98, c++03, c++11, c++14
  13. // UNSUPPORTED: libcpp-no-deduction-guides
  14. // The deduction guides for std::function do not handle rvalue-ref qualified
  15. // call operators and C-style variadics. It also doesn't deduce from nullptr_t.
  16. // Make sure we stick to the specification.
  17. #include <functional>
  18. #include <type_traits>
  19. struct R { };
  20. struct f0 { R operator()() && { return {}; } };
  21. struct f1 { R operator()(int, ...) { return {}; } };
  22. int main() {
  23. std::function f = f0{}; // expected-error{{no viable constructor or deduction guide for deduction of template arguments of 'function'}}
  24. std::function g = f1{}; // expected-error{{no viable constructor or deduction guide for deduction of template arguments of 'function'}}
  25. std::function h = nullptr; // expected-error{{no viable constructor or deduction guide for deduction of template arguments of 'function'}}
  26. }