aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-03-05 15:04:59 +0100
committerGitHub <noreply@github.com>2023-03-05 15:04:59 +0100
commitcbdce1cc7d96f4eced79a8d4a50b71fa1dcd831e (patch)
treeba8bc7609b7e6e833c1702d4a8cd6b000be48b18
parented1f9bddeec215a51d08c821fcb4265887dcdfbb (diff)
parent72a7ea5cae8b38e502787671538ac419225876b0 (diff)
Merge pull request #26297 from vespa-engine/toregge/include-memory-to-get-declaration-of-std-addressofv8.133.49
Include memory to get declaration of std::addressof.
-rw-r--r--vespalib/src/tests/ref_counted/ref_counted_test.cpp18
-rw-r--r--vespalib/src/vespa/vespalib/util/ref_counted.h1
2 files changed, 17 insertions, 2 deletions
diff --git a/vespalib/src/tests/ref_counted/ref_counted_test.cpp b/vespalib/src/tests/ref_counted/ref_counted_test.cpp
index 046823a9ebc..d831e664374 100644
--- a/vespalib/src/tests/ref_counted/ref_counted_test.cpp
+++ b/vespalib/src/tests/ref_counted/ref_counted_test.cpp
@@ -34,6 +34,20 @@ struct Leaf : Base {
std::atomic<int> Leaf::ctor_cnt = 0;
std::atomic<int> Leaf::dtor_cnt = 0;
+void copy_assign_ref_counted_leaf_real(ref_counted<Leaf>& lhs, const ref_counted<Leaf> &rhs)
+{
+ lhs = rhs;
+}
+
+void (*copy_assign_ref_counted_leaf)(ref_counted<Leaf>& lhs, const ref_counted<Leaf> &rhs) = copy_assign_ref_counted_leaf_real;
+
+void move_assign_ref_counted_leaf_real(ref_counted<Leaf>& lhs, ref_counted<Leaf>&& rhs)
+{
+ lhs = std::move(rhs);
+}
+
+void (*move_assign_ref_counted_leaf)(ref_counted<Leaf>& lhs, ref_counted<Leaf>&& rhs) = move_assign_ref_counted_leaf_real;
+
// check that the expected number of objects have been created and
// destroyed while this object was in scope.
struct CheckObjects {
@@ -197,8 +211,8 @@ TEST(RefCountedTest, compile_errors_when_uncommented) {
TEST(RefCountedTest, self_assign) {
ref_counted<Leaf> ref = make_ref_counted<Leaf>(10);
- ref = ref;
- ref = std::move(ref);
+ copy_assign_ref_counted_leaf(ref, ref);
+ move_assign_ref_counted_leaf(ref, std::move(ref));
EXPECT_EQ(ref->count_refs(), 1);
EXPECT_EQ(ref->val, 10);
}
diff --git a/vespalib/src/vespa/vespalib/util/ref_counted.h b/vespalib/src/vespa/vespalib/util/ref_counted.h
index ab0e1c82044..0b75cc51d7a 100644
--- a/vespalib/src/vespa/vespalib/util/ref_counted.h
+++ b/vespalib/src/vespa/vespalib/util/ref_counted.h
@@ -4,6 +4,7 @@
#include <atomic>
#include <concepts>
+#include <memory>
#include <utility>
// This file contains code that implements intrusive reference