Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2002-11-19 07:19:53


Peter Dimov wrote:
> I wrote "I don't understand how it works even _after_ (briefly)
> looking at the code. ;-)" but then it occured to me that list(int, char,
> long, int) is a function type.

Yep.

> Cool trick. Cv qualifiers will probably be a problem

They are stripped on non-class rvalues, aren't they? :(. So, basically, this
one will work:

    typedef eval<
          count_if(
              list(int,char,long,her const)
            , lambda(is_same(_,her const))
            )
>::type res;

    BOOST_STATIC_ASSERT(res::value == 1);

but this one won't:

    typedef eval<
          count_if(
              list(int,char,long,int const)
            , lambda(is_same(_,int const))
            )
>::type res;

    BOOST_STATIC_ASSERT(res::value == 1); // error, res::value == 2

It's an issue to solve indeed - thanks for reminding the rule.

> but it's cool. Aleksey wins the Boost obfuscated C++ contest of the week.

I am not completely sure if it's a compliment, but thanks :).

Aleksey

P.S. It just occured to me that with the above we finally have a way to
write two nested template instantiations without a space between their
closing brackets:
  
   typedef one<another<int> > == typedef eval< one(another(int)) >::type

That one would really make a good obfuscated contest's task :).


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk