Boost logo

Boost :

From: Jaap Suter (J.Suter_at_[hidden])
Date: 2002-09-09 16:38:34

RE: [boost] Re: MPL Experiences>Sorry, I've been out of sync with the list.
>As it has been reported during the review, 'insert' and 'insert_range'
>algorithms in the "" archive are broken.

Don't be sorry. I should have checked the review archive messages. My bad.

Thanks for the fix!

On another topic; I would love to see or hear how other people are using the
MPL. I am kinda developing my own code style with it, and I am fairly sure I
am doing all sorts of things wrong. For example:

1. What kind of indentation practices do you use?
2. Do you nest if_ statements, or do you always factor them out into a
seperate meta function?
3. When do you decide to use a type and when a direct value for a template
parameter of your own functions. I used to use int or size_t in my own
meta-functions. But I ended up rewriting most of them to use integral_c<
something >, even when only ints or size_t's are appropriate types. That is
because that way they can be used with the algorithms. It takes some getting
used to, but right now I am very comfortable with it. In fact, I like it
better this way.
4. How do you comment your meta-functions and -algorithms. For example, do
you reckon it might be helpful for some meta-functions to add a runtime
pseudo-code version in the comments for comparison purposes.
5. How do you deal with default parameters that indicate a starting value
(for example, for an iteration). To illustrate, the following runtime-code

for ( int i = 0; i < 8; ++i );

can be converted (code is not the same, but you'll get the idea) to:

template< typename Index = int_c< 0 > > struct foo
        if_< less< Index, int_c< 8 > >::type,
               foo< Index::next >,
               ...stop thingy...

        // I know this doesn't make any sense, but the point
        // is the default iterator parameter;

Do you expose this parameter? Or do you use something like this:

struct foo{ struct foo_impl< int_c< 0 > >; }

Anyway, just some random thoughts.

I understand that the MPL, and meta programming in general, is very new. I
have looked at the MPL source to get an idea. But I am sure lots of people
have different practices. I'm interested to hear other stories.


Jaap Suter

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