
David Abrahams wrote:
"Peter Dimov" <pdimov@mmltd.net> writes:
David Abrahams wrote:
"Peter Dimov" <pdimov@mmltd.net> writes:
Of course f = t; is merely a shorthand way of spelling f = boost::lambda::constant(t), but a dependency on lambda isn't always desirable.
Thoughts?
By the same token, one could argue that this functionality ought to be pushed into boost::bind.
I'm not sure what you mean. What functionality ought to be pushed into boost::bind?
The ability to build an always(whatever) function object:
f = boost::bind(t);
This is not an improvement over f = constant( t ); It still needs a glue call. Also, it doesn't make much sense to use boost::bind for this functionality, because constants do not have any arguments that could be bound. The bind way to make a constant is bind( identity<T>(), t ). The original motivating example is this: struct button { boost::function<bool()> is_enabled; }; bool sometimes(); int main() { button b; b.is_enabled = true; b.is_enabled = false; b.is_enabled = sometimes; } I don't want the simple syntax to be encumbered by constant() or bind().