mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-07 13:40:38 +02:00
Merge #20736: rpc: Replace boost::variant with std::variant for RPCArg.m_fallback
fa749fbea3cad64582f76f7a58cfcc0d91a97326 rpc: Replace boost::variant with std::variant for RPCArg.m_fallback (MarcoFalke) Pull request description: Now that we can use std::variant from the vanilla standard library, drop the third-party boost variant dependency. Patch is split out from #20480. A step-by-step replacement is possible because we don't have our own `Variant` wrapper and the source code specifies `boost::variant` explicitly. I think a step-by-step replacement should be preferred, because it simplifies review. ACKs for top commit: fjahr: re-ACK fa749fbea3cad64582f76f7a58cfcc0d91a97326 Sjors: re-ACK fa749fbea3cad64582f76f7a58cfcc0d91a97326 Tree-SHA512: 5e3c12b7d535f73065b4afa8df0a488f78fb25d2234f5ecbf740e624db03a34c35fea100eb7d37e84741721310e6450b7fb4296a2207a7ed1fa24485b3650981
This commit is contained in:
commit
bc8ada1c15
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2017-2020 The Bitcoin Core developers
|
// Copyright (c) 2017-2021 The Bitcoin Core developers
|
||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
@ -562,10 +562,10 @@ std::string RPCArg::GetName() const
|
|||||||
|
|
||||||
bool RPCArg::IsOptional() const
|
bool RPCArg::IsOptional() const
|
||||||
{
|
{
|
||||||
if (m_fallback.which() == 1) {
|
if (m_fallback.index() == 1) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return RPCArg::Optional::NO != boost::get<RPCArg::Optional>(m_fallback);
|
return RPCArg::Optional::NO != std::get<RPCArg::Optional>(m_fallback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -609,10 +609,10 @@ std::string RPCArg::ToDescriptionString() const
|
|||||||
}
|
}
|
||||||
} // no default case, so the compiler can warn about missing cases
|
} // no default case, so the compiler can warn about missing cases
|
||||||
}
|
}
|
||||||
if (m_fallback.which() == 1) {
|
if (m_fallback.index() == 1) {
|
||||||
ret += ", optional, default=" + boost::get<std::string>(m_fallback);
|
ret += ", optional, default=" + std::get<std::string>(m_fallback);
|
||||||
} else {
|
} else {
|
||||||
switch (boost::get<RPCArg::Optional>(m_fallback)) {
|
switch (std::get<RPCArg::Optional>(m_fallback)) {
|
||||||
case RPCArg::Optional::OMITTED: {
|
case RPCArg::Optional::OMITTED: {
|
||||||
// nothing to do. Element is treated as if not present and has no default value
|
// nothing to do. Element is treated as if not present and has no default value
|
||||||
break;
|
break;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2017-2020 The Bitcoin Core developers
|
// Copyright (c) 2017-2021 The Bitcoin Core developers
|
||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
@ -19,10 +19,9 @@
|
|||||||
#include <util/check.h>
|
#include <util/check.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <variant>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <boost/variant.hpp>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String used to describe UNIX epoch time in documentation, factored out to a
|
* String used to describe UNIX epoch time in documentation, factored out to a
|
||||||
* constant for consistency.
|
* constant for consistency.
|
||||||
@ -144,7 +143,7 @@ struct RPCArg {
|
|||||||
*/
|
*/
|
||||||
OMITTED,
|
OMITTED,
|
||||||
};
|
};
|
||||||
using Fallback = boost::variant<Optional, /* default value for optional args */ std::string>;
|
using Fallback = std::variant<Optional, /* default value for optional args */ std::string>;
|
||||||
const std::string m_names; //!< The name of the arg (can be empty for inner args, can contain multiple aliases separated by | for named request arguments)
|
const std::string m_names; //!< The name of the arg (can be empty for inner args, can contain multiple aliases separated by | for named request arguments)
|
||||||
const Type m_type;
|
const Type m_type;
|
||||||
const bool m_hidden;
|
const bool m_hidden;
|
||||||
|
@ -77,4 +77,6 @@ implicit-signed-integer-truncation:test/skiplist_tests.cpp
|
|||||||
implicit-signed-integer-truncation:torcontrol.cpp
|
implicit-signed-integer-truncation:torcontrol.cpp
|
||||||
implicit-unsigned-integer-truncation:crypto/*
|
implicit-unsigned-integer-truncation:crypto/*
|
||||||
implicit-unsigned-integer-truncation:leveldb/*
|
implicit-unsigned-integer-truncation:leveldb/*
|
||||||
|
# std::variant warning fixed in https://github.com/gcc-mirror/gcc/commit/074436cf8cdd2a9ce75cadd36deb8301f00e55b9
|
||||||
|
implicit-unsigned-integer-truncation:std::__detail::__variant::_Variant_storage
|
||||||
implicit-integer-sign-change:crc32c/*
|
implicit-integer-sign-change:crc32c/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user