Comment #2 on issue 195 by jmccaskey: common.h should not have "using
Yes, although the using statement is inside your own namespace it appears
least in Visual C++ 2005 the encapsulation is leaky and having used the
affect other code in the global name space. Maybe this is a Visual C++
bug, it does
seem to be violating scope rules for the using directive somehow. Even if
Visual C++ specific though, what if my application code wanted to use the
google::protobuf name space but not std? Having that also automatically
of std still seems undesirable.
Below is a simple test program that reproduces the issue directly just by
the common.h header. You'll notice I define a swap function directly in
namespace, and it ends up causing ambiguity with the std::swap function.
"using namespace std;" is removed from common.h this problem disappears.
The compilation errors will be:
error C2668: 'swap' : ambiguous call to overloaded function
1> c:\users\jmccaskey\documents\visual studio
2005\projects\test\test\test.cpp(8): could be 'void swap<int>(T &,T &)'
1> c:\program files (x86)\microsoft visual studio
'void std::swap<int>(_Ty &,_Ty &)'
1> while trying to match the argument list '(int, int)'
// test.cpp : Defines the entry point for the console application.
template< class T >
void swap( T &a, T &b )
T tmp = a;
a = b;
b = tmp;
int _tmain(int argc, _TCHAR* argv)
int one = 1;
int two = 2;
swap( one, two );
You received this message because you are subscribed to the Google Groups "Protocol
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to
For more options, visit this group at