This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: shadowed rel_ops operators
- To: libstdc++ at gcc dot gnu dot org
- Subject: Re: shadowed rel_ops operators
- From: Nathan Myers <ncm at nospam dot cantrip dot org>
- Date: Thu, 18 Jan 2001 23:42:26 -0800
- References: <20010119130601.A7419@kungfu.ixla.com.au>
- Reply-To: libstdc++ at gcc dot gnu dot org
On Fri, Jan 19, 2001 at 01:06:01PM +1100, Richard Andrews wrote:
> Looking at stl_iterator.h (near end of file)
>
> There are templated operators defined here which exactly shadow the
> operators defined in std::rel_ops.
>
> These iterator specific operators cause havoc when using <iterator> and
> std::rel_ops in the same compilation unit.
>
> There are only two operators in stl_iterator.h which do anything unique
> to iterators they are operator==() and operator<(), the fundamental
> operators.
>
> I'd like to have the rest of the operators removed and replaced with (eg.)
>
> using std::rel_ops::operator!=;
>
> I have made the changes on my system and recompiled my extensive list of
> container code without any problems that I can see. So it looks like its
> safe to do this.
The rel_ops members were sequestered there to keep them out of trouble.
(They would have been removed entirely but for political considerations.)
Exposing them is dangerous because (IIRC) they are too greedy; they
interfere with other template operators that users define. (Recall
that users are allowed to specialize std:: templates on their own
types.)
It's OK to "using" them in your own .cc file, but they should not
be hoisted in a standard header file.
Nathan Myers
ncm at cantrip dot org