[RISC-V] Avoid unnecessary sign extension after memcmp
[official-gcc.git] / libstdc++-v3 / testsuite / 20_util / function / cons / deduction_c++23.cc
blob8c70c1029296dc721d228b9c2d1f4c871a5b5927
1 // { dg-do compile { target c++23 } }
2 // { dg-require-effective-target hosted }
4 #include <functional>
6 template<typename T, typename U> struct require_same;
7 template<typename T> struct require_same<T, T> { using type = void; };
9 template<typename T, typename U>
10 typename require_same<T, U>::type
11 check_type(U&) { }
13 void
14 test_static_call_operator()
16 struct F1 { static long operator()() { return 0; } };
17 std::function func1 = F1{};
18 check_type<std::function<long()>>(func1);
20 struct F2 { static float operator()(char, void*) noexcept { return 0; } };
21 std::function func2 = F2{};
22 check_type<std::function<float(char, void*)>>(func2);
25 void
26 test_explicit_object_call_operator()
28 // LWG 3617 - function/packaged_task deduction guides and deducing this
29 struct F {
30 int operator()(this const F&) { return 42; }
33 std::function g = F{};
34 check_type<std::function<int()>>(g);
36 struct F2 {
37 short operator()(this F2&, float&) { return 0; }
40 std::function g2 = F2{};
41 check_type<std::function<short(float&)>>(g2);
43 struct F3 {
44 void operator()(this const F3, char*, long) { }
47 std::function g3 = F3{};
48 check_type<std::function<void(char*, long)>>(g3);
50 struct F4 {
51 int i;
52 operator const int&() const { return i; }
53 const long& operator()(this int, const long& l) { return l; }
56 std::function g4 = F4{};
57 check_type<std::function<const long&(const long&)>>(g4);