Alisdair Meredith <[EMAIL PROTECTED]> writes: > Terje Slettebų wrote: > >> The results don't necessarily have to be printed out at >> compile-time (Erwin Unruh printed the results using compiler-warnings, but >> that is of course highly implementation dependent). > >> "Hello, world" in compile-time programming doesn't necessarily have to be >> the same kind of program as in run-time programming, since the way it works >> is different. > > I suspect a metaprogram that does nothing but issue a few diagnostics > would be dismissed as a curiosity, maybe a cool toy, but hardy seen as > an interesting tool by someone new to the idea. > > Creating a static array of size 5! shows a little more potential, but > what to do with the array?
And that's still primarily numerical computation. > However, it is far too easy to be negative when I have nothing better to > offer in return (although I will be quite keen to see the final example, > MPL is one of those items on my 'to-do' list that never quite hits the > top) My current working idea is really simple: struct impl1 { ... }; struct impl2 { ... }; template <class T> struct my_container : if_<is_pointer<T>, impl1, impl2>::type { ... }; This is something I want to do all the time; it lets you swap out a completely different implementation for the class (well, except for the constructors) based on type properties. It also shows the convenient interaction of type_traits metafunctions with MPL algorithms. Can we do better? > What are people actively doing with MPL anyway? Perhaps and answer > to that question will indicate what 'Hello world' should look like. > It should be more than a neat exercise in syntax, it should > demonstrate the idea of real-world use. > > Currently I mainly use compile-time techniques for static assertions. It's a good thing to use MPL for, but I suspect the idea of causing errors isn't going to entice most people to dig deeper ;-) > I have written some toy curiousities such as the classic factorial > generator and recursive array-like containers. I am yet to make the > leap from playing with the syntax to applying it to real world > problems, and if we can come up with a simple example that makes > that leap, we'll have hit gold [where 'we' here clearly means 'you' > <g>] That's what we're interested in. My favorite examples are much too involved to be used for "hello, world". -- David Abrahams [EMAIL PROTECTED] * http://www.boost-consulting.com Boost support, enhancements, training, and commercial distribution _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost