[PATCH] LWG 2989 hide path iostream operators from normal lookup

François Dumont frs.dumont@gmail.com
Thu Jun 21 05:12:00 GMT 2018


That's a great way to define global operators.

I started working on making iterator operators global as we said once on 
this mailing list. I already noticed during that task that when I was 
making a mistake and gcc was complaining about not finding the == 
operator it was proposing about 80 candidates, so a very big compiler 
error message.

Can I generalize this approach ?

François

On 18/06/2018 20:59, Jonathan Wakely wrote:
> By only defining these operators as friends (with no namespace-scope
> declaration) they can only be found by ADL and do not participate in
> overload resolution for arguments of types other than path.
>
>     LWG 2989 hide path iostream operators from normal lookup
>     * include/bits/fs_path.h (operator<<, operator>>): Define inline as
>     friends.
>     * testsuite/27_io/filesystem/path/io/dr2989.cc: New.
>
> Tested powerpc64le-linux, commmitted to trunk.
>
>



More information about the Libstdc++ mailing list