|
Boost : |
From: Helmut Zeisel (HZ2012_at_[hidden])
Date: 2019-06-09 05:40:01
Von: "Roberto Hinz via Boost" <boost_at_[hidden]>
>> With a function object based interface, one could easily store and reuse
>> different formating options in parallel.
>>
> Not clear to me what you mean by that. Could you explain better ?
This is a general difference between functions and funcion objects.
If you use functions, you either need a global state
(which is not thread-safe and has to be reset after every change because you might rely on the original state at some other place in the program),
or you have to specify all options at every call (which might be quite a lot in the case of formatting).
Function objects can store the state/options internally.
When you use two (or more) different options alternating, you create two (or more) function objects and use these objects alternating without changing the global state and without specifying the different options again.
Helmut
Â
Â
Â
Â
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk