Skip to content

Commit 732e02a

Browse files
author
Eduardo Madrid
committed
Subtlety regarding trivial copyable and move of UB type erasure
1 parent 645d24a commit 732e02a

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

test/AnyCallable.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
template<typename ErasureProvider>
66
struct CallableTests {
77
template<typename Signature>
8-
using ZFunction = zoo::function<Signature>;
8+
using ZFunction = zoo::AnyCallable<ErasureProvider, Signature>;
99

1010
inline static void execute();
1111
};
@@ -46,7 +46,7 @@ void CallableTests<ErasureProvider>::execute() {
4646
struct MovableCallable {
4747
bool moved_ = false;
4848
MovableCallable() = default;
49-
MovableCallable(const MovableCallable &) = default;
49+
MovableCallable(const MovableCallable &) {};
5050
MovableCallable(MovableCallable &&other) noexcept {
5151
other.moved_ = true;
5252
}
@@ -56,7 +56,7 @@ void CallableTests<ErasureProvider>::execute() {
5656
ac{MovableCallable{}},
5757
empty;
5858
SECTION("Move assignment") {
59-
auto &heldObject = *ac.state<MovableCallable>();
59+
auto &heldObject = *ac.template state<MovableCallable>();
6060
REQUIRE_FALSE(heldObject.moved_);
6161
empty = std::move(ac);
6262
CHECK(heldObject.moved_);
@@ -101,16 +101,16 @@ void CallableTests<ErasureProvider>::execute() {
101101
}
102102
SECTION("target() non-const") {
103103
ZFunction<long(int)> ac;
104-
CHECK(ac.target<int>() == nullptr);
105-
CHECK(ac.target<MyCallable>() == nullptr);
104+
CHECK(ac.template target<int>() == nullptr);
105+
CHECK(ac.template target<MyCallable>() == nullptr);
106106
ac = myCallable;
107-
CHECK(ac.target<int>() == nullptr);
108-
CHECK(ac.target<MyCallable>() != nullptr);
107+
CHECK(ac.template target<int>() == nullptr);
108+
CHECK(ac.template target<MyCallable>() != nullptr);
109109
}
110110
SECTION("target() const") {
111111
const ZFunction<long(int)> ac { myCallable };
112-
CHECK(ac.target<int>() == nullptr);
113-
CHECK(ac.target<MyCallable>() != nullptr);
112+
CHECK(ac.template target<int>() == nullptr);
113+
CHECK(ac.template target<MyCallable>() != nullptr);
114114
}
115115
SECTION("comparison to nullptr") {
116116
ZFunction<long(int)> acEmpty;

0 commit comments

Comments
 (0)