|
Boost : |
From: John Maddock (john_at_[hidden])
Date: 2006-07-21 05:17:24
Pavol Droba wrote:
> Hi,
>
> First of all, I'd like to thank you for the nice benchmarks.
>
> Now my comments to your patches:
>
> 1.) const Predicate& Pred
> Although this change can bring a performance benefits, it has one big
> drawback. You cannot pass an ordinary C function as predicate.
> At least not in VC++ 7.1
> I consider this is to be very important functionality, therefor it is
> implemented the way it is.
VC++ is correct here: in order to bind to that signature, one would have to
create a "reference to const-function" type, but const-qualified functions
are illegal types.
However, I believe there may be a DR that *would* make this legal: gcc tends
to be at the forefront of implementing these even if they haven't made it
into an official std yet.
> 2.) std::locale()
>
> I'm not a big fan of global objects when they are not necessary.
> Correct locale implementation should give only a very small footprint
> when instantiating std::locale(), since is all should be reference
> based.
> As seen from your benchmarks, there is great difference between g++
> and
> msvc. On the other hand, the difference on the vc++ is so large, that
> it is worth considering.
In theory passing a locale by value should be cheap, and it's distressing to
see that it's not.
Note that caching a global locale object and doing something like:
foo(const std::locale& l = get_cached_locale_object());
is *not* an option: the global locale can be changed at any time by calling
std::locale::global, which would make the locales returned by
get_cached_locale_object() and std::locale() non-equivalent.
Sorry for the bad news :-(
John.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk