This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/15910] can't compile self defined void distance(std::vector<T>, std::vector<T>)
- From: "giovannibajo at libero dot it" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Aug 2004 12:48:27 -0000
- Subject: [Bug libstdc++/15910] can't compile self defined void distance(std::vector<T>, std::vector<T>)
- References: <20040610143911.15910.king.benjamin@mh-hannover.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From giovannibajo at libero dot it 2004-08-03 12:48 -------
Subject: Re: can't compile self defined void distance(std::vector<T>, std::vector<T>)
gdr at integrable-solutions dot net wrote:
>> Is there *anything* in the standard saying that the code is actually
>> illegal?
>> This is a rejects-valid IMO.
> Can you elaborate on why you believe this is a reject a valid?
Because I think that picking up std::distance by Koenig lookup and having it
*abort compilation* instead of being reject as an invalid overload is just an
unintended side effect of the implementation. If you want to push it, it might
be an unintended side-effect of the standard - fine, the standard is broken.
But I won't never buy that the code is rightfully ill-formed as-is. It breaks
every single kind of orthogonality in the language: for instance, if I define a
::distance() with 3 parameters, it will compile.
When and if we agree there is *at least* a QoI issue here, we can discuss the
implementation details.
>A class is not an iterator just because it happens to have
>a nested type named iterator_category.
Sure, I'm just making the QoI issue less worse. There are other possible
implementations that come to mind. I can enable_if using a ConceptCheck on the
iterators - still much better than just aborting on *any* class.
Or maybe, we could have a way to use enable_if using as condition "does
iterator_traits<T> have a nested difference_type?".
Giovanni Bajo
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15910