[libcxx-commits] [PATCH] D141321: [libc++] Add [[clang::lifetimebound]] attribute to std::forward and friends

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jan 10 12:12:21 PST 2023


Mordante added a comment.

I like this idea. I think it would be useful for "views" like `string_view` and `span` too.



================
Comment at: libcxx/include/__config:1056
+#  if __has_cpp_attribute(_Clang::__lifetimebound__)
+#    define _LIBCPP_LIFETIMEBOUND [[_Clang::__lifetimebound__]]
+#  else
----------------
Why not `[[clang::lifetimebound]]` ?


================
Comment at: libcxx/include/__utility/forward_like.h:37
 template <class _Tp, class _Up>
-[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto forward_like(_Up&& __ux) noexcept -> _ForwardLike<_Tp, _Up> {
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto forward_like(_LIBCPP_LIFETIMEBOUND _Up&& __ux) noexcept
+    -> _ForwardLike<_Tp, _Up> {
----------------
Should this extension be documented, like we do with `[[nodiscard]]`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141321



More information about the libcxx-commits mailing list