From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2004-04-19 21:02:42
A couple of questions regarding typeof:
1) Is it going to be in the next C++ standard?
2) Is there any estimate when it is going to happen?
I assume that quite a few Boost libraries could largely benefit from this
operator. Spirit documentation even contains a section on typeof and how
the syntax could be improved with it. I recently had a need to determine a
type of a Lambda functor (but got away with Boost.Function with some
performance expences). Also Joaquin recently raised a similar question.
Our RTL syntax would also benefit a lot if this facility was available.
About one and a half year ago Steve Dewhurst published three articles on
this subject in CUJ. The idea was to encode the type as an integer using
bitwise operations. This integer could be than "returned" from the
function, this crossing the boundaries between a type and a value, and then
decoded into the original type.
I wonder if this or any other technique is currently being considered by
anyone to be added to Boost or we are just waiting until the real typeof is
I have been experimenting with this, and came up with a very simple trick
that allows to use a static list of integers, like mpl::vector_c, instead of
bitwise operations, to encode the type, and pass this list across the
function boundaries. I think, if nothing else, this is much simpler than
bitwise operations. Everything else is pretty much like in Steve's
approach. Based on this it seems to be pretty simple to encode/decode types
to implement typeof-like facilities for some specific (or maybe not so
Has anybody already done something similar, and/or is this of any interest?
If there is an interest I am ready to provide explanation, code, etc.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk