Boost logo

Boost :

Subject: Re: [boost] request for comments in a new format library
From: Roberto Hinz (robhz786_at_[hidden])
Date: 2018-02-28 15:02:34

On Wed, Feb 28, 2018 at 5:04 AM, Frédéric <ufospoke_at_[hidden]> wrote:

> Hi,
> Why did you choose this syntax:
> strf::write_to(output) [assembly_string] = {name, age};
> and not
> strf::write_to(output, assembly_string, {name, age});

​because of that optional functions like .with(facets)
, .reserve(size), etc (and I will possibly add some others )
Although I could be possible (maybe) to specify everything as
arguments of a single function call like this:

      ( output
      , strf::no_reserve()
      , strf::make_ftuple(facets)
      , assembly_string
      , {args...}

that would require a function overload for each possible combination.
That would complicate me, and would especially complicate
the user when he/she extends the library to a new output type.

In the way it is now, the user only needs to write one simple function:

  // see section "How to add support to a new destination type"
  auto write_to(user_own_output_type& output)
     return boost::stringify::make_args_handler
         < user_own_output_type_writer
         , user_own_output_type&
         ( output );

So, the user only needs to provide what I named as a new
"leading expression". He/she doesn't need to implement all the
optional syntax variations, since this is already provided
by the return of boost::stringify::make_args_handler.

However, I don't see any problem of:

  write_to(ouput) /*optional funcs here*/ (assembly_string, {args});

And actually I thinks it looks better, though I find the syntax with
={args} easier to ident when breaking it into multiple lines.

But it is also possible to provide both option,
so that the user can choose which one he/she prefers.​
​I think I'll do that!

> or
> strf::write_to(output, assembly_string, name, age);

​The arguments have to go into an std::initializer_list.
Variadic template would make it impossible to pass some special
input types ( like joins ). Though I think it could be possible to use
"Fixed sized parameter packs"

​But I think unfortunately this will never became ​part of c++.


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