summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2020-12-06 18:48:17 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2020-12-06 18:48:17 +0000
commit6b10cb1067240fff229cf5febbe81c5e4c8cd7a5 (patch)
tree8db5bbe4905b362b9be38cf4c6721c891996e438
parentSimplified LazyPointer (diff)
downloadlibadhocutil-6b10cb1067240fff229cf5febbe81c5e4c8cd7a5.tar.bz2
libadhocutil-6b10cb1067240fff229cf5febbe81c5e4c8cd7a5.tar.xz
libadhocutil-6b10cb1067240fff229cf5febbe81c5e4c8cd7a5.zip
Put some C++20 in LazyPointer
-rw-r--r--libadhocutil/lazyPointer.h4
-rw-r--r--libadhocutil/unittests/Jamfile.jam12
2 files changed, 16 insertions, 0 deletions
diff --git a/libadhocutil/lazyPointer.h b/libadhocutil/lazyPointer.h
index 70fe61d..8b523d3 100644
--- a/libadhocutil/lazyPointer.h
+++ b/libadhocutil/lazyPointer.h
@@ -58,7 +58,11 @@ namespace AdHoc {
[[nodiscard]] T *
get() const
{
+#if __cpp_lib_to_address
+ return std::to_address(deref());
+#else
return &*deref();
+#endif
}
[[nodiscard]] const P &
diff --git a/libadhocutil/unittests/Jamfile.jam b/libadhocutil/unittests/Jamfile.jam
index f91579a..5ca476d 100644
--- a/libadhocutil/unittests/Jamfile.jam
+++ b/libadhocutil/unittests/Jamfile.jam
@@ -161,6 +161,18 @@ run
;
run
+ testLazyPointer.cpp
+ : : :
+ <define>BOOST_TEST_DYN_LINK
+ <library>..//adhocutil
+ <library>boost_utf
+ <cxxstd>17
+ -<cxxstd>20
+ :
+ testLazyPointer17
+ ;
+
+run
testNvpParse.cpp
: : :
<define>BOOST_TEST_DYN_LINK