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// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
10
11// checks that CTAD for std::function works properly with static operator() overloads
12
13#include <functional>
14#include <type_traits>
15
16struct Except0 {
17 static void operator()() {}
18};
19static_assert(std::is_same_v<decltype(std::function{Except0{}}), std::function<void()>>);
20
21struct Except1 {
22 static int operator()(int&) { return 0; }
23};
24static_assert(std::is_same_v<decltype(std::function{Except1{}}), std::function<int(int&)>>);
25
26struct Except2 {
27 static int operator()(int*, long*) { return 0; }
28};
29static_assert(std::is_same_v<decltype(std::function{Except2{}}), std::function<int(int*, long*)>>);
30
31struct ExceptD {
32 static int operator()(int*, long* = nullptr) { return 0; }
33};
34static_assert(std::is_same_v<decltype(std::function{ExceptD{}}), std::function<int(int*, long*)>>);
35
36struct Noexcept {
37 static int operator()(int*, long*) noexcept { return 0; }
38};
39
40static_assert(std::is_same_v<decltype(std::function{Noexcept{}}), std::function<int(int*, long*)>>);
41

source code of libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/ctad.static.compile.pass.cpp