summaryrefslogtreecommitdiffstats
path: root/Utilities/std
diff options
context:
space:
mode:
authorSumit Bhardwaj <bhardwajs@outlook.com>2020-07-03 06:36:10 (GMT)
committerSumit Bhardwaj <bhardwajs@outlook.com>2020-07-04 18:03:46 (GMT)
commit782d7387d5ac0f965b2e61d6142f55ab2ce31411 (patch)
tree9dcd0c614bafc878f0a74d81aa2ab921062a308a /Utilities/std
parentbfa645c5992fa111b2ac90c5b7994c6aac8f7764 (diff)
downloadCMake-782d7387d5ac0f965b2e61d6142f55ab2ce31411.zip
CMake-782d7387d5ac0f965b2e61d6142f55ab2ce31411.tar.gz
CMake-782d7387d5ac0f965b2e61d6142f55ab2ce31411.tar.bz2
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<O>.get() which is always well-defined.
Diffstat (limited to 'Utilities/std')
-rw-r--r--Utilities/std/cmext/memory17
1 files 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 <typename T, typename O,
- cm::enable_if_t<
- std::is_pointer<cm::invoke_result_t<decltype(&O::get), O>>::value,
- int> = 0>
+template <
+ typename T, typename O,
+ cm::enable_if_t<std::is_pointer<decltype(std::declval<O>().get())>::value,
+ int> = 0>
T& static_reference_cast(O& item)
{
return *(static_cast<T*>(item.get()));
}
-template <typename T, typename O,
- cm::enable_if_t<
- std::is_pointer<cm::invoke_result_t<decltype(&O::get), O>>::value,
- int> = 0>
+
+template <
+ typename T, typename O,
+ cm::enable_if_t<std::is_pointer<decltype(std::declval<O>().get())>::value,
+ int> = 0>
T& dynamic_reference_cast(O& item)
{
auto p = dynamic_cast<T*>(item.get());