196dbdd75SChristopher Di Bella //===----------------------------------------------------------------------===//
296dbdd75SChristopher Di Bella //
396dbdd75SChristopher Di Bella // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
496dbdd75SChristopher Di Bella // See https://llvm.org/LICENSE.txt for license information.
596dbdd75SChristopher Di Bella // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
696dbdd75SChristopher Di Bella //
796dbdd75SChristopher Di Bella //===----------------------------------------------------------------------===//
896dbdd75SChristopher Di Bella
996dbdd75SChristopher Di Bella // UNSUPPORTED: c++03, c++11, c++14, c++17
1096dbdd75SChristopher Di Bella
1196dbdd75SChristopher Di Bella // template<class F, class... Args>
1296dbdd75SChristopher Di Bella // concept predicate;
1396dbdd75SChristopher Di Bella
1496dbdd75SChristopher Di Bella #include <concepts>
15*3d2d3b3eSArthur O'Dwyer #include <type_traits>
1696dbdd75SChristopher Di Bella
1796dbdd75SChristopher Di Bella static_assert(std::predicate<bool()>);
1896dbdd75SChristopher Di Bella static_assert(std::predicate<bool (*)()>);
1996dbdd75SChristopher Di Bella static_assert(std::predicate<bool (&)()>);
2096dbdd75SChristopher Di Bella
2196dbdd75SChristopher Di Bella static_assert(!std::predicate<void()>);
2296dbdd75SChristopher Di Bella static_assert(!std::predicate<void (*)()>);
2396dbdd75SChristopher Di Bella static_assert(!std::predicate<void (&)()>);
2496dbdd75SChristopher Di Bella
2596dbdd75SChristopher Di Bella struct S {};
2696dbdd75SChristopher Di Bella
2796dbdd75SChristopher Di Bella static_assert(!std::predicate<S(int), int>);
2896dbdd75SChristopher Di Bella static_assert(!std::predicate<S(double), double>);
2996dbdd75SChristopher Di Bella static_assert(std::predicate<int S::*, S*>);
3096dbdd75SChristopher Di Bella static_assert(std::predicate<int (S::*)(), S*>);
3196dbdd75SChristopher Di Bella static_assert(std::predicate<int (S::*)(), S&>);
3296dbdd75SChristopher Di Bella static_assert(!std::predicate<void (S::*)(), S*>);
3396dbdd75SChristopher Di Bella static_assert(!std::predicate<void (S::*)(), S&>);
3496dbdd75SChristopher Di Bella
3596dbdd75SChristopher Di Bella static_assert(!std::predicate<bool(S)>);
3696dbdd75SChristopher Di Bella static_assert(!std::predicate<bool(S&), S>);
3796dbdd75SChristopher Di Bella static_assert(!std::predicate<bool(S&), S const&>);
3896dbdd75SChristopher Di Bella static_assert(std::predicate<bool(S&), S&>);
3996dbdd75SChristopher Di Bella
4096dbdd75SChristopher Di Bella struct Predicate {
4196dbdd75SChristopher Di Bella bool operator()(int, double, char);
4296dbdd75SChristopher Di Bella };
4396dbdd75SChristopher Di Bella static_assert(std::predicate<Predicate, int, double, char>);
4496dbdd75SChristopher Di Bella static_assert(std::predicate<Predicate&, int, double, char>);
4596dbdd75SChristopher Di Bella static_assert(!std::predicate<const Predicate, int, double, char>);
4696dbdd75SChristopher Di Bella static_assert(!std::predicate<const Predicate&, int, double, char>);
4796dbdd75SChristopher Di Bella
check_lambda(auto)4888b73a98SLouis Dionne constexpr bool check_lambda(auto) { return false; }
4996dbdd75SChristopher Di Bella
check_lambda(std::predicate auto)5088b73a98SLouis Dionne constexpr bool check_lambda(std::predicate auto) { return true; }
5196dbdd75SChristopher Di Bella
__anon8cbae8960102null5296dbdd75SChristopher Di Bella static_assert(check_lambda([] { return std::true_type(); }));
__anon8cbae8960202() 5396dbdd75SChristopher Di Bella static_assert(check_lambda([]() -> int* { return nullptr; }));
5496dbdd75SChristopher Di Bella
5596dbdd75SChristopher Di Bella struct boolean {
5696dbdd75SChristopher Di Bella operator bool() const noexcept;
5796dbdd75SChristopher Di Bella };
__anon8cbae8960302null5896dbdd75SChristopher Di Bella static_assert(check_lambda([] { return boolean(); }));
5996dbdd75SChristopher Di Bella
6096dbdd75SChristopher Di Bella struct explicit_bool {
6196dbdd75SChristopher Di Bella explicit operator bool() const noexcept;
6296dbdd75SChristopher Di Bella };
__anon8cbae8960402null6396dbdd75SChristopher Di Bella static_assert(!check_lambda([] { return explicit_bool(); }));
64