[PATCH] D26896: [libcxx] Make constexpr char_traits<T> and char_traits<char>

Anton Bikineev via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 24 05:10:05 PST 2016

AntonBikineev marked 2 inline comments as done.
AntonBikineev added inline comments.

Comment at: include/__config:925
+#if !__has_builtin(__builtin_memcpy)
EricWF wrote:
> What about GCC? Surely it implements some if not most of these.
Thanks, good point. I've done it in the same way as it is done for __buitin_addressof. On the other hand, gcc has an option -fno-builtin to disable them. That way it *won't* compile. I try to stick to the current solution though.

Comment at: include/__string:213
-    static inline int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
-        {return __n == 0 ? 0 : memcmp(__s1, __s2, __n);}
-    static inline size_t length(const char_type* __s)  _NOEXCEPT {return strlen(__s);}
-    static inline const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
-        {return __n == 0 ? NULL : (const char_type*) memchr(__s, to_int_type(__a), __n);}
+    static inline constexpr int
EricWF wrote:
> wow. This is #ifdef hell. Please find a way to do it with less (or hopefully no) conditional compilation blocks.
yep, this is generic hell. I want to cover as many cases as possible, i.e. combinations of (is_constexpr x has_builtin_xxx) for every function. I'm open to suggestions


More information about the cfe-commits mailing list