Boost logo

Boost :

From: Itay Maman (itay_maman_at_[hidden])
Date: 2002-07-27 02:17:30

"Geoff Leyland" <geoff.leyland_at_[hidden]> wrote in message
> Hi,
> I'm new to Boost, so please excuse me if I bring up any stuff that's
> been dealt with ages ago: I've been reading the list for a while, but
> not forever, and it's a *lot* of volume. There's a few questions I'd
> like to ask, and things to propose. I've only got the released Boost
> 1.28, so if things have changed a lot since then, please excuse me again.
> 1) I've got some very crude classes for something I call "run-time
> structures" (naming things isn't my strong point). These are for
> handling, well, structures that get created at run time - like one has
> in MATLAB or Python or so on. If x is one I can go:
> x("a.b") = 2.0;
> x("a.c.d") = "hello";
> if (x("a.c.d").isa<string>())
> std::cout << x("a.c.d").be<string>();

Consider this code:

   map<string, any> x;
   x["a.b"] = 2.0;
   x["a.c.d"] = "hello";

   if(string* p = any_cast<string>(&(x["a.c.d"]))
       cout << *p;

Isn't it semantically equivalent to your code?

You can also 'port' this code to variants, provided that you know which
types will be assigned to x. The variant-based code supplies a much more
flexible way for retrieving the stored values (currently carried out by

I would be interested to hear of possible applications of generic containers
(any/variant). Anyway, I think that the functionality you need, is already
offered by either boost::any or the (under construction) variant library.


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