1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// <functional>
10
11// template<class F>
12// function(F) -> function<see-below>;
13
14// UNSUPPORTED: c++03, c++11, c++14
15
16// The deduction guides for std::function do not handle rvalue-ref qualified
17// call operators and C-style variadics. It also doesn't deduce from nullptr_t.
18// Make sure we stick to the specification.
19
20#include <functional>
21
22struct R { };
23struct f0 { R operator()() && { return {}; } };
24struct f1 { R operator()(int, ...) { return {}; } };
25
26void f() {
27 std::function f = f0{}; // expected-error{{no viable constructor or deduction guide for deduction of template arguments of 'function'}}
28 std::function g = f1{}; // expected-error{{no viable constructor or deduction guide for deduction of template arguments of 'function'}}
29 std::function h = nullptr; // expected-error{{no viable constructor or deduction guide for deduction of template arguments of 'function'}}
30}
31

source code of libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/deduct_F.verify.cpp