[libcxx-commits] [libcxx] [libc++] Implements Runtime format strings II. (PR #72543)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Nov 21 10:48:21 PST 2023


================
@@ -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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// <format>
+
+// template<class charT> struct runtime-format-string {  // exposition-only
+// private:
+//   basic_string_view<charT> str;  // exposition-only
+//
+// public:
+//   runtime-format-string(basic_string_view<charT> s) noexcept : str(s) {}
+//
+//   runtime-format-string(const runtime-format-string&) = delete;
+//   runtime-format-string& operator=(const runtime-format-string&) = delete;
+// };
+// runtime-format-string<char> runtime_format(string_view fmt) noexcept;
+// runtime-format-string<wchar_t> runtime_format(wstring_view fmt) noexcept;
+
+#include <format>
+
+#include <cassert>
+#include <concepts>
+#include <string_view>
+#include <type_traits>
+
+#include "test_macros.h"
+
+template <class T, class CharT>
+static void test_properties() {
+  static_assert(std::is_nothrow_convertible_v<std::basic_string_view<CharT>, T>);
+  static_assert(std::is_nothrow_constructible_v<T, std::basic_string_view<CharT>>);
+
+  static_assert(!std::copy_constructible<T>);
+  static_assert(!std::is_copy_assignable_v<T>);
+
+  static_assert(!std::move_constructible<T>);
+  static_assert(!std::is_move_assignable_v<T>);
+}
+
+int main(int, char**) {
----------------
ldionne wrote:

Here's let's introduce `using RuntimeFormatString = decltype(...);`.

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


More information about the libcxx-commits mailing list