[libc-commits] [libc] [libc] Template the writing mode for the writer class (PR #111559)
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Tue Mar 11 11:30:49 PDT 2025
================
@@ -21,12 +21,23 @@
namespace LIBC_NAMESPACE_DECL {
namespace printf_core {
-struct WriteBuffer {
- enum class WriteMode {
- FILL_BUFF_AND_DROP_OVERFLOW,
- FLUSH_TO_STREAM,
- RESIZE_AND_FILL_BUFF,
- };
+enum class WriteMode {
+ FILL_BUFF_AND_DROP_OVERFLOW,
+ FLUSH_TO_STREAM,
+ RESIZE_AND_FILL_BUFF,
+};
+
+// Helper to omit the template argument if we are using runtime dispatch and
+// avoid multiple copies of the converter functions.
+template <WriteMode write_mode> struct Mode {
+#ifdef LIBC_COPT_PRINTF_RUNTIME_DISPATCH
+ static constexpr WriteMode value = WriteMode::FILL_BUFF_AND_DROP_OVERFLOW;
+#else
+ static constexpr WriteMode value = write_mode;
+#endif
+};
----------------
jhuber6 wrote:
done
https://github.com/llvm/llvm-project/pull/111559
More information about the libc-commits
mailing list