Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions include/iris/requirements.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef IRIS_REQUIREMENTS_HPP
#ifndef IRIS_REQUIREMENTS_HPP
#define IRIS_REQUIREMENTS_HPP

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

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

// https://eel.is/c++draft/swappable.requirements#5
template<class X>
Expand Down
12 changes: 12 additions & 0 deletions test/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,11 @@ TEST_CASE("Cpp17CopyAssignable")
}
}

template<class T>
concept Cpp17Destructible_expr = requires(T a) {
a.~T();
};

TEST_CASE("Cpp17Destructible")
{
STATIC_REQUIRE(iris::req::Cpp17Destructible<int>);
Expand Down Expand Up @@ -369,6 +374,13 @@ TEST_CASE("Cpp17Destructible")
STATIC_REQUIRE(!std::destructible<void>);
STATIC_REQUIRE( std::destructible<int&>);
}
{
// Pointer types *should* be destructible
STATIC_REQUIRE(iris::req::Cpp17Destructible<int*>);

struct Class;
STATIC_REQUIRE(iris::req::Cpp17Destructible<Class*>);
}
}

namespace {
Expand Down