Skip to content

Commit 24b2629

Browse files
committed
Add conditional compilation.
1 parent df91388 commit 24b2629

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

libs/internal/include/launchdarkly/serialization/value_mapping.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <boost/core/ignore_unused.hpp>
66
#include <boost/json.hpp>
77
#include <tl/expected.hpp>
8+
#include <boost/version.hpp>
89

910
#include <optional>
1011
#include <type_traits>
@@ -195,7 +196,16 @@ void WriteMinimal(boost::json::object& obj,
195196
T const& val,
196197
std::function<bool()> const& predicate, const C &c) {
197198
if (predicate()) {
199+
// In Boost 1.83 the ability to have a conversion context was added.
200+
// It also introduces the potential for the wrong conversion to be used,
201+
// so for boost 1.83 and greater we use a conversion context to ensure
202+
// the correct serialization is used.
203+
#if BOOST_VERSION >= 108300
198204
obj.emplace(key, boost::json::value_from(val, c));
205+
#else
206+
boost::ignore_unused(c);
207+
obj.emplace(key, boost::json::value_from(val));
208+
#endif
199209
}
200210
}
201211

0 commit comments

Comments
 (0)