[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,80 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=40000000
+// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-ops-limit): -fconstexpr-ops-limit=1000000000
+
+// <text_encoding>
+
+// text_encoding::text_encoding(string_view) noexcept
+
+#include <cassert>
+#include <concepts>
+#include <string_view>
+#include <text_encoding>
+#include <type_traits>
+
+#include "../test_text_encoding.h"
+
+constexpr void test_ctor(std::string_view str, std::text_encoding::id expect_id) {
+  std::same_as<std::text_encoding> decltype(auto) te = std::text_encoding(str);
+
+  assert(te.mib() == expect_id);
+  assert(te.name() == str);
+}
+
+constexpr bool test() {
+  { // The first encoding name for each mib in the data table.
----------------
frederick-vs-ja wrote:

Ditto here and below. `{}` is pointeless.

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


More information about the libcxx-commits mailing list