Domanda

Suppose I use shared_ptr<MyAwesomeClass> in 100 different cpp files. Will the compiler create a MyAwesomeClass specialization of shared_ptr in each and every one of the corresponding objs and then force the linker to sift through them all, select one winner, and remove all the losers?

If so, can this effect come to dominate link time, or will other operations take so much longer that it doesn't really matter?

I am trying to figure out why one of my projects takes 100+ seconds to link and another one of similar size gets done much faster. So far the only systematic difference I've identified is that the slow one makes heavy, widespread use of some of the newer standard library templates like shared_ptr and function.

The compiler/linker in question are Micrsoft's 2012 versions.

È stato utile?

Soluzione

This is platform dependent, but if it is indeed the cause you can address it via this in VS 2013. Hopefully it will work also for 2012. Note that it's a part of the C++11 standard as noted by Captain Obvlious, so it's just a question of whether or not it was supported in VS 2012.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top