Microsoft has an extension in which you can declare that the template instance will be external; therefore, it does not receive an implicit instance. At least this theory. I tried to reproduce this with code
#include <vector> class Foo{ int i; public: virtual ~Foo(); }; extern template class std::vector<Foo>;
It gives me
warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
However, nothing else happens: the program continues to bind find, although I use push_back (and dumpbin shows that push_back was created).
Only when I announce
extern template void std::vector<Foo>::push_back(const Foo&);
I get a linker error as expected.
So: how can I declare the entire instance (all members) explicit, preventing the implicit instantiation of the instance?
, :
extern -, . , , .
vector::push_back() ( std::vector < > ) .
vector::push_back()
, , , extern - , , .
extern
, , , extern -.
Source: https://habr.com/ru/post/1776535/More articles:How to enable Speex codec on a microphone object in Flex 4? - flexSlow WPF animation. Better to use shapes than .png? - performanceSocket data corrupted during TCP / IP transmission - c== on String in Java is not as expected? - javaHow to deal with localization? Is there a standard that I have to follow? - php местоположение - searchWhy does Xcode compile all my code twice, resulting in linker errors for any global variables? - compiler-constructionHow to calculate a negative number in an assembly - assemblyWhat causes a redirect loop? - redirectThe correct way to change the image size for installation on the screen ldpi, hdpi - androidAll Articles