[webkit-dev] Using namespace std

Allan Sandfeld Jensen kde at carewolf.com
Wed May 16 01:25:27 PDT 2012

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 end.

> > Since the problem exists in both GCC 4.6 and 4.7, I see no alternative
> > than ensuring any files that uses isinf or isnan does not open the std
> > namespace. This is only around 10 files in total as you can see in my
> > patch.
> Sure, but that assumes we won’t use more things from the std namespace in
> the future, and I am not sure that’s a good assumption.
You don't have to open the namespace to use the methods within. I prefer to 
use the 'std::' prefix. I only kept them in this dcase to keep the changes to 
a minimum.

Best regards

More information about the webkit-dev mailing list