From 17726406ec255a32ac0f519fade4acd5061ac39a Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Sun, 12 Apr 2026 16:53:39 -0700 Subject: [PATCH 1/2] change `__common_domain_t` to always check for convertibility to `default_domain` --- include/stdexec/__detail/__domain.hpp | 21 +++++++-- test/CMakeLists.txt | 1 + test/stdexec/detail/test_common_domain.cpp | 50 ++++++++++++++++++++++ 3 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 test/stdexec/detail/test_common_domain.cpp diff --git a/include/stdexec/__detail/__domain.hpp b/include/stdexec/__detail/__domain.hpp index 627822aa0..26ecaf6e9 100644 --- a/include/stdexec/__detail/__domain.hpp +++ b/include/stdexec/__detail/__domain.hpp @@ -151,10 +151,23 @@ namespace STDEXEC // Common domain for a set of domains template - struct __common_domain + constexpr auto __common_domain_fn() noexcept { - using __t = __minvoke<__mtry_catch_q>, _Domains...>; - }; + if constexpr (__minvocable_q) + { + return std::common_type_t<_Domains...>{}; + } + // NOT TO SPEC: If each domain in Domains... is convertible to default_domain, then + // the common domain is default_domain. + else if constexpr (__minvocable_q) + { + return std::common_type_t{}; + } + else + { + return __make_domain_t<_Domains...>{}; + } + } } // namespace __detail //////////////////////////////////////////////////////////////////////////////////////////////// @@ -169,7 +182,7 @@ namespace STDEXEC using __completion_domain_of_t = __completion_domain_t<_Tag, env_of_t<_Sender>, _Env const &...>; template - using __common_domain_t = __t<__detail::__common_domain<_Domains...>>; + using __common_domain_t = decltype(__detail::__common_domain_fn<_Domains...>()); template concept __has_common_domain = diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3a072d151..bd5999d22 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -70,6 +70,7 @@ set(stdexec_test_sources stdexec/algos/consumers/test_sync_wait.cpp stdexec/algos/consumers/test_spawn.cpp stdexec/detail/test_any.cpp + stdexec/detail/test_common_domain.cpp stdexec/detail/test_completion_signatures.cpp stdexec/detail/test_demangle.cpp stdexec/detail/test_utility.cpp diff --git a/test/stdexec/detail/test_common_domain.cpp b/test/stdexec/detail/test_common_domain.cpp new file mode 100644 index 000000000..01aa125d4 --- /dev/null +++ b/test/stdexec/detail/test_common_domain.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Lucian Radu Teodorescu + * + * Licensed under the Apache License Version 2.0 with LLVM Exceptions + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * https://llvm.org/LICENSE.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include + +namespace ex = STDEXEC; + +namespace +{ + struct gpu_domain + {}; + + struct thread_pool_domain : ex::default_domain + {}; + + struct parallel_runtime_domain : ex::default_domain + {}; + + template + using common_domain_t = ex::__common_domain_t; + + TEST_CASE("finding common domains", "[detail][domain]") + { + using common1 = common_domain_t; + STATIC_REQUIRE(std::same_as); + + using common2 = common_domain_t; + STATIC_REQUIRE(std::same_as); + + using common3 = common_domain_t; + STATIC_REQUIRE(std::same_as>); + } + +} // namespace From 9d0addf0fcb116a45773e382a7ea5fa211d6e901 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Sun, 12 Apr 2026 17:24:39 -0700 Subject: [PATCH 2/2] tparam order in `indeterminate_domain` doesn't matter --- examples/CMakeLists.txt | 4 +++- test/CMakeLists.txt | 1 + test/stdexec/detail/test_common_domain.cpp | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 832caa4fd..f48c7636a 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -29,7 +29,9 @@ function(def_example example) split(${example} target source) add_executable(${target} ${source}) target_compile_options(${target} PUBLIC - $<$:-Wno-maybe-uninitialized>) # warnings being emitted from stdlib headers, why? + $<$:-Wno-maybe-uninitialized> # warnings being emitted from stdlib headers, why? + $<$:-Wno-gnu-line-marker> + ) target_link_libraries(${target} PRIVATE STDEXEC::stdexec stdexec_executable_flags diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bd5999d22..6256522ed 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -100,6 +100,7 @@ target_compile_definitions(common_test_settings INTERFACE target_compile_options(common_test_settings INTERFACE $<$:/wd4714> # function marked as __forceinline not inlined $<$:-Wno-maybe-uninitialized> # warnings being emitted from stdlib headers, why? + $<$:-Wno-gnu-line-marker> ) target_link_libraries(common_test_settings INTERFACE $) # target_compile_definitions( diff --git a/test/stdexec/detail/test_common_domain.cpp b/test/stdexec/detail/test_common_domain.cpp index 01aa125d4..b40da2b88 100644 --- a/test/stdexec/detail/test_common_domain.cpp +++ b/test/stdexec/detail/test_common_domain.cpp @@ -44,7 +44,8 @@ namespace STATIC_REQUIRE(std::same_as); using common3 = common_domain_t; - STATIC_REQUIRE(std::same_as>); + STATIC_REQUIRE( + std::same_as> + || std::same_as>); } - } // namespace