[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:38:08 PST 2023


fsb4000 updated this revision to Diff 502622.
fsb4000 added a comment.

inline variables is a c++17 feature


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145376/new/

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
@@ -26,8 +26,10 @@
 _Tp __declval(long);
 _LIBCPP_SUPPRESS_DEPRECATED_POP
 
-template <class _Tp>
-decltype(std::__declval<_Tp>(0)) declval() _NOEXCEPT;
+template <class _Tp, bool _False = false>
+decltype(std::__declval<_Tp>(0)) declval() _NOEXCEPT {
+    static_assert(_False, "Calling declval is ill-formed, see [declval]/2.");
+}
 
 _LIBCPP_END_NAMESPACE_STD
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145376.502622.patch
Type: text/x-patch
Size: 553 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230306/3f02301b/attachment.bin>


More information about the libcxx-commits mailing list