Boost logo

Boost :

Subject: Re: [boost] Assign V2 - first impression
From: Christian Holmquist (c.holmquist_at_[hidden])
Date: 2011-06-22 18:00:32


>
>
> Additional features include:
>>
>>> Options for overriding default semantics, and macros to create custom
>>> options
>>>
>>> What are the default semantics?
>>
>
> Please do a search for semantics in the tutorial:
>
>
>
I continued with the tutorial, but it didn't help me much in the
understanding how V2 would make my life easier.

V2's first example:

>
> typedef std::string word_;
> const char x[] = "foo";
> const char y[4] = { 'b', 'a', 'r', '\0' };
> word_ z = "***baz";
> std::map<int, word_> map;
> put( map )( 1, x, 3 )( 2, y )( 3, z, 3, 3 )( 4, "qux" );

If I was given the above code and had to figure out the contents of map, I
would fail to do so.
What's the benefit of the library to construct the container's value_type,
instead of explicitly by the user?

This reads easier to me
map[1] = std::string(x, 3);
map[2] = y;
map[3] = std::string(z, 3, 3);
map[4] = "qux";

I would not sacrifice clarity for compactness.

The following next example is also IMO convoluted, I've read it multiple
times but I don't understand what it attempts to do.

std::vector<int> numeric( 10 ); iota( numeric, 0 );
> typedef std::string str_; typedef variant< int, str_ > data_;
> array<data_, 17> keypad;
> csv(
> put( keypad ),
> "+", "-", "*", "/", "=", ".", "c"
> ).for_each( numeric );

Can you provide both the standard way of populating the keypad structure, so
it can be more easily compared to the way V2 suggests it should be done.
Reading the assert macros, I guess this is equivalent?

array<variant<int, std::string>, 17> keypad =
{
"+", "-", "*", "/", "=", ".", "c",
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
};

- Christian


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk