[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
Wed Oct 27 15:00:24 PDT 2021
jloser updated this revision to Diff 382807.
jloser added a comment.
Rename helper concept to be less generic in its identifier
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.382807.patch
Type: text/x-patch
Size: 1269 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211027/539ebc95/attachment-0001.bin>
More information about the libcxx-commits
mailing list