Skip to content

Commit 5e08d35

Browse files
committed
Fix Cpp17Destructible for pointer-to-class type
1 parent 4aa8142 commit 5e08d35

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

include/iris/requirements.hpp

Lines changed: 3 additions & 3 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,8 +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() };
90+
concept Cpp17Destructible = (!std::is_array_v<T>) && std::is_object_v<T> && requires(T a) {
91+
{ a.~T() };
9292
};
9393

9494
// https://eel.is/c++draft/swappable.requirements#5

test/core.cpp

Lines changed: 19 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,20 @@ TEST_CASE("Cpp17Destructible")
369374
STATIC_REQUIRE(!std::destructible<void>);
370375
STATIC_REQUIRE( std::destructible<int&>);
371376
}
377+
{
378+
struct Class;
379+
380+
{
381+
using T = Class*;
382+
T t;
383+
t.~T();
384+
}
385+
STATIC_REQUIRE(Cpp17Destructible_expr<Class*>);
386+
387+
// Pointer types *should* be destructible
388+
STATIC_REQUIRE(iris::req::Cpp17Destructible<int*>);
389+
STATIC_REQUIRE(iris::req::Cpp17Destructible<Class*>);
390+
}
372391
}
373392

374393
namespace {

0 commit comments

Comments
 (0)