Skip to content

Commit 7eee48e

Browse files
authored
Merge pull request #38 from iris-cpp/fix-destructible
Fix `Cpp17Destructible` for pointer-to-class type
2 parents 4aa8142 + 5566d8b commit 7eee48e

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

include/iris/requirements.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#ifndef IRIS_REQUIREMENTS_HPP
1+
#ifndef IRIS_REQUIREMENTS_HPP
22
#define IRIS_REQUIREMENTS_HPP
33

44
// SPDX-License-Identifier: MIT
@@ -87,9 +87,8 @@ concept Cpp17CopyAssignable = Cpp17MoveAssignable<T> && requires {
8787

8888
// https://eel.is/c++draft/utility.requirements#tab:cpp17.destructible
8989
template<class T>
90-
concept Cpp17Destructible = (!std::is_array_v<T>) && std::is_object_v<T> && requires(T u) {
91-
{ u.~T() };
92-
};
90+
concept Cpp17Destructible = std::is_object_v<T> && !std::is_array_v<T> && std::is_destructible_v<T>;
91+
// MSVC 2026 cannot compile `a.~T()` for pointer-to-class types (needs upstream bugfix)
9392

9493
// https://eel.is/c++draft/swappable.requirements#5
9594
template<class X>

test/core.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,11 @@ TEST_CASE("Cpp17CopyAssignable")
323323
}
324324
}
325325

326+
template<class T>
327+
concept Cpp17Destructible_expr = requires(T a) {
328+
a.~T();
329+
};
330+
326331
TEST_CASE("Cpp17Destructible")
327332
{
328333
STATIC_REQUIRE(iris::req::Cpp17Destructible<int>);
@@ -369,6 +374,13 @@ TEST_CASE("Cpp17Destructible")
369374
STATIC_REQUIRE(!std::destructible<void>);
370375
STATIC_REQUIRE( std::destructible<int&>);
371376
}
377+
{
378+
// Pointer types *should* be destructible
379+
STATIC_REQUIRE(iris::req::Cpp17Destructible<int*>);
380+
381+
struct Class;
382+
STATIC_REQUIRE(iris::req::Cpp17Destructible<Class*>);
383+
}
372384
}
373385

374386
namespace {

0 commit comments

Comments
 (0)