问题标签 [fastformat]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c++ - Is there a 'catch' with FastFormat?
I just read about the FastFormat C++ i/o formatting library, and it seems too good to be true: Faster even than printf, typesafe, and with what I consider a pleasing interface:
This looks almost too good to be true. Is there a catch? Have you had good, bad or indifferent experiences with it?
c++ - Windows FormatMessage 的安全/灵活外观
我需要为一个项目使用FormatMessage(),但我不喜欢它可怕的界面。有谁知道一个外观可以整理它,同时仍然允许替换参数?
我刚刚阅读了FastFormat 介绍的第二部分,并且正在考虑为FormatMessage()编写一个扩展(或者询问FastFormat项目团队是否有一个在工作中),但我很想尽快得到一些东西,所以如果那里还有其他像样的东西,我可能会抓住它。
我想要的是能够编写代码,例如:
这将给出结果:
我构建的当前包装器具有接口:
这有两个问题:
- 它不是类型安全的,因为很容易传递任何类型 -
int
,std::string
,void*
-const char*
- 参数的数量很容易与表示错误的格式字符串所需的数量不匹配
鉴于FastFormat在类型安全方面的能力,我想知道是否有办法遵循其处理FormatMessage()的机制。
c++ - 如何在接受无限数量参数的函数中保证类型安全?
FastFormat库的工作方式如下:
它还声称“100% 类型安全”。我可以理解其他库是如何boost::format
通过重载来实现的operator%
,这也是我经常用我的代码做的事情。
但是,如果我能够使用逗号代替,其他程序员就不会那么惊讶了。我真的很想知道如何在没有模板化运算符重载技巧的情况下保证类型安全。
旁注:如果您想知道“模板化运算符重载技巧”是什么,这就是 boost::format 的工作原理(主要):
c++ - Do C++ formatting libraries generally fall back to *sprintf for numeric formatting?
I am wondering whether "all" C++ formatting libraries eventually fall back to a *sprintf
function to format numbers.
I am asking this because:
- Looking at the iostreams library that comes with Visual C++, I can see that numbers input into a stream will eventuall be formatted with
sprintf_s
. - Boost.Format just uses the available iostreams library as far as I can tell.
- FastFormat eventually uses
vsprintf
to format a number.
So, are there iostreams implementations that do not use *sprintf and do the formatting themselves? Are there other formatting libraries that do not forward formatting of numbers to *sprintf family of functions?
I would appreciate answers in the form of:
- No: implementation XY uses ABC to format numbers
- Yes: all other (e.g. iostreams) implementations I know (X, Y, Z) also forward number formatting to stdio, because ...
Please avoid overly speculative answers.
c++ - 如何使用 FastFormat 格式化带逗号的数字?
如何使用FastFormat库格式化带有千位分隔符的逗号数字?
例如,
c++ - OS X 上的快速格式化
在阅读了一些关于 FastFormat 的信息后,我决定将它下载并安装在运行 OS X 10.8 的 Macbook Pro 上。我成功构建了 FastFormat,并运行了性能测试。然后我写了一个小测试来检查它是否有效:
使用 g++-4.7 编译它(并确保所有包含路径都正确)后,我从 PlatformSTL 得到了编译时错误,如下面的错误。
我试图通过定义unix
和PLATFORMSTL_OS_IS_UNIX
手动来抑制这些错误,但随后我收到了这些链接器错误:
OS X 是否支持 FastFormat,如果支持,我做错了什么?