kokkos-execution 0.0.1
Loading...
Searching...
No Matches
matching_completion_signature.hpp
Go to the documentation of this file.
1// NOLINTBEGIN
2/*
3 * SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
4 * Copyright (c) 2026 Robert Leahy. All rights reserved.
5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 *
7 * Licensed under the Apache License, Version 2.0 with LLVM Exceptions (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * https://llvm.org/LICENSE.txt
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20#pragma once
21
22#include "stdexec/execution.hpp"
23
24#include <cstddef>
25#include <type_traits>
26
28
30
31template <typename>
33
34template <typename Tag, typename... Args>
35struct canonicalize<Tag(Args...)> {
36 using type = Tag(Args&&...);
37};
38
39template <typename Signature>
41
42template <typename Needle, typename Signature>
43inline constexpr bool is_canonical_match = std::is_same_v<canonicalize_t<Needle>, canonicalize_t<Signature>>;
44
45template <typename Needle, typename Signatures>
47
48template <typename Needle, typename... Signatures>
49struct canonical_match_count<Needle, ::STDEXEC::completion_signatures<Signatures...>>
50 : std::integral_constant<std::size_t, (is_canonical_match<Needle, Signatures> + ... + 0)> { };
51
52template <typename Needle, typename... Signatures>
54
55template <typename Needle>
56struct find_canonical_match<Needle> { };
57
58template <typename Needle, typename Signature, typename... Rest>
59struct find_canonical_match<Needle, Signature, Rest...>
60 : std::conditional_t<
61 is_canonical_match<Needle, Signature>,
62 std::type_identity<Signature>,
63 find_canonical_match<Needle, Rest...>
64 > { };
65
66template <
67 typename Signatures,
68 typename Signature,
70>
72
73template <typename Signature, typename... Signatures>
74struct matching_completion_signature<::STDEXEC::completion_signatures<Signatures...>, Signature, 1>
75 : find_canonical_match<Signature, Signatures...> { };
76
77} // namespace detail::matching_completion_signature
78
79template <typename Signatures, typename Tag, typename... Args>
81 typename detail::matching_completion_signature::matching_completion_signature<Signatures, Tag(Args...)>::type;
82
83template <typename Signatures, typename Tag, typename... Args>
84inline constexpr bool has_matching_completion_signature_v = requires {
85 typename matching_completion_signature_t<Signatures, Tag, Args...>;
86};
87
88template <typename Signatures, typename Tag, typename... Args>
90 using type = matching_completion_signature_t<Signatures, Tag, Args...>;
91};
92
93template <typename Signatures, typename Tag, typename... Args>
95 : std::bool_constant<has_matching_completion_signature_v<Signatures, Tag, Args...>> { };
96
97} // namespace experimental::execution
98
99// NOLINTEND
typename detail::matching_completion_signature::matching_completion_signature< Signatures, Tag(Args...)>::type matching_completion_signature_t
matching_completion_signature_t< Signatures, Tag, Args... > type