diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2018-01-31 11:16:03 +0100 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2020-12-05 21:28:08 +0100 |
commit | 7d527c6dd8d55b0c8a7d001d5ae71627f38b1beb (patch) | |
tree | 46a19ddec3075bd295e5d1c9d98299b980be2d79 | |
parent | 85edb458f4d623b6e1fc361e2a29c909c286d785 (diff) |
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>
-rw-r--r-- | src/syncevo/util.cpp | 4 | ||||
-rw-r--r-- | src/syncevo/util.h | 9 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/syncevo/util.cpp b/src/syncevo/util.cpp index cf11c7c6..86f9a8be 100644 --- a/src/syncevo/util.cpp +++ b/src/syncevo/util.cpp @@ -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 diff --git a/src/syncevo/util.h b/src/syncevo/util.h index fb049944..d21ed1a1 100644 --- a/src/syncevo/util.h +++ b/src/syncevo/util.h @@ -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 |