[libcxx-commits] [PATCH] D145376: [libc++] add declval failure assertion for instantiation
Igor Zhukov via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Mar 6 06:25:00 PST 2023
fsb4000 created this revision.
fsb4000 added reviewers: Mordante, philnik, libc++.
fsb4000 added a project: libc++.
Herald added a project: All.
fsb4000 requested review of this revision.
Herald added a subscriber: libcxx-commits.
Herald added 1 blocking reviewer(s): libc++.
Fixes https://github.com/llvm/llvm-project/issues/61202
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D145376
Files:
libcxx/include/__utility/declval.h
Index: libcxx/include/__utility/declval.h
===================================================================
--- libcxx/include/__utility/declval.h
+++ libcxx/include/__utility/declval.h
@@ -27,7 +27,12 @@
_LIBCPP_SUPPRESS_DEPRECATED_POP
template <class _Tp>
-decltype(std::__declval<_Tp>(0)) declval() _NOEXCEPT;
+inline constexpr bool __false = false;
+
+template <class _Tp>
+decltype(std::__declval<_Tp>(0)) declval() _NOEXCEPT {
+ static_assert(__false<_Tp>, "Calling declval is ill-formed, see [declval]/2.");
+}
_LIBCPP_END_NAMESPACE_STD
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145376.502616.patch
Type: text/x-patch
Size: 558 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230306/f9f1dfdd/attachment.bin>
More information about the libcxx-commits
mailing list