Console Library 8.0.0
A header-only library that makes C++ simple
Loading...
Searching...
No Matches
fmt.h File Reference

轻量级格式化字符串头文件库。 More...

#include <cctype>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <stdexcept>
#include <string>
#include "../core/csexc.h"
#include "../io/output.h"

Go to the source code of this file.

Classes

struct  console::details::BasicFormatSpec< CharT >
 格式说明符结构。 More...

Namespaces

namespace  console
 本库所有组件所在的顶层命名空间。
namespace  console::details

Typedefs

using console::FormatSpec = details::BasicFormatSpec<char>
using console::WFormatSpec = details::BasicFormatSpec<wchar_t>

Functions

template<class CharT = char>
void console::details::parse_format_spec (const std::basic_string< CharT > &specStr, BasicFormatSpec< CharT > &spec)
 解析格式说明符。
template<class CharT = char>
void console::details::apply_format (std::basic_ostream< CharT > &os, const BasicFormatSpec< CharT > &spec)
 将格式说明符应用到输出流。
template<class CharT, class T>
static std::enable_if< std::is_arithmetic< T >::value, void >::type console::details::apply_space_if_nonneg (std::basic_ostream< CharT > &os, const T &value)
template<class CharT, class T>
static std::enable_if<!std::is_arithmetic< T >::value, void >::type console::details::apply_space_if_nonneg (std::basic_ostream< CharT > &, const T &)
template<typename CharT = char, typename T>
void console::details::format_value (std::basic_ostream< CharT > &os, const T &value, const BasicFormatSpec< CharT > &spec)
 格式化单个值。
template<class CharT = char>
void console::details::format_impl (std::basic_ostream< CharT > &os, const std::basic_string< CharT > &fmt, size_t &pos, size_t)
 格式化实现(无参数版本,递归终止)。
template<class CharT = char, typename T, typename... Args>
void console::details::format_impl (std::basic_ostream< CharT > &os, const std::basic_string< CharT > &fmt, size_t &pos, size_t argIndex, const T &first, const Args &...rest)
 格式化实现(有参数版本)。
template<typename... Args>
std::string console::format (const std::string &fmt, const Args &...args)
 格式化字符串(char 版)。
template<typename... Args>
std::wstring console::format (const std::wstring &fmt, const Args &...args)
 格式化字符串(wchar_t 版)。

Detailed Description

轻量级格式化字符串头文件库。

在没有std::format的情况下,使用<iomanip>提供轻量级的格式化字符串功能。

Author
MrXie1109
Date
2026