This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [RFA] Status of HP/SGI extensions
Phil Edwards wrote:
> On Sun, Dec 30, 2001 at 06:47:40PM +0100, Paolo Carlini wrote:
> > What about keeping the helpers (that is, from a practical point of view, those
> > names beginning with one or two underscores) insided namespace std, and
> > viceversa putting the extension themselves into separate files in namespace
> > __gnu_cxx?
> >
> > Right now I don't have any better idea.
>
> This appeals to me. I (personally) feel that the uglified extensions don't
> need to be removed from std:: if we're using them as helpers to implement
> other things (for example, __uninitialized_copy_fill). We could leave
> those where they are, and document them as helper functions.
>
> Then in ext/* it would simply be a matter of
>
> namespace __gnu_cxx
> {
> using std::__uninitialized_copy_fill;
> }
>
> stl_deque.h uses some others also. For example, stl_iterator_base_funcs.h
> defines an additional version of std::distance(), taking three parameters.
I read your comment in the code. I agree that the 3-parameter version is an
extension.
> I just now changed deque::_M_range_initialize as follows:
>
> - size_type __n = 0;
> - distance(__first, __last, __n);
> + size_type __n = distance(__first, __last);
>
> The 3-parameter distance() extension is one that should be moved into ext,
> since we don't need to use it anywhere in bits/*. Occurrances should be
> fixed to use the standard 2-parameter version.
Phil, a quick grep reveals that the 3-parameter version is used also elsewhere in
bits, i.e.:
./stl_bvector.h:420: distance(__first, __last, __n);
./stl_bvector.h:441: distance(__first, __last, __n);
./stl_bvector.h:604: distance(__first, __last, __len);
./stl_tempbuf.h:141: distance(__first, __last, _M_len);
./stl_tree.h:1026: distance(__p.first, __p.second, __n);
./stl_tree.h:1143: distance(__p.first, __p.second, __n);
./stl_vector.h:466: distance(__first, __last, __n);
./stl_vector.h:587: distance(__first, __last, __len);
./stl_vector.h:756: distance(__first, __last, __n);
So, what should we do here?
This is one of the *nastiest* cases (very, very few of them luckily!) in which not
only an helper accompanying an extension is used by the implementation of the
standard library, but the extension itself!!
We have two options:
1- Change all those occurrences to a standard 2-parameter version and move to
__gnu_cxx both the 3-parameter extension and its helpers.
2- Change the implementation of the standard library to use the corresponding
3-parameter helper __distance and move only the extension itself to __gnu_cxx.
Cheers,
Paolo.