Boost logo

Boost :

From: Gary Powell (powellg_at_[hidden])
Date: 2002-03-18 12:52:35

Yet another example of complexity being useful (ie. control fns.)

I have a class which for reasons has to be this way, with a "type" id. I
want a clone of it. (Sorry no virtual fns allowed in the original objects.)

(Warning more uncompiled code)

using boost::lambda;

  transform(a.begin(), a.end(),
              case_statement<FIRST_TYPE>( new_ptr<Clone1stType>(*_1) ),
              case_statement<SECOND_TYPE>( new_ptr<Clone2ndType>(*_1) ),

That's not too bad to read and maintain. (Yes I know about the pitfalls of
adding a new type, but see the above comment about virtual.)

What I find, is that the utility that allows me to write an entire program
as one function and one file, doesn't prevent me from structuring my
programs into multiple subroutines and files. Same for Lambda functions. If
you find that the complexity is getting high. Make a subroutine!

Meantime for boost a rich set of utilities can make writing/reading code
much easier. (Note: I didn't say debugging and compiling)


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