Boost logo

Boost Users :

From: Scott Meyers (usenet_at_[hidden])
Date: 2006-03-10 17:04:07


Doug Gregor wrote:
> We can't overload dynamic_cast, which is too bad: that's the right
> name for this sort of thing. If only someone would go ahead and write
> the C++0x proposal to add overloading of the cast operators, smart
> pointers, any, variant, python::object, and many other classes would
> get much more intuitive syntax. But I digress...

FWIW, I'm told that the deadline for new language proposals is past, otherwise
I'd seriously consider writing up a proposal to add "raw" strings to C++ to make
experimenting with regex easier. But *I* digress...

> In an ideal world, I think we'd end up using "dynamic_cast" for
> everything. Instead, we use the name "get", and I think the
> "any_cast<T>(&a)" is probably a holdover from the dark days that we
> should change.

My only other knowledge of "get" is from tuple, where "get" takes a compile-time
constant, not a type, as an argument. With that background, I found the use of
"get" for variant initially confusing. I think it'd be better to find a name
with the "_cast" suffix and to explicitly specify pointer and reference types
(as with dynamic_cast) and adopt that convention. I don't know enough about the
various Boost libraries to know whether that is a reasonable suggestion.

Scott


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net