Boost logo

Boost :

From: Jaap Suter (J.Suter_at_[hidden])
Date: 2003-03-23 12:40:08

> Jaap, I was just looking over the EMPL Wiki page (which continues to
> be a great thing), and noticed that item 5.2 is not really a good
> example of MPL style.

The original intention was to focus on the default-template-parameter
technique, and keep the rest simple. The 'operate-on-types-only' is
introduced in a later item, so I wanted to keep this item simple.
Looking back, I agree with you, so I've changed the code.

> In fact, you apply equal_to to an integral
> constant and access its ::value_type member so I think it won't even
> compile.

That was of course completely wrong.

> That "arg" template is something that Aleksey and I have discussed
> which causes a nullary metafunction to be evaluated in a lambda
> expression. It may have another name in the current MPL sources; I'm
> not absolutely sure (Aleksey?)

I've done it somewhat differently in the new code.

> I also think it would be a great idea to have "zero" and "one"
> metafunctions (which also satisfy the integral constant wrapper
> requirements)
> If we wanted to get funky we could make it so zero<int_<3> > and
> zero<long> both work.

Those would be greatly appreciated, and very useful.

On a side note, I've ran into a few situations where I ended up using code
like this:

typedef list_c< some_type, 0, 1, 2, 3, 4 > some_list;
typedef integral_c< front< some_list >::type::value_type, 5 > some_element;

See what I'm trying to do? I need to get the type of the integral constants
inside a list, so I just get it through the first element in the list.
This doesn't work with empty list though, and it feels too complicated to do
this. Is there a simpler method? Something like:

typedef integral_c< some_list::element_type::value_type, 5 > some_element;

Notice the 'element_type'. All sequences would then have such a member-type
Perhaps there is already something like this in the MPL (STL has it too,
probably under a different name), but I couldn't find it.


Jaap Suter

Boost list run by bdawes at, gregod at, cpdaniel at, john at