Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: separate-compilation option #209

Open
cxw42 opened this issue Jan 14, 2023 · 1 comment
Open

Request: separate-compilation option #209

cxw42 opened this issue Jan 14, 2023 · 1 comment

Comments

@cxw42
Copy link
Contributor

cxw42 commented Jan 14, 2023

Would it be possible to add an option that separately compiles the parser and some of the other detail code that callers don't need? That would speed up compilation quite a bit. Thanks for considering this request!

Example of how this is done in another library: https://github.com/gulrak/filesystem#using-it-as-forwarding-implementation-header

@cxw42
Copy link
Contributor Author

cxw42 commented Jan 16, 2023

As an interim step, I was able to write a forwarding header and function using the default template arguments. Here it is in case it helps anyone else:

toml-wrapper.hpp

#include <unordered_map>
#include <vector>

#include "toml/get.hpp"

toml::basic_value<toml::preserve_comments, std::unordered_map, std::vector>
parseTomlFile(std::string fname);

toml-wrapper.cpp

#include "toml.hpp"
#include "toml-wrapper.hpp"

toml::basic_value<toml::preserve_comments, std::unordered_map, std::vector>
parseTomlFile(std::string fname)
{
    return toml::parse(fname);
}

Then client code can include toml-wrapper.hpp but not toml.hpp, and link to toml-wrapper.cpp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant