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

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Dec 5 09:02:06 PST 2023


================
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+// 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
+
+// <format>
+
+// template<class... Args>
+//   format-arg-store<format_context, Args...>
+//   make_format_args(const Args&... args);
+
+#include <format>
+
+// expected-error@*:* {{no matching function for call to 'make_format_args'}}
+[[maybe_unused]] auto store = std::make_format_args(42);
----------------
ldionne wrote:

This should be a SFINAE test instead. You could actually put this in the `.pass.cpp` test for `make_format_args` and do:

```
template <class ...Args>
concept can_make_format_args = requires (Args&& ...args) {
  std::make_format_args(std::forward<Args>(args)...);
};

static_assert(can_make_format_args<int&>); // test the test
static_assert(!can_make_format_args<int>);
static_assert(!can_make_format_args<int&&>);
```

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


More information about the libcxx-commits mailing list