mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Make use of C++17 std::optional<> instead of boost::optional<>.
This commit is contained in:
@@ -22,9 +22,9 @@
|
||||
|
||||
#include <libevmasm/Instruction.h>
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/operators.hpp>
|
||||
|
||||
|
||||
@@ -51,12 +51,12 @@ public:
|
||||
static EVMVersion istanbul() { return {Version::Istanbul}; }
|
||||
static EVMVersion berlin() { return {Version::Berlin}; }
|
||||
|
||||
static boost::optional<EVMVersion> fromString(std::string const& _version)
|
||||
static std::optional<EVMVersion> fromString(std::string const& _version)
|
||||
{
|
||||
for (auto const& v: {homestead(), tangerineWhistle(), spuriousDragon(), byzantium(), constantinople(), petersburg(), istanbul(), berlin()})
|
||||
if (_version == v.name())
|
||||
return v;
|
||||
return {};
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
bool operator==(EVMVersion const& _other) const { return m_version == _other.m_version; }
|
||||
|
||||
@@ -53,8 +53,9 @@
|
||||
#include <liblangutil/Common.h>
|
||||
#include <liblangutil/Exceptions.h>
|
||||
#include <liblangutil/Scanner.h>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <optional>
|
||||
#include <ostream>
|
||||
#include <tuple>
|
||||
|
||||
@@ -187,7 +188,7 @@ bool Scanner::scanHexByte(char& o_scannedByte)
|
||||
return true;
|
||||
}
|
||||
|
||||
boost::optional<unsigned> Scanner::scanUnicode()
|
||||
std::optional<unsigned> Scanner::scanUnicode()
|
||||
{
|
||||
unsigned x = 0;
|
||||
for (int i = 0; i < 4; i++)
|
||||
@@ -718,7 +719,7 @@ bool Scanner::scanEscape()
|
||||
break;
|
||||
case 'u':
|
||||
{
|
||||
if (boost::optional<unsigned> codepoint = scanUnicode())
|
||||
if (auto const codepoint = scanUnicode(); codepoint.has_value())
|
||||
addUnicodeAsUTF8(*codepoint);
|
||||
else
|
||||
return false;
|
||||
|
||||
@@ -57,6 +57,8 @@
|
||||
#include <liblangutil/SourceLocation.h>
|
||||
#include <libdevcore/Common.h>
|
||||
#include <libdevcore/CommonData.h>
|
||||
|
||||
#include <optional>
|
||||
#include <iosfwd>
|
||||
|
||||
namespace langutil
|
||||
@@ -207,7 +209,7 @@ private:
|
||||
inline Token selectToken(char _next, Token _then, Token _else);
|
||||
|
||||
bool scanHexByte(char& o_scannedByte);
|
||||
boost::optional<unsigned> scanUnicode();
|
||||
std::optional<unsigned> scanUnicode();
|
||||
|
||||
/// Scans a single Solidity token.
|
||||
void scanToken();
|
||||
|
||||
Reference in New Issue
Block a user