How to guarantee order of argument evaluation when calling a function object?

What about a silly wrapper class like this:

struct OrderedCall
    template <typename F, typename ...Args>
    OrderedCall(F && f, Args &&... args)


void foo(int, char, bool);

OrderedCall{foo, 5, 'x', false};

If you want a return value, you could pass it in by reference (you’ll need some trait to extract the return type), or store it in the object, to get an interface like:

auto x = OrderedCall{foo, 5, 'x', false}.get_result();

Leave a Comment