Sunday, July 8, 2018

c++ - How to avoid shared_ptr ambiguity? (stl vs boost)










I've used stl's shared_ptr many places in my code and I have used the following using statement anywhere that I have used shared_ptr:




using namespace std::tr1;


Now I need to use boost::bimap. So I have to include the following header file in my code:



#include 


As soon as I include the bimap header file, the shared_ptr type becomes ambiguous, and I have to change all usages of shared_ptr to std::tr1::shared_ptr. Since this makes my code ugly, I am looking for a way to avoid this ambiguity without needing to declare shared_ptr everywhere with a fully qualified name. I was thinking of using typedef for std::tr1::shared_ptr, but maybe there are better ways too. Any advice would be appreciated!


Answer




simply do not introduce it. avoid the general using namespace ...


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...