From 5566d8bae524389da58b1ba8c990fc96964fb811 Mon Sep 17 00:00:00 2001 From: Nana Sakisaka <1901813+saki7@users.noreply.github.com> Date: Fri, 20 Feb 2026 00:22:00 +0900 Subject: [PATCH] Fix `Cpp17Destructible` for pointer-to-class type MSVC 2026 workaround --- include/iris/requirements.hpp | 7 +++---- test/core.cpp | 12 ++++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/include/iris/requirements.hpp b/include/iris/requirements.hpp index 155d742..ad6bfd0 100644 --- a/include/iris/requirements.hpp +++ b/include/iris/requirements.hpp @@ -1,4 +1,4 @@ -#ifndef IRIS_REQUIREMENTS_HPP +#ifndef IRIS_REQUIREMENTS_HPP #define IRIS_REQUIREMENTS_HPP // SPDX-License-Identifier: MIT @@ -87,9 +87,8 @@ concept Cpp17CopyAssignable = Cpp17MoveAssignable && requires { // https://eel.is/c++draft/utility.requirements#tab:cpp17.destructible template -concept Cpp17Destructible = (!std::is_array_v) && std::is_object_v && requires(T u) { - { u.~T() }; -}; +concept Cpp17Destructible = std::is_object_v && !std::is_array_v && std::is_destructible_v; +// MSVC 2026 cannot compile `a.~T()` for pointer-to-class types (needs upstream bugfix) // https://eel.is/c++draft/swappable.requirements#5 template diff --git a/test/core.cpp b/test/core.cpp index 0f821ec..f7a7a64 100644 --- a/test/core.cpp +++ b/test/core.cpp @@ -323,6 +323,11 @@ TEST_CASE("Cpp17CopyAssignable") } } +template +concept Cpp17Destructible_expr = requires(T a) { + a.~T(); +}; + TEST_CASE("Cpp17Destructible") { STATIC_REQUIRE(iris::req::Cpp17Destructible); @@ -369,6 +374,13 @@ TEST_CASE("Cpp17Destructible") STATIC_REQUIRE(!std::destructible); STATIC_REQUIRE( std::destructible); } + { + // Pointer types *should* be destructible + STATIC_REQUIRE(iris::req::Cpp17Destructible); + + struct Class; + STATIC_REQUIRE(iris::req::Cpp17Destructible); + } } namespace {