Variadic functions in C++98

  • fuse/unfuseを使ってvariadic functionのエミュレートを試みた…実装
  • Argsに何を渡すかだが、将来的にはfusion::vector固定でいいと思う
    • FusionSequenceはRangeのようにviewを取り出せる
std::stringstream g_out;

struct little_print
{
    template<class Me, class Args>
    struct apply
    {
        typedef void type;
    };

    template<class Re, class Args>
    void call(Args& args) const
    {
        g_out << args.get_head();
        make_function(*this)(args.get_tail());
    }

    template<class Re>
    void call(boost::tuples::null_type) const
    {}
};

typedef variadic<little_print>::type T_print;
T_print const print = PSTADE_EGG_VARIADIC({});

void test()
{
    print(1,2,3,4,5);
    BOOST_CHECK(g_out.str() == "12345");
}