[libcxx-commits] [libcxx] [libc++] Fix constexpr initialization of std::array<T, 0> (PR #74667)

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Sat Dec 9 04:19:45 PST 2023


================
@@ -280,7 +280,8 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>
     typedef std::reverse_iterator<iterator>       reverse_iterator;
     typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
 
-    typedef __conditional_t<is_const<_Tp>::value, const char, char> _CharType;
+    struct _EmptyAggregate { };
+    typedef __conditional_t<is_const<_Tp>::value, const _EmptyAggregate, _EmptyAggregate> _CharType;
----------------
mordante wrote:

```suggestion
    using _EmptyType = __maybe_const<_Tp>::value, _EmptyAggregate>;
```
// #include <__type_traits/maybe_const.h> is needed too
The name was not great before, but now it looks really weird since there is no connection with `char` at all.

https://github.com/llvm/llvm-project/pull/74667


More information about the libcxx-commits mailing list