|
Boost : |
From: Peder Holt (peder.holt_at_[hidden])
Date: 2007-05-24 15:23:32
2007/5/24, Giovanni Piero Deretta <gpderetta_at_[hidden]>:
> On 5/24/07, Peder Holt <peder.holt_at_[hidden]> wrote:
> > 2007/5/24, Minmin Gong <gongminmin_at_[hidden]>:
> > [...]
> > On GCC we use the native typeof mechanism, so your code is actually
> > translated into this:
> >
> > int main() {
> > std::vector<int> v;
> > typedef typeof(boost::type_of::ensure_obj(v))::type type;
> > }
> >
> > The simpler:
> > typedef typeof(v)::type type;
> >
> > fails to compile as well, so this is a shortcomming in the compiler.
>
> Well, vector has no 'type' type. Anyways, It fail)s for 'iterator' too:
>
Sorry. That was a copy and paste error in the mail. My test code used
a simpler struct in place of std::vector with a typedef int type;
> std::vector<int> v;
> typedef typeof(int)::iterator type;
>
> > Unfortunately there is little we can do to fix this in Boost.Typeof.
>
> This works though (at least with gcc 4.1.2):
>
> #include <vector>
>
> template<typename T>
> struct identity {
> typedef T type;
> };
>
> int main() {
> std::vector<int> v;
> typedef identity<typeof(v)>::type::iterator type;
> }
>
> So BOOST_TYPEOF could include 'identity' in its expansion.
>
> It might fail with more complex expression as I heard that gcc doesn't
> like much typeof in template parameters (but never tested it).
>
> gpd
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk