Boost logo

Boost :

From: Yitzhak Sapir (yitzhaks_at_[hidden])
Date: 2003-01-06 10:36:15


I think storing the text "Hello world!" in a vector

typedef vector13_c<char,
    'H','e','l','l','o',' ',
    'w','o','r','l','d','!','\n'> hello_world;

And then using functors to print it such as:

template <class Prev, class T> struct print
{
    static void eval()
    {
        Prev::eval();
        std::cout.put(T::value);
    }
};

fold<vector,...>::type::eval();

would work as an hello world. It introduces two main concepts (fold,
vector), shows how MPL can be used for loop unrolling (on proper
compilers, the entire Hello world text would be unrolled into
successive calls cout.put), and makes sense for most people as an "Hello
world".


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk