From 9bbdf5f2d8e06130f4405053ad183e1fc20d410e Mon Sep 17 00:00:00 2001 From: Amber Ehrlich Date: Fri, 6 Oct 2023 18:56:38 -0400 Subject: [PATCH] surely THIS time --- include/dpp/discordevents.h | 2 +- src/dpp/discordevents.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/dpp/discordevents.h b/include/dpp/discordevents.h index d2c80c8ed1..f0dae80caa 100644 --- a/include/dpp/discordevents.h +++ b/include/dpp/discordevents.h @@ -53,7 +53,7 @@ void DPP_EXPORT set_snowflake_array_not_null(const nlohmann::json* j, const char * @param key key name to check for the values * @param fn function to apply to each element */ -void DPP_EXPORT for_each_json(nlohmann::json* parent, std::string_view key, std::function fn); +void DPP_EXPORT for_each_json(nlohmann::json* parent, std::string_view key, const std::function &fn); /** @brief Sets an array of objects from a json field value, if defined, else does nothing * @tparam T The class of which the array consists of. Must be derived from dpp::json_interface diff --git a/src/dpp/discordevents.cpp b/src/dpp/discordevents.cpp index be84176beb..43fefe6527 100644 --- a/src/dpp/discordevents.cpp +++ b/src/dpp/discordevents.cpp @@ -100,12 +100,12 @@ void set_snowflake_array_not_null(const json* j, const char *keyname, std::vecto } } -void for_each_json(const nlohmann::json* parent, const char* key, std::function fn) { +void for_each_json(nlohmann::json* parent, std::string_view key, const std::function &fn) { auto it = parent->find(key); if (it == parent->end() || it->is_null()) { return; } - for (const nlohmann::json &elem : *parent) { + for (nlohmann::json &elem : *parent) { fn(&elem); } }