[LLVMdev] name collision - llvm::tie and boost::tie

Sameer D. Sahasrabuddhe sameerds at it.iitb.ac.in
Fri Sep 23 00:42:07 PDT 2005

Tzu-Chien Chiu wrote:

> I hope I could "using namespace"  boost and llvm in .cpp file, because
> it's tedious to use fully-qualified identifiers in boost and llvm
> namespace.

How often do you need to mix the two libraries? Or specifically, use the 
two versions of tie() in the same cpp? A little #include discipline 
could go a long way in avoiding such clashes. LLVM source itself is a 
good example of how to avoid including headers unless absolutely necessary.

Or, simply qualify tie() in the appropriate places, while you continue 
to use the "using namespace" directive. The following code works for me:

#include <iostream>

namespace one {

   void arbit_one()
     std::cout << "arbit one" << std::endl;

   void name_space()
     std::cout << "namespace one" << std::endl;

namespace two {

   void arbit_two()
     std::cout << "arbit two" << std::endl;

   void name_space()
     std::cout << "namespace two" << std::endl;

int main()
   using namespace one;
   using namespace two;


   return 0;

Research Scholar, KReSIT, IIT Bombay

More information about the llvm-dev mailing list