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

Boost.variant requirement #2

Open
jeremyong opened this issue Nov 18, 2015 · 4 comments
Open

Boost.variant requirement #2

jeremyong opened this issue Nov 18, 2015 · 4 comments

Comments

@jeremyong
Copy link

Given that C++11 (and beyond) union requirements have been relaxed, I'm curious as to whether boost variant is truly necessary, or even the best option for providing the JSON-structure like mstch::node object. The only weakness is that you lose constructor/destructor semantics but providing this as part of the constructor and destructor of a thin wrapper around the union is easy enough.

Removing the boost dependency would make the library a bit lighter and easier to integrate into other codebases.

Thanks for this library!

@staticlibs
Copy link

I implemented mstch::node without Boost.Variant - staticlibs@363d846

All tests are passed, with the following memory characteristics (reported by Valgrind for all tests in a single run):

# original Boost.Variant: 
total heap usage: 144,248 allocs, 144,247 frees, 21,974,808 bytes allocated

# mstch::node without Boost.Variant: 
total heap usage: 114,699 allocs, 114,698 frees, 26,540,620 bytes allocated

It may be optimized further, I haven't even used a union - used a plain class. VS2013 makes unions problematic though.

I am not creating a PR - doubt that it's worth it, Boost.Variant variant is cleaner and avoids a lot of runtime checks. Feel free to pull this change of course - it is under MIT as the whole mstch.

@KingDuckZ
Copy link

I can try and patch up the cmake file, so users can choose if they want boost::variant or eggs::variant, which might be better in terms of package download size, but that would conflict with my other pull request, so that should be merged first. Is the maintainer still around, or can somebody fork and sort out the PRs?

@torbjoernk
Copy link

@jeremyong, @staticlibs I've integrated @mbits-libs take on replacing boost::variant by std::variant. You may want to give that a try: torbjoernk/mstch@289cf21

Boost is only required for running the tests.

@wille-io
Copy link

wille-io commented Aug 8, 2022

Using std::variant as cmake option should be reconsidered, as C++17 is pretty spread already.

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

5 participants