Replies: 2 comments
-
Thanks for the suggestion. Generally I think that header-only implementations should be avoided for the reasons you pointed out. However, in the case of Thanks for the Boost example. Actually I have another open source project spacy-cpp which is available both as header-only and as a compiled library, so I'm familiar with the concept. |
Beta Was this translation helpful? Give feedback.
-
I will proceed to close this discussion, as there are no plans to address this. |
Beta Was this translation helpful? Give feedback.
-
A bunch of primarily header-only libraries like
tomlplusplus
orspdlog
are also available in a compilable variant, where there's a single translation unit (cpp file) that defines the body of actual functions, or even a separate project that generates a library with the symbols, and on other places they are just declared and reused. They claim that it speeds up the compilation a lot (and it makes sense, given the size of the headers, and reusability of compiled code increases due to incremental compilation). The idea is simple, some preprocessor directives should control whether the header only declares all the functions, or whether it also defines their bodies. And the include with definitions should just go into one designated file, while the lightweight declare-only inclusion to all the other files.Also Boost.Asio has something like this for instance (depending on whether library is to be in .cpp or separate lib):
Beta Was this translation helpful? Give feedback.
All reactions