xref: /llvm-project/libcxx/test/std/thread/thread.stoptoken/stopcallback/ctad.compile.pass.cpp (revision 121ed5c1985356436d0040dbe81bca26992b1fae)
1*b77e50e6SHui //===----------------------------------------------------------------------===//
2*b77e50e6SHui //
3*b77e50e6SHui // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*b77e50e6SHui // See https://llvm.org/LICENSE.txt for license information.
5*b77e50e6SHui // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*b77e50e6SHui //
7*b77e50e6SHui //===----------------------------------------------------------------------===//
8*b77e50e6SHui //
9*b77e50e6SHui // UNSUPPORTED: no-threads
10*b77e50e6SHui // UNSUPPORTED: c++03, c++11, c++14, c++17
11*b77e50e6SHui // XFAIL: availability-synchronization_library-missing
12*b77e50e6SHui 
13*b77e50e6SHui //   template<class Callback>
14*b77e50e6SHui //   stop_callback(stop_token, Callback) -> stop_callback<Callback>;
15*b77e50e6SHui 
16*b77e50e6SHui #include <stop_token>
17*b77e50e6SHui #include <type_traits>
18*b77e50e6SHui #include <utility>
19*b77e50e6SHui 
20*b77e50e6SHui void test() {
21*b77e50e6SHui   std::stop_token st;
22*b77e50e6SHui   auto a = [] {};
23*b77e50e6SHui   static_assert(std::is_same_v<decltype(std::stop_callback(st, a)), std::stop_callback<decltype(a)>>);
24*b77e50e6SHui   static_assert(std::is_same_v<decltype(std::stop_callback(st, std::as_const(a))), std::stop_callback<decltype(a)>>);
25*b77e50e6SHui   static_assert(std::is_same_v<decltype(std::stop_callback(st, std::move(a))), std::stop_callback<decltype(a)>>);
26*b77e50e6SHui   static_assert(
27*b77e50e6SHui       std::is_same_v<decltype(std::stop_callback(st, std::move(std::as_const(a)))), std::stop_callback<decltype(a)>>);
28*b77e50e6SHui }
29