[webkit-dev] Using namespace std
Allan Sandfeld Jensen
kde at carewolf.com
Wed May 16 09:20:01 PDT 2012
On Wednesday 16 May 2012, Allan Sandfeld Jensen wrote:
> On Tuesday 15 May 2012, Darin Adler wrote:
> > On May 15, 2012, at 10:04 AM, Allan Sandfeld Jensen wrote:
> > > The conflict is between isinf, isnan and std::isinf and std::isnan, but
> > > the conflict only exists in C++11 when constexpr versions are
> > > introduced.
> > We should try harder to come up with a solution in MathExtras.h. Even one
> > that uses macros.
> > If I understand correctly, the conflict here is not between some WebKit
> > namespace and the std namespace, it’s in the C++ library itself between
> > the global namespace and the std namespace. I think that’s a bug in the
> > C++ library, and MathExtras.h is the perfect place for a workaround for
> > that bug.
> True. If we can find a method that would work, that would be the optimal
> solution, but it is a difficult case to work around. It is not that I
> haven't tried, but modifying those ~10 files was just a lot easier in the
Okay I found a solution and have updated the patch in
https://bugs.webkit.org/show_bug.cgi?id=86465. It is not pretty, but it works
I should point out though, that there is another conflict which is entirely
our own fault. It is between WTF::bind and the new std::bind from C++11, we
have even declared 'using WTF::bind' in the global namespace, which makes
conflicts much easier to trigger. On top of that several of the files using
bind, had declared 'using namespace std' even though they do not using any
functions from std.
We can work around issues like this, but I would still prefer if we advised
against 'using namespace std', as seen even more clearly in the 'bind' case,
it can easily cause problems when upgrading standard libraries or compilers.
More information about the webkit-dev