BOOST_LEAF_CFG_CAPTURE must be 1 for single-header build to compile
dnmiller opened this issue · comments
If BOOST_LEAF_CFG_CAPTURE
is 0, then <memory>
isn't included, but the code that uses std::shared_ptr
is not stripped out by the preprocessor, causing a build failure.
This is from a single-header build with this at the top:
// Generated on 05/27/2022 from https://github.com/boostorg/leaf/tree/5e9a5b9.
Thanks for reporting this.
I see a bug in LEAF where if you have BOOST_LEAF_CFG_CAPTURE=0
, it attempts to use std::shared_ptr
in exception.hpp
, which leads to a compile error. However, everything in exception.hpp
is turned off if exceptions are disabled. I'll fix this, but can you confirm that the configuration I'm describing is what you're using when you get the error?
Yep, that's it:
boost/leaf/exception.hpp:52:14: error: 'shared_ptr' in namespace 'std' does not name a template type
boost/leaf/exception.hpp:52:9: note: 'std::shared_ptr' is defined in header '<memory>'; did you forget to '#include <memory>'?
Yeah, OK. I'll remove the shared_ptr
from there, it was rather inefficient anyway. I'm curious about your platform if you don't mind me asking, it's surprising to want BOOST_LEAF_CFG_CAPTURE=0
but also not disable exception handling.
This is fixed, merged into the master branch, will ship with Boost 1.80.0.
I'm curious about your platform if you don't mind me asking, it's surprising to want BOOST_LEAF_CFG_CAPTURE=0 but also not disable exception handling.
I had actually just included it in an existing project to mess around with and was not paying much attention to the compiler flags...