C++: instantiate some templates once in libsyncevolution

This saves some space (total number of blocks for SyncEvolution object
files when building statically down from 421588 to 413300) and
presumably also build times (not measured).

However, it did not work for all templates, leading to link errors
when trying to add std::map and std::pair of strings. It probably also
does not make sense for templates where only some functionality is
used.

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
This commit is contained in:
Patrick Ohly 2018-01-31 11:16:03 +01:00
parent 85edb458f4
commit 7d527c6dd8
2 changed files with 13 additions and 0 deletions

View File

@ -64,6 +64,10 @@
CPPUNIT_REGISTRY_ADD_TO_DEFAULT("SyncEvolution");
#endif
template class std::basic_string<char>; // std::string
template class std::vector<std::string>;
template class std::list<std::string>;
#include <syncevo/declarations.h>
SE_BEGIN_CXX

View File

@ -42,6 +42,15 @@
// include it to avoid changing code using the time things
#include <syncevo/Exception.h> // same for Exception and SE_THROW*
extern template class std::basic_string<char>; // std::string
extern template class std::vector<std::string>;
extern template class std::list<std::string>;
// Does not work:
// undefined reference to `std::pair<...>::pair(...)'
// extern template struct std::pair<std::string, std::string>;
// extern template class std::map<std::string, std::string>;
#include <syncevo/declarations.h>
SE_BEGIN_CXX