Boost logo

Boost Users :

Subject: Re: [Boost-users] [Proto] Building a mpl::vector from an expression
From: christophe henry (henry_christophe_at_[hidden])
Date: 2009-08-20 10:33:06


Eric Niebler wrote:

> #include
> #include
> #include
> #include
> #include
> #include
> namespace proto = boost::proto;
> namespace mpl = boost::mpl;
> using proto::_;
>
> namespace My
> {
> struct my_tag {};
>
> template
> struct attribute_
> {
> BOOST_PROTO_BASIC_EXTENDS(
> proto::terminal::type
> , attribute_
> , proto::default_domain
> )
> };
>
> attribute_<> const attribute = {{}};
>
> struct BuildAttributes
> : proto::make<
> mpl::pop_front<
> proto::fold_tree<
> _
> , mpl::vector0<>()
> , mpl::push_back()
> >
> >
> >
> {};
> }
>
> int main()
> {
> mpl::vector3 x =
> My::BuildAttributes()(
> My::attribute << int() << std::string() << bool()
> );
> }
>
> HTH,

 

Hi Eric,

 

It does! It is way more elegant than what I came up with.

I can even add a few features (like an optional end) inside and it still compiles much faster.

 

Thanks a lot,

 

Christophe

 

_________________________________________________________________
With Windows Live, you can organize, edit, and share your photos.
http://www.microsoft.com/middleeast/windows/windowslive/products/photo-gallery-edit.aspx



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