From 76dfda7c1c03e728d96a29e2a4db5dc2a56bf7a8 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 11 May 2020 12:38:49 +0100 Subject: [PATCH] Replace boost:variant with std::variant in StandardCompiler --- libsolidity/interface/StandardCompiler.cpp | 18 +++++++++--------- libsolidity/interface/StandardCompiler.h | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index 15989dcf3..65b948bb2 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -32,7 +32,7 @@ #include #include -#include +#include #include #include @@ -491,7 +491,7 @@ std::optional checkOutputSelection(Json::Value const& _outputSelect } /// Validates the optimizer settings and returns them in a parsed object. /// On error returns the json-formatted error message. -boost::variant parseOptimizerSettings(Json::Value const& _jsonInput) +std::variant parseOptimizerSettings(Json::Value const& _jsonInput) { if (auto result = checkOptimizerKeys(_jsonInput)) return *result; @@ -552,7 +552,7 @@ boost::variant parseOptimizerSettings(Json::Valu } -boost::variant StandardCompiler::parseInput(Json::Value const& _input) +std::variant StandardCompiler::parseInput(Json::Value const& _input) { InputsAndSettings ret; @@ -740,10 +740,10 @@ boost::variant StandardCompile if (settings.isMember("optimizer")) { auto optimiserSettings = parseOptimizerSettings(settings["optimizer"]); - if (optimiserSettings.type() == typeid(Json::Value)) - return boost::get(std::move(optimiserSettings)); // was an error + if (std::holds_alternative(optimiserSettings)) + return std::get(std::move(optimiserSettings)); // was an error else - ret.optimiserSettings = boost::get(std::move(optimiserSettings)); + ret.optimiserSettings = std::get(std::move(optimiserSettings)); } Json::Value jsonLibraries = settings.get("libraries", Json::Value(Json::objectValue)); @@ -1155,9 +1155,9 @@ Json::Value StandardCompiler::compile(Json::Value const& _input) noexcept try { auto parsed = parseInput(_input); - if (parsed.type() == typeid(Json::Value)) - return boost::get(std::move(parsed)); - InputsAndSettings settings = boost::get(std::move(parsed)); + if (std::holds_alternative(parsed)) + return std::get(std::move(parsed)); + InputsAndSettings settings = std::get(std::move(parsed)); if (settings.language == "Solidity") return compileSolidity(std::move(settings)); else if (settings.language == "Yul") diff --git a/libsolidity/interface/StandardCompiler.h b/libsolidity/interface/StandardCompiler.h index 885417d8b..d1a1489c3 100644 --- a/libsolidity/interface/StandardCompiler.h +++ b/libsolidity/interface/StandardCompiler.h @@ -24,9 +24,9 @@ #include -#include #include #include +#include namespace solidity::frontend { @@ -73,7 +73,7 @@ private: /// Parses the input json (and potentially invokes the read callback) and either returns /// it in condensed form or an error as a json object. - boost::variant parseInput(Json::Value const& _input); + std::variant parseInput(Json::Value const& _input); Json::Value compileSolidity(InputsAndSettings _inputsAndSettings); Json::Value compileYul(InputsAndSettings _inputsAndSettings);