[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,52 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <text_encoding>
+
+// REQUIRES: std-at-least-c++26
+// REQUIRES: locale.en_US.UTF-8
+// UNSUPPORTED: no-localization
+// UNSUPPORTED: availability-te-environment-missing
+
+// class locale
+
+// text_encoding locale::encoding() const
+
+#include <cassert>
+#include <format>
+#include <iostream>
+#include <locale>
+#include <text_encoding>
+
+#include "platform_support.h"
+
+int main(int, char**) {
+ {
+ // 1. Locale built with en_US.UTF-8 returns text_encoding representing "UTF-8"
+ const std::locale utf8_locale(LOCALE_en_US_UTF_8);
+ std::text_encoding te = utf8_locale.encoding();
----------------
frederick-vs-ja wrote:
I think in this line it would make sense to use the `std::same_as<...> decltype(auto)` technique. (`<concepts>` should be included if use this.)
https://github.com/llvm/llvm-project/pull/141312
More information about the libcxx-commits
mailing list