[PATCH] D55308: Implement the second part of P0482 (char8_t)

Marshall Clow via Phabricator reviews at reviews.llvm.org
Mon Dec 10 15:34:03 PST 2018


mclow.lists marked an inline comment as done.
mclow.lists added inline comments.


================
Comment at: include/string:4173
 
+#if _LIBCPP_STD_VER > 17 && defined(__cpp_char8_t)
+typedef basic_string<char8_t> u8string;
----------------
ldionne wrote:
> mclow.lists wrote:
> > ldionne wrote:
> > > I hate feature test macros already. This should just be `#if _LIBCPP_STD_VER > 17`... Can't we take the slightly more aggressive stance of "if you're trying to use libc++ as a c++20 library but your compiler does not support c++20, you're out of luck"?
> > > I hate feature test macros already.
> > Agreed.
> > 
> > > Can't we take the slightly more aggressive stance of "if you're trying to use libc++ as a c++20 library but your compiler does not support c++20, you're out of luck"
> > 
> > We can't do that, because (for example) LLVM 7.0 claims to support C++20, but doesn't support `char8_t`.
> > 
> > In general, I agree with you, but this feature (`char8_t`) requires a compiler feature, or it doesn't work.
> > We can't do that, because (for example) LLVM 7.0 claims to support C++20, but doesn't support char8_t.
> 
> Isn't that claim wrong, then? Also, surely you can't claim you implement C++20 at this point since it hasn't been voted?
> 
> I'm not trying to be rhetorical -- I'd _really_ like to avoid having to guard everything with a feature test macro because that will make the library much more complex and I'm sure it will introduce some tricky bugs. Just supporting many compilers and many C++ Standard versions is already difficult -- supporting partial implementations of a standard scares me a lot.
I agree; we don't want to do that; and, in general, we won't need to do so.

BUT, in this case, we need a particular bit of functionality from the compiler, and the way to see if the compiler has implemented it is via a feature-test macro.  In other places, we use `__has_builtin` or other ways of querying the compiler. This is the first place (that I know of) that we're using a feature-test macro to do so.



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

https://reviews.llvm.org/D55308





More information about the libcxx-commits mailing list