flatten 20260225
This commit is contained in:
21
tjp/core/string/sxprintf.h
Executable file
21
tjp/core/string/sxprintf.h
Executable file
@@ -0,0 +1,21 @@
|
||||
// License: Modified MIT (NON-AI)
|
||||
// See the LICENSE file in the root directory for license information.
|
||||
// Copyright 2025 Timothy Prepscius
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdio>
|
||||
#include <type_traits>
|
||||
|
||||
namespace tjp::core {
|
||||
|
||||
template<typename T, typename ... Args>
|
||||
void sxprintf(T &t, const char *format, Args &&... args)
|
||||
{
|
||||
static_assert(std::is_array<T>::value, "T must be an array");
|
||||
static_assert(std::is_same<typename std::remove_all_extents<T>::type, char>::value, "T must be an array of char");
|
||||
|
||||
snprintf(t, std::size(t), format, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
Reference in New Issue
Block a user