[libcxx-commits] [libcxx] [llvm] [libc++] Implement P1885R12: `<text_encoding>` (PR #141312)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jun 3 20:58:37 PDT 2026


================
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: std-at-least-c++26
+
+// <text_encoding>
+
+// bool text_encoding::operator==(const text_encoding&, id) noexcept
+
+#include <cassert>
+#include <text_encoding>
+
+#include "test_macros.h"
+#include "../test_text_encoding.h"
+
+using id = std::text_encoding::id;
+
+constexpr void test_primary_encodings() {
+  for (auto& data : unique_encoding_data) {
+    std::text_encoding te = std::text_encoding(id(data.mib));
+    assert(te == id(data.mib));
+  }
+}
+
+constexpr bool test() {
+  // operator==(const text_encoding&, id) must be noexcept and returns bool
+  {
+    std::text_encoding te = std::text_encoding();
----------------
frederick-vs-ja wrote:

No change requested for the `{}` as there's a local variable. But as mentioned before, the style of initialization should be simplified.
```suggestion
  {
    std::text_encoding te{};
```

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


More information about the libcxx-commits mailing list