Skip to content

Commit 3e7147f

Browse files
committed
Preserve const
1 parent 3facf4f commit 3e7147f

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

libs/server-sdk/src/bindings/c/hook_context.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ LDHookContext_Set(LDHookContext hook_context,
2020
LD_ASSERT(hook_context != nullptr);
2121
LD_ASSERT(key != nullptr);
2222

23-
const auto shared_any = std::make_shared<std::any>(
24-
const_cast<void*>(value));
23+
const auto shared_any = std::make_shared<std::any>(value);
2524
// The "any" wrapper will be allocated and deleted, but the contents
2625
// of the "any" will not.
2726
AS_HOOK_CONTEXT(hook_context)->Set(key, shared_any);
@@ -38,7 +37,7 @@ LDHookContext_Get(LDHookContext hook_context,
3837
const auto result = AS_HOOK_CONTEXT(hook_context)->Get(key);
3938
if (result.has_value() && *result != nullptr) {
4039
try {
41-
*out_value = std::any_cast<void*>(*result->get());
40+
*out_value = std::any_cast<const void*>(*result->get());
4241
return true;
4342
} catch (std::bad_any_cast const&) {
4443
// The stored value wasn't a void*, return false

0 commit comments

Comments
 (0)