Boost logo

Boost :

Subject: Re: [boost] [review][assign] Formal review of Assign v2 ongoing
From: Simonson, Lucanus J (lucanus.j.simonson_at_[hidden])
Date: 2011-06-20 13:36:10

er wrote:
> PS:
> - csv_deque<p_, I>( a1,...aI, ..., z1,...,zI ) is same as
> deque<p_>( a1, ..., aI)...(z1, ..., zI)
> - deque's nearest equivalent in Boost.Assign ( 1.0 ) is list_of
> - do_csv_put<>() is C++0x only as of current revision
> Any questions?

I use initializer lists in another language, but not yet in the new C++.

In C++0x can we use initializer lists to populate a container with syntax like:
  std::list<string> My_list;
  My_list = {"a", "b", "c"};

For some reason the code examples for this library remind me of ruby, in that when I first saw ruby code it was completely unreadable. I'm not sure the pipe, dot and comma usage is really intuitive, nor csv. I'm pretty good at guessing TLA meanings, but csv meant nothing to me until I saw "comma seperated values" somewhere in the tutorial or something. "csv_" might as well be "_", it would be shorter and just as intuitive. "put" is at least intuitive. I think "values" would be more intuitive than csv and if it were me I'd probably name csv<2> "value_pairs", but then I don't mind typing. Typing time should not correlate to productivity. Longer names don't increase code complexity. It isn't clear to me that the library syntax reduces code complexity.

It is too bad we can't emulate initializer lists in C++03 as a template library with some macro wrapper.

 struct S { int a; string b; };
 S s;

 that gives same meaning as
 s = {1, "2"};

I don't think we can get the order or names of data members at compile time because we have no introspection language features.

I very much like initializer list syntax, but the syntax for this library doesn't give me any warm feelings. Perhaps we need motivating examples and a little bit of rationale for *why* such a library should exist. Does it make doing something much easier in a templated context or is it just a quest to type less when using standard containers in code that looks like the examples? I ordinarily only initialize containers to literals when writing unit tests.


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