| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
9年前发布

C++ 格式化库:cppformat

cppformat (C++ Format) 是一个既轻便、安全,又快捷的开源 C++ 格式化库。它可以用来取代 IOStreams ,同时也是格式输出中较为安全的替代品。

特性

  • Two APIs: faster concatenation-based write API and slower (but still very fast) replacement-based format API with positional arguments for localization.
  • Write API similar to the one used by IOStreams but stateless allowing faster implementation.
  • Format API with format string syntax similar to the one used by str.format in Python.
  • Safe printf implementation including the POSIX extension for positional arguments.
  • Support for user-defined types.
  • High speed: performance of the format API is close to that of glibc's printf and better than performance of IOStreams. See Speed tests and Fast integer to string conversion in C++.
  • Small code size both in terms of source code (format consists of a single header file and a single source file) and compiled code. See Compile time and code bloat.
  • Reliability: the library has an extensive set of unit tests.
  • Safety: the library is fully type safe, errors in format strings are reported using exceptions, automatic memory management prevents buffer overflow errors.
  • Ease of use: small self-contained code base, no external dependencies, permissive BSD license.
  • Portability with consistent output across platforms and support for older compilers.
  • Clean warning-free codebase even on high warning levels (-Wall -Wextra -pedantic).
  • Support for wide strings.
  • Optional header-only configuration enabled with theFMT_HEADER_ONLYmacro.

示例

This prints Hello, world! to stdout:

fmt::print("Hello, {}!", "world");  // uses Python-like format string syntax  fmt::printf("Hello, %s!", "world"); // uses printf format string syntax

项目主页:http://www.open-open.com/lib/view/home/1426683233164

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1426683233164.html
cppformat C/C++开发