[libcxx-commits] [PATCH] D121231: [libc++] Remove raw call to debug handler from __char_traits_length_checked
Arthur O'Dwyer via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Mar 10 06:55:32 PST 2022
Quuxplusone added inline comments.
================
Comment at: libcxx/include/string_view:244
+ // This needs to be a single statement for C++11 constexpr
+ return _LIBCPP_ASSERT(__s != nullptr, "null pointer passed to non-null argument of char_traits<...>::length"), _Traits::length(__s);
+}
----------------
EricWF wrote:
> If you use the ternary operator, you can make it a single statement without having to worry about custom char types that hijack ADL for operator,
>
> Which is why it was written out that way initially.
>
> Non built-in character types are allowed in string view, right?
I'm not thrilled by `return _LIBCPP_ASSERT...` either, but I do agree with Louis that I'd rather see `_LIBCPP_ASSERT` than the raw call to `__libcpp_debug_function`.
To fix the `operator,` issue, it's cheap and easy to replace the comma with `, void(), `; I think we should do that.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D121231/new/
https://reviews.llvm.org/D121231
More information about the libcxx-commits
mailing list