[PATCH] D21459: Implement http://wg21.link/P0254R1: "Integrating std::string_view and std::string"

Marshall Clow via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 21 06:33:27 PDT 2016


mclow.lists added inline comments.

================
Comment at: include/string_view:216
@@ +215,3 @@
+	basic_string_view(const _CharT* __s)
+		: __data(__s), __size(_Traits::length(__s)) {}
+
----------------
kimgr wrote:
> I'm working from the paper at https://isocpp.org/files/papers/N3762.html, and I find it a little sketchy on the policy for nullptrs.
> 
> Since the ctor above accepts nullptr as long as the length is zero, would it make sense to do that here too? That is, only call _Traits::length for non-nullptr __s args?
Reading from N4600: Requires: `[str, str + traits::length(str))` is a valid range.

So, no - passing `nullptr` here is undefined.



https://reviews.llvm.org/D21459





More information about the cfe-commits mailing list