[libcxx-commits] [PATCH] D112665: [libc++] Ensure valid view for view_interface template parameter
Joe Loser via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Oct 28 11:19:35 PDT 2021
jloser updated this revision to Diff 383099.
jloser added a comment.
[NFC] Format the concept a bit nicer
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D112665/new/
https://reviews.llvm.org/D112665
Files:
libcxx/include/__ranges/view_interface.h
Index: libcxx/include/__ranges/view_interface.h
===================================================================
--- libcxx/include/__ranges/view_interface.h
+++ libcxx/include/__ranges/view_interface.h
@@ -38,16 +38,29 @@
template<class _Tp>
void __implicitly_convert_to(type_identity_t<_Tp>) noexcept;
+template<class _Derived>
+ requires is_class_v<_Derived> && same_as<_Derived, remove_cv_t<_Derived>>
+class view_interface;
+
+
+template<class _Tp>
+concept __valid_view_for_view_interface =
+ requires { sizeof(_Tp); } &&
+ derived_from<_Tp, view_interface<_Tp>> &&
+ view<_Tp>;
+
template<class _Derived>
requires is_class_v<_Derived> && same_as<_Derived, remove_cv_t<_Derived>>
class view_interface : public view_base {
_LIBCPP_HIDE_FROM_ABI
constexpr _Derived& __derived() noexcept {
+ static_assert(__valid_view_for_view_interface<_Derived>, "The derived type must model derived_from<view_interface<D>> and view");
return static_cast<_Derived&>(*this);
}
_LIBCPP_HIDE_FROM_ABI
constexpr _Derived const& __derived() const noexcept {
+ static_assert(__valid_view_for_view_interface<_Derived>, "The derived type must model derived_from<view_interface<D>> and view");
return static_cast<_Derived const&>(*this);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112665.383099.patch
Type: text/x-patch
Size: 1274 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211028/1fc356db/attachment.bin>
More information about the libcxx-commits
mailing list