diff --git a/include/function2/function2.hpp b/include/function2/function2.hpp index 542c72ba..376afc65 100644 --- a/include/function2/function2.hpp +++ b/include/function2/function2.hpp @@ -339,7 +339,8 @@ template struct address_taker { template static void* take(O&& obj) { - return std::addressof(obj); + const void *ret = std::addressof(obj); + return const_cast(ret); } static T& restore(void* ptr) { return *static_cast(ptr); diff --git a/test/regressions.cpp b/test/regressions.cpp index 101fb0c1..54ef428c 100644 --- a/test/regressions.cpp +++ b/test/regressions.cpp @@ -191,13 +191,13 @@ TEST(regression_tests, unique_non_copyable) { } // https://github.com/Naios/function2/issues/21 -/*TEST(regression_tests, can_bind_const_view) { +TEST(regression_tests, can_bind_const_view) { auto const callable = [] { return 5; }; fu2::function_view view(callable); ASSERT_EQ(view(), 5); -}*/ +} // https://github.com/Naios/function2/issues/48 // -Waddress warning generated for non-capturing lambdas on gcc <= 9.2 #48