Skip to content

Commit bc8ada1

Browse files
author
MarcoFalke
committed
Merge bitcoin#20736: rpc: Replace boost::variant with std::variant for RPCArg.m_fallback
fa749fb 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 bitcoin#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 fa749fb Sjors: re-ACK fa749fb Tree-SHA512: 5e3c12b7d535f73065b4afa8df0a488f78fb25d2234f5ecbf740e624db03a34c35fea100eb7d37e84741721310e6450b7fb4296a2207a7ed1fa24485b3650981
2 parents f52f427 + fa749fb commit bc8ada1

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

src/rpc/util.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2017-2020 The Bitcoin Core developers
1+
// Copyright (c) 2017-2021 The Bitcoin Core developers
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

@@ -562,10 +562,10 @@ std::string RPCArg::GetName() const
562562

563563
bool RPCArg::IsOptional() const
564564
{
565-
if (m_fallback.which() == 1) {
565+
if (m_fallback.index() == 1) {
566566
return true;
567567
} else {
568-
return RPCArg::Optional::NO != boost::get<RPCArg::Optional>(m_fallback);
568+
return RPCArg::Optional::NO != std::get<RPCArg::Optional>(m_fallback);
569569
}
570570
}
571571

@@ -609,10 +609,10 @@ std::string RPCArg::ToDescriptionString() const
609609
}
610610
} // no default case, so the compiler can warn about missing cases
611611
}
612-
if (m_fallback.which() == 1) {
613-
ret += ", optional, default=" + boost::get<std::string>(m_fallback);
612+
if (m_fallback.index() == 1) {
613+
ret += ", optional, default=" + std::get<std::string>(m_fallback);
614614
} else {
615-
switch (boost::get<RPCArg::Optional>(m_fallback)) {
615+
switch (std::get<RPCArg::Optional>(m_fallback)) {
616616
case RPCArg::Optional::OMITTED: {
617617
// nothing to do. Element is treated as if not present and has no default value
618618
break;

src/rpc/util.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2017-2020 The Bitcoin Core developers
1+
// Copyright (c) 2017-2021 The Bitcoin Core developers
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

@@ -19,10 +19,9 @@
1919
#include <util/check.h>
2020

2121
#include <string>
22+
#include <variant>
2223
#include <vector>
2324

24-
#include <boost/variant.hpp>
25-
2625
/**
2726
* String used to describe UNIX epoch time in documentation, factored out to a
2827
* constant for consistency.
@@ -144,7 +143,7 @@ struct RPCArg {
144143
*/
145144
OMITTED,
146145
};
147-
using Fallback = boost::variant<Optional, /* default value for optional args */ std::string>;
146+
using Fallback = std::variant<Optional, /* default value for optional args */ std::string>;
148147
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)
149148
const Type m_type;
150149
const bool m_hidden;

test/sanitizer_suppressions/ubsan

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,6 @@ implicit-signed-integer-truncation:test/skiplist_tests.cpp
7777
implicit-signed-integer-truncation:torcontrol.cpp
7878
implicit-unsigned-integer-truncation:crypto/*
7979
implicit-unsigned-integer-truncation:leveldb/*
80+
# std::variant warning fixed in https://github.com/gcc-mirror/gcc/commit/074436cf8cdd2a9ce75cadd36deb8301f00e55b9
81+
implicit-unsigned-integer-truncation:std::__detail::__variant::_Variant_storage
8082
implicit-integer-sign-change:crc32c/*

0 commit comments

Comments
 (0)