diff --git a/src/rest.cpp b/src/rest.cpp --- a/src/rest.cpp +++ b/src/rest.cpp @@ -21,7 +21,7 @@ #include <streams.h> #include <sync.h> #include <txmempool.h> -#include <util/system.h> +#include <util/any.h> #include <validation.h> #include <version.h> diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -22,10 +22,10 @@ #include <scheduler.h> #include <script/descriptor.h> #include <timedata.h> +#include <util/any.h> #include <util/check.h> #include <util/message.h> // For MessageSign(), MessageVerify() #include <util/strencodings.h> -#include <util/system.h> #include <util/time.h> #include <univalue.h> diff --git a/src/rpc/server_util.cpp b/src/rpc/server_util.cpp --- a/src/rpc/server_util.cpp +++ b/src/rpc/server_util.cpp @@ -10,7 +10,7 @@ #include <rpc/protocol.h> #include <rpc/request.h> #include <txmempool.h> -#include <util/system.h> +#include <util/any.h> #include <validation.h> #include <any> diff --git a/src/util/any.h b/src/util/any.h new file mode 100644 --- /dev/null +++ b/src/util/any.h @@ -0,0 +1,24 @@ +// Copyright (c) 2023 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_UTIL_ANY_H +#define BITCOIN_UTIL_ANY_H + +#include <any> + +namespace util { + +/** + * Helper function to access the contained object of a std::any instance. + * Returns a pointer to the object if passed instance has a value and the type + * matches, nullptr otherwise. + */ +template <typename T> T *AnyPtr(const std::any &any) noexcept { + T *const *ptr = std::any_cast<T *>(&any); + return ptr ? *ptr : nullptr; +} + +} // namespace util + +#endif // BITCOIN_UTIL_ANY_H diff --git a/src/util/system.h b/src/util/system.h --- a/src/util/system.h +++ b/src/util/system.h @@ -13,7 +13,6 @@ #include <compat.h> #include <compat/assumptions.h> -#include <any> #include <cstdint> #include <set> #include <string> @@ -39,18 +38,4 @@ std::string CopyrightHolders(const std::string &strPrefix); -namespace util { - -/** - * Helper function to access the contained object of a std::any instance. - * Returns a pointer to the object if passed instance has a value and the type - * matches, nullptr otherwise. - */ -template <typename T> T *AnyPtr(const std::any &any) noexcept { - T *const *ptr = std::any_cast<T *>(&any); - return ptr ? *ptr : nullptr; -} - -} // namespace util - #endif // BITCOIN_UTIL_SYSTEM_H diff --git a/src/wallet/rpc/util.cpp b/src/wallet/rpc/util.cpp --- a/src/wallet/rpc/util.cpp +++ b/src/wallet/rpc/util.cpp @@ -5,6 +5,7 @@ #include <wallet/rpc/util.h> #include <rpc/util.h> +#include <util/any.h> #include <util/translation.h> #include <util/url.h> #include <wallet/context.h>