$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] SafeInt code proposal
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-06-23 16:01:50
AMDG
Niels Dekker - address until 2010-10-10 wrote:
> Jean-Francois Bastien wrote:
>> [pedanticism]
>> Don't both your examples rely on pre-standard C++ friend declarations
>> and definitions injecting the function name in the innermost enclosing
>> namespace? I might be reading this worng, but 7.3.1.2 [namespace.memdef]
>> paragraph 3 states: "The name of the friend is not found by unqualified
>> lookup (3.4.1) or by qualified lookup (3.4.3) until a matching
>> declaration is provided in that namespace scope".
>> So you'd still need to declare in the namespace. From what I understand
>> the examples shouldn't work.
>>
>> Correct me if I'm wrong :)
>
> Well... I do appreciate your pedanticism, but I think you're wrong.
> All the compilers I tried accept the function calls to the inline
> friend function, operator-(safe_int,safe_int), including MSVC 2008
> SP1, Comeau (www.comeaucomputing.com/tryitout), and g++ 4.1.2, run at
> http://codepad.org/dB9IbQJ7
>
> You might want to have a look at [temp.inject] ("Friend names declared
> within a class template"). Quoting the latest C++0x Working Draft,
> www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2857.pdf, 14.7.5/2
> (slightly reformatted):
>
> "As with non-template classes, the names of namespace-scope friend
> functions of a class template specialization are not visible during an
> ordinary lookup unless explicitly declared at namespace scope (11.4).
> Such names may be found under the rules for associated classes
> (3.4.2). [ Example: <snip> ]
Exactly. In the current standard, they can be found by
argument-dependent lookup:
When considering an associated namespace, the lookup is the same as the
lookup performed when the associated
namespace is used as a qualifier (3.4.3.2) except that:
Any using-directives in the associated namespace are ignored.
Any namespace-scope friend functions declared in associated classes
are visible within their respective
namespaces even if they are not visible during an ordinary lookup (11.4).
In Christ,
Steven Watanabe