[webkit-dev] Using namespace std
rniwa at webkit.org
Tue May 15 11:37:55 PDT 2012
On May 15, 2012 10:53 AM, "Peter Kasting" <pkasting at chromium.org> wrote:
> On Tue, May 15, 2012 at 9:31 AM, Darin Adler <darin at apple.com> wrote:
>> On May 15, 2012, at 5:48 AM, Allan Sandfeld Jensen wrote:
>> > To me it seems like an odd practice, so I would like to ask what
original rationale behind that style guideline is
>> Adding a list of using declarations like "using std::min" to the top of
each source file would give us another ongoing maintenance job. The list in
each file would grow, we’d not remember to remove them when they are no
longer needed, and so on.
> Given how little of std:: we actually use (since WTF is used instead for
most things), what about just explicitly qualifying usages with std::
directly? I realize you probably feel like these sorts of qualifications
make code less readable, but the impact of that seems minor to me -- the
Chromium codebase gets away with doing it and uses std:: far more often
than WebKit -- and it avoids the sort of maintenance headaches you mention.
It also makes it clearer to a reader when we are actually pulling in types
or functions from std:: (which might not always be what we wanted), and
avoids any naming conflicts from pulling in the whole std:: namespace
(which is apparently the reason for this thread).
Can we do that if and only if we have conflicts?
An alternative solution is to forward conflicting symbols from std to WTF
(i.e. make decisions about namespace in WTF) so that the rest of codebase
can simply use the forwarded WTF symbols instead. We could even wrap
whatever function we're using with a different name if we wanted.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the webkit-dev