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