Boost logo

Boost :

From: John Torjo (john.lists_at_[hidden])
Date: 2003-08-05 12:52:41


>
> #include <iostream>
>
>
> using namespace std;
>
>
> namespace infinite
> {
>
>
> template <typename T = void, typename U = void>
> struct typelist : U
> {
> typedef T type;
>
> T value;
>
> typelist(T const & a, U const & b) : value(a), U(b) {}
> };
>
> template <>
> struct typelist<void, void>
> {
> typedef void type;
> };
>
> template <typename T>
> struct typelist<T, void>
> {
> typedef T type;
>
> T value;
>
> typelist(T const & a) : value(a) {}
> };
>
>
> typelist<> const begin = typelist<>();
>
>
> }
>
>
> template <typename V>
> infinite::typelist<V, void> operator , (infinite::typelist<> const &, V
> const & v)
> {
> return infinite::typelist<V, void>(v);
> }
>
> template <typename T, typename U, typename V>
> infinite::typelist< V, infinite::typelist<T, U> > operator ,
> (infinite::typelist<T, U> const & t, V const & v)
> {
> return infinite::typelist< V, infinite::typelist<T, U> >(v,
> infinite::typelist<T, U>(t));
> }
>
>
> // Usage example:
>
> template <typename T, typename U>
> void foo(infinite::typelist<T, U> const & i)
> {
> cout << __PRETTY_FUNCTION__ << endl;
> }
>
> int main()
> {
> foo((infinite::begin, true, (char *) "adasd", 12367, 127.2));
> }
I have not compiled it, but looks ok.
Anyway, why the two (( and )) ?

I think it's not needed.

Anyway, I'm not sure how much this generality can buy you.
I do like it, though :)

By the way, Andrei Alexandrescu had an article (about 4-5 years ago) about
inline containers. Look it up.

Best,
John

>
>
>
> My 0,02$
>
> Philippe
>
>
>
> _______________________________________________
> 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