Skip to content

Commit

Permalink
rpc: Replace boost::variant with std::variant for RPCArg.m_fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoFalke committed Jan 1, 2021
1 parent e75f91e commit fa749fb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/rpc/util.cpp
Original file line number Diff line number Diff line change
@@ -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
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

Expand Down Expand Up @@ -562,10 +562,10 @@ std::string RPCArg::GetName() const

bool RPCArg::IsOptional() const
{
if (m_fallback.which() == 1) {
if (m_fallback.index() == 1) {
return true;
} else {
return RPCArg::Optional::NO != boost::get<RPCArg::Optional>(m_fallback);
return RPCArg::Optional::NO != std::get<RPCArg::Optional>(m_fallback);
}
}

Expand Down Expand Up @@ -609,10 +609,10 @@ std::string RPCArg::ToDescriptionString() const
}
} // no default case, so the compiler can warn about missing cases
}
if (m_fallback.which() == 1) {
ret += ", optional, default=" + boost::get<std::string>(m_fallback);
if (m_fallback.index() == 1) {
ret += ", optional, default=" + std::get<std::string>(m_fallback);
} else {
switch (boost::get<RPCArg::Optional>(m_fallback)) {
switch (std::get<RPCArg::Optional>(m_fallback)) {
case RPCArg::Optional::OMITTED: {
// nothing to do. Element is treated as if not present and has no default value
break;
Expand Down
7 changes: 3 additions & 4 deletions src/rpc/util.h
Original file line number Diff line number Diff line change
@@ -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
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

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

#include <string>
#include <variant>
#include <vector>

#include <boost/variant.hpp>

/**
* String used to describe UNIX epoch time in documentation, factored out to a
* constant for consistency.
Expand Down Expand Up @@ -144,7 +143,7 @@ struct RPCArg {
*/
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 Type m_type;
const bool m_hidden;
Expand Down
2 changes: 2 additions & 0 deletions test/sanitizer_suppressions/ubsan
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,6 @@ implicit-signed-integer-truncation:test/skiplist_tests.cpp
implicit-signed-integer-truncation:torcontrol.cpp
implicit-unsigned-integer-truncation:crypto/*
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/*

0 comments on commit fa749fb

Please sign in to comment.