zero-alloc cache (was Re: [v3] Fix PR libstdc++/10276)
Nathan Myers
ncm-nospam@cantrip.org
Mon Apr 28 19:56:00 GMT 2003
On Mon, Apr 28, 2003 at 12:56:24PM +0200, Carlo Wood wrote:
> On Mon, Apr 28, 2003 at 02:22:09AM -0400, Jerry Quinn wrote:
> > Oops. The following patch moves the hook to pass the static cache to
> > the stream constructors. It passes make check-abi, but is it actually
> > safe?
>
> It seems to "break" the binary API - that is, the object name of
> the init function without a locale_cache being passed is changed;
> as a result, programs compiled with libstdc++ version 5.0.x with
> x <= 2 will not link anymore with libstdc++-5.0.3.
>
> While this solution might be ok for libstdc++-6 (although I'd ask
> someone else about that; I am not an API expert), I think we should
> use a totally new constructor for this one.
>
> Thus:
>
> keep explicit basic_istream(__streambuf_type* __sb);
>
> add explicit basic_istream(__streambuf_type* __sb, __locale_cache<_CharT>* __lc);
>
> What do you think?
As a matter of design policy, it's better to overload than to
add default arguments. Even where the standard explicitly declares
default arguments, we should take the opportunity to make them
overloads instead.
BTW, the second ctor above doesn't need to be declared explicit
(although it's allowed).
Nathan Myers
ncm-nospam@cantrip.org
More information about the Libstdc++
mailing list