From d2f891288ac2b3b4fd96bb0ddf829869513c5e4a Mon Sep 17 00:00:00 2001 From: Sumit Bhardwaj Date: Thu, 2 Jul 2020 23:36:10 -0700 Subject: Implement cm::static_reference_cast by declval Previously, cm::static_reference_cast used invoke_result_t and took the address of O::get. This is not in complete conformance with standard. This MR changes the implementation to use std::declval.get() which is always well-defined. --- Utilities/std/cmext/memory | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Utilities/std/cmext/memory b/Utilities/std/cmext/memory index 50e79df..fa326f0 100644 --- a/Utilities/std/cmext/memory +++ b/Utilities/std/cmext/memory @@ -12,18 +12,19 @@ namespace cm { -template >::value, - int> = 0> +template < + typename T, typename O, + cm::enable_if_t().get())>::value, + int> = 0> T& static_reference_cast(O& item) { return *(static_cast(item.get())); } -template >::value, - int> = 0> + +template < + typename T, typename O, + cm::enable_if_t().get())>::value, + int> = 0> T& dynamic_reference_cast(O& item) { auto p = dynamic_cast(item.get()); -- cgit v0.12