
15 Feb
2008
15 Feb
'08
3:07 p.m.
On Fri, Feb 15, 2008 at 3:14 AM, Jean-Pierre Bergamin <james@ractive.ch> wrote:
Could there be a way to provide a function object safe_logical_and that only evaluates the second argument if the first one is true?
I've written something like that before as: // warning, code typed in e-mail template <typename F0, typename F2> struct and_ { F0 first; F1 second; and_(F0 f0, F1, f1) : first(f0), second(f1) { } bool operator()() const { return first() && second(); } }; but if you needed function arguments that weren't available to be bound at and_ construction time you'd have to do some more trickery. This would also scale well using variadic templates. --Michael Fawcett