Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2002-10-08 14:56:26

----- Original Message -----
From: "Yitzhak Sapir" <yitzhaks_at_[hidden]>

> Even as far as the STL you don't seem to support it properly. The
> main thing that seems to me to be unsupported are pairs (example, list of
> pairs). But I'm sure you could have, with a little more thought to
> details. Anyhow, my interface has a uniform syntax (even if you don't
> like it).
> It would also be worthwhile for you to make your interface compile with
> Visual C++ 6 (and probably other compilers). For example, the policies
> classes are partially specialized, and VC 6.5 and others don't accept
> partially specialized classes. In your case, I think you could use
> function template overloading to provide a solution to this. (Also take
> note of the point list example later on).
year, that's a real pain. People with experience in this area are welcome
with their
support. I fear that this could really produce some irritating compiler
error messages
when something goes wrong. Anyway, a little example would be appreciated...

> > [thor]
> > at first speed wasn't an issue. but my test (see other mail) that there
> > no overhead in my approach.
> > I don't think it is unthinkable that a loop could contain
> >
> > set_cont( v ) += x,y,z;
> I either think that they'd be better as a list of explicit push_back()s,
> or that a std::copy(block.begin(), block.end(), std::back_inserter(v));
> would be better.

> > [thor]
> > not understood. Have you run a test?
> I can't. I use VC 6.5.
> > If you think about missing a single
> > value, the solution is easy. put a flag in the Map_comma_initializer
> > that is set false in operator,(); set the flag to true in
> > Map_data_initialiser
> > and the the destructor of Mapcomma_initializer test the flag. If you're
> > referrring
> Huh? You're expecting a beginner to understand this?
yep, the error message will simply be "missing data item in initialization
of map".
I thought that was what you meant.

> I mean the user
> will have a problem if he does something like (contrived so you know what
> the values are supposed to be):
> std::map<int, int> prime_to_odd; // the nth odd for the nth prime
> set_cont(prime_to_square) += 2, 1, 3, 3, 5, 5, 7, 11, 9, 13, 11;
> There's a value missing, but he'd have to carefully work through the list
> to find out which value is missing.
and a compile time solution would catch this? Enlighten me.

> > to a compile time error, then maybe the compile time list is better.
> > However,
> > its more complicated usage would be much worse than waiting for a
> > initilization error.
> Compile time errors are always preferable. But very simply, I can't
> compile your code because it uses template specialization that is not
> supported by my compiler.

That depends. If the error msg is 1000 lines of STL unreadable, a runtime
might be considered ok. It is a tradeof.

> How about assigner(), a function that returns an assigner object
> to its parameter?
good candidate.

> > bad name because this is "fraud"
> >
> > initialize( v ) = 1,2,3,4.
> >
> > since ot will remove whatever v held before that statement. It's realy
> > assignment.
> > , not initializing something.
> So call your library an "assignment" library. It's not any more "fraud."
> I used initializer() because that was the name of the library. Assigner
> would work just as well.

Perhaps. Initialization has more meanings than the C++ specific.

> > [thor]
> > I don't agree. With your syntax above it's not clear what is the key and
> > what is data. Production code
> > would be
> >
> > set_map(addresses) = address("Washington St.", 30), "Johnson";
> It's not clear with your syntax, because the user gives a comma delimited
> list, that delimits both the keys and the data by commas. Instead of
> using this example, about about a list of pairs.
> typedef std::pair<int, int> point;
> std::list<point> point_list;
> set_cont(point_list) += ....
> Would this work?

Unfortunately, it will work both as

set_cont( point_list ) += 3,3,4,5,6,67;


set_cont( point_list ) += point( 3,2 ), point( 3,4 );

The last syntax is much preferred. I didn't know until know that one can do

typedef std::pair<int, int> point, P;

but it makes the stuff shorter:

set_cont( point_list ) += P( 3,2 ), P( 3,4 );

> I really don't think my format is that complex to understand (especially
> with proper documentation), and neither that expensive for use. Your
> format is nice for its use of the comma operator. I'm not against it, but
> I asked why not also, and then realized it wasn't that hard to implement
> (at least what I did yesterday wasn't that hard).
and I appreciate your advices. If I can see some small examples of the
template overloading you talked about, I might do something in the weekend
so the vc6 people can enjoy it.



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