From 91906ac904cb69ec44fef73617c10c07e9f3569d Mon Sep 17 00:00:00 2001 From: Miuna <809711+Mishura4@users.noreply.github.com> Date: Fri, 6 Oct 2023 19:25:21 -0400 Subject: [PATCH] build: fix #926, speedrun to #1000 (#927) --- include/dpp/discordevents.h | 4 +++- src/dpp/discordevents.cpp | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/dpp/discordevents.h b/include/dpp/discordevents.h index d2c80c8ed1..60ef5006b2 100644 --- a/include/dpp/discordevents.h +++ b/include/dpp/discordevents.h @@ -23,6 +23,8 @@ #include #include #include +#include +#include namespace dpp { @@ -53,7 +55,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); } }