From 2c457c42758f1aeb5e2ec15f89b9702586328220 Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Wed, 26 Mar 2025 18:54:49 +0100 Subject: Add address_of --- asl/types/BUILD.bazel | 1 + asl/types/function_ref.hpp | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'asl/types') diff --git a/asl/types/BUILD.bazel b/asl/types/BUILD.bazel index 198d0a2..53905a3 100644 --- a/asl/types/BUILD.bazel +++ b/asl/types/BUILD.bazel @@ -97,6 +97,7 @@ cc_library( ], deps = [ "//asl/base", + "//asl/memory", ], visibility = ["//visibility:public"], ) diff --git a/asl/types/function_ref.hpp b/asl/types/function_ref.hpp index 8daa5bd..8d874f1 100644 --- a/asl/types/function_ref.hpp +++ b/asl/types/function_ref.hpp @@ -7,6 +7,7 @@ #include "asl/base/utility.hpp" #include "asl/base/meta.hpp" #include "asl/base/functional.hpp" +#include "asl/memory/memory.hpp" namespace asl { @@ -43,7 +44,7 @@ public: && same_as, R> ) // NOLINTNEXTLINE(*cast*) - : m_obj{const_cast(reinterpret_cast(&t))} + : m_obj{const_cast(reinterpret_cast(address_of(t)))} , m_invoke{invoke>} {} @@ -56,7 +57,7 @@ public: ) { // NOLINTNEXTLINE(*cast*) - m_obj = const_cast(reinterpret_cast(&t)); + m_obj = const_cast(reinterpret_cast(address_of(t))); m_invoke = invoke>; return *this; -- cgit