PStade.Egg 使ってみた

#include <iostream>
#include <string>
#include <boost/lexical_cast.hpp>
#include <boost/mpl/lambda.hpp>
#include <pstade/egg/automatic.hpp>

using namespace std;
using namespace pstade::egg;

template <class To>
struct X_lexical_cast {
    typedef To result_type;

    template <class From>
    To operator()(From from) const
    {
        return boost::lexical_cast<To>(from);
    }
};

automatic<X_lexical_cast<boost::mpl::_> >::type
    const lexical = PSTADE_EGG_AUTOMATIC;

int main()
{
    string str = lexical(20); // lexical_cast<string>(20);

    cout << str << endl;

    return 0;
}

これはすごい