Boost logo

Boost :

Subject: Re: [boost] request for comments in a new format library
From: Roberto Hinz (robhz786_at_[hidden])
Date: 2018-02-23 07:14:59

On Thu, Feb 22, 2018 at 9:49 PM, Gavin Lambert via Boost <
boost_at_[hidden]> wrote:

> On 22/02/2018 03:24, Roberto Hinz wrote:
>> some time ago I announced a format library I'm working on. I think at that
>> time it was still too incipient for one to evaluate whether it looked
>> promising, thought some few but very useful observation were made ( one
>> regarding i18n and other code bloat ) that made me change many things.
> Do you assume that "char" is UTF-8 or is it encoding-agnostic? I
> suspect the former given use of char32_t elsewhere. While this might be
> typical on Posix it is not universal, and on Windows it is rarely the case.

​by default it is utf-8,​ but this is customizable through facets. However
if one wants another
encoding, one needs to implement ones own encoder and decoder as explained

> = vs. &= to denote exception throwing or not seems a bit opaque. Have
> you considered overloads taking nothrow_t or error_code& instead?

​Perhaps we could do something like:
     auto s = make_string .error_code("blah blah {} blah {}") = {arg1,

> g/the_assembly_string.html :
> {/ as an escape is highly peculiar. \{ or {{ would be more typical.

I'm against \{ because ​using an escape character before the '{' instead of
would force the parser to be less efficient. And also because the user
would actually need to type "\\{".

My only reluctance against {{ is that it may wrongly suggest that there
must be an
enclosing }}, especially to users coming from fmtlib, since this is how is
done there.
And I really don't want to require an enclosing }}, because the user may
want to
print a { without an enclosing }.

 Let's see what others think about.

> "destinated" => "intended"
> "octadecimal" != "octal". The latter is correct.

​I really appreciate ​these little advices. thanks. Being a non-native
English speaker,
I'm aways afraid of making some linguistic gaffe.

By the way, is it better "format library" or "fomatting library" ?
"format functions" or "formatting functions" ?

> Also, while I've never particularly been a fan of the STL formatting
> facets, it does bother me a bit that you're trying to reinvent the wheel
> here.

I can't avoid this. The std facets just don't combine well with this

Facets of boost.stringify are designed to be used with the ftuple class
while the facets from std are designed to be used with std::locate. And we
use std::locale here, because we need​ a really fast getter, since it is
called several
times for each input argument.
( get_facet of ftuple is very fast, while std::use_facet is not ).

( Btw, I thinking about renaming the ftuple class template.
  Perhaps facets_pack or facets_bundle ).

Another reason is that each facet category is designed to work well
specifically in
this library. Using for instance std::codecvt instead of the decode and
encode facets
would be too cumbersome and inefficient. It is too oriented toward std

There is also some design philosophy differences. For example, note that
facet is based in char32_t, so that the same facet object works for
different encodings.
he std::numpunct on the other hand is a class template parametrized to

And anyway, creating a format library is already reinventing wheel.
I also needed to reinvent the formatting functions ( hex, oct, right, left,
etc ).

> definition, you should try to avoid having these break ABI in different
> compilation units -- have it select in the headers which of two unique
> implementations in different namespaces is used, such that both can coexist
> in different translation units without conflict. The compiled library, if
> there is one, would always provide both.
​I need to think about that. I will come to an answer later.

I can see you really spent some time reading the documentations
And I much appreciate your effort. Thanks and best regards.


Boost list run by bdawes at, gregod at, cpdaniel at, john at