Is it possible to create an inline lambda using boost which always throws an exception?
(this question follows on from "Using boost to create a lambda function which always returns true").
Suppose I have a function which takes some form of predicate:
void Foo( boost::function<bool(int,int,int)> predicate );
If I want to call it with a predicate that always throws an exception, define a helper function:
bool AlwaysThrow( int, int, int ) { throw std::exception(); }
...
Foo( boost::bind( AlwaysThrow ) );
But is there anyway to call this function (possibly using boost::lambda) without having to define a separate function?
(Note 1: I can't use C++0x.)
(Note 2: I've simplified this example. My actual "predicate" function doesn't return a bool, it returns a type which doesn't have a default-ctor.)