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:
@@ -36,6 +36,7 @@
|
||||
#include <json/json.h>
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -912,10 +913,10 @@ public:
|
||||
ElementaryTypeName(
|
||||
SourceLocation const& _location,
|
||||
ElementaryTypeNameToken const& _elem,
|
||||
boost::optional<StateMutability> _stateMutability = {}
|
||||
std::optional<StateMutability> _stateMutability = {}
|
||||
): TypeName(_location), m_type(_elem), m_stateMutability(_stateMutability)
|
||||
{
|
||||
solAssert(!_stateMutability.is_initialized() || _elem.token() == Token::Address, "");
|
||||
solAssert(!_stateMutability.has_value() || _elem.token() == Token::Address, "");
|
||||
}
|
||||
|
||||
void accept(ASTVisitor& _visitor) override;
|
||||
@@ -923,11 +924,11 @@ public:
|
||||
|
||||
ElementaryTypeNameToken const& typeName() const { return m_type; }
|
||||
|
||||
boost::optional<StateMutability> const& stateMutability() const { return m_stateMutability; }
|
||||
std::optional<StateMutability> const& stateMutability() const { return m_stateMutability; }
|
||||
|
||||
private:
|
||||
ElementaryTypeNameToken m_type;
|
||||
boost::optional<StateMutability> m_stateMutability; ///< state mutability for address type
|
||||
std::optional<StateMutability> m_stateMutability; ///< state mutability for address type
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,10 +26,9 @@
|
||||
#include <libsolidity/ast/ASTEnums.h>
|
||||
#include <libsolidity/ast/ExperimentalFeatures.h>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
@@ -183,7 +182,7 @@ struct ExpressionAnnotation: ASTAnnotation
|
||||
|
||||
/// Types and - if given - names of arguments if the expr. is a function
|
||||
/// that is called, used for overload resoultion
|
||||
boost::optional<FuncCallArguments> arguments;
|
||||
std::optional<FuncCallArguments> arguments;
|
||||
};
|
||||
|
||||
struct IdentifierAnnotation: ExpressionAnnotation
|
||||
|
||||
@@ -148,7 +148,7 @@ Json::Value ASTJsonConverter::typePointerToJson(TypePointer _tp, bool _short)
|
||||
return typeDescriptions;
|
||||
|
||||
}
|
||||
Json::Value ASTJsonConverter::typePointerToJson(boost::optional<FuncCallArguments> const& _tps)
|
||||
Json::Value ASTJsonConverter::typePointerToJson(std::optional<FuncCallArguments> const& _tps)
|
||||
{
|
||||
if (_tps)
|
||||
{
|
||||
|
||||
@@ -27,10 +27,12 @@
|
||||
#include <liblangutil/Exceptions.h>
|
||||
|
||||
#include <json/json.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <optional>
|
||||
#include <ostream>
|
||||
#include <stack>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
namespace langutil
|
||||
{
|
||||
@@ -169,7 +171,7 @@ private:
|
||||
return json;
|
||||
}
|
||||
static Json::Value typePointerToJson(TypePointer _tp, bool _short = false);
|
||||
static Json::Value typePointerToJson(boost::optional<FuncCallArguments> const& _tps);
|
||||
static Json::Value typePointerToJson(std::optional<FuncCallArguments> const& _tps);
|
||||
void appendExpressionAttributes(
|
||||
std::vector<std::pair<std::string, Json::Value>> &_attributes,
|
||||
ExpressionAnnotation const& _annotation
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <array>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
|
||||
namespace dev
|
||||
|
||||
@@ -1812,10 +1812,10 @@ TypePointer ArrayType::decodingType() const
|
||||
|
||||
TypeResult ArrayType::interfaceType(bool _inLibrary) const
|
||||
{
|
||||
if (_inLibrary && m_interfaceType_library.is_initialized())
|
||||
if (_inLibrary && m_interfaceType_library.has_value())
|
||||
return *m_interfaceType_library;
|
||||
|
||||
if (!_inLibrary && m_interfaceType.is_initialized())
|
||||
if (!_inLibrary && m_interfaceType.has_value())
|
||||
return *m_interfaceType;
|
||||
|
||||
TypeResult result{TypePointer{}};
|
||||
@@ -2106,10 +2106,10 @@ MemberList::MemberMap StructType::nativeMembers(ContractDefinition const*) const
|
||||
|
||||
TypeResult StructType::interfaceType(bool _inLibrary) const
|
||||
{
|
||||
if (_inLibrary && m_interfaceType_library.is_initialized())
|
||||
if (_inLibrary && m_interfaceType_library.has_value())
|
||||
return *m_interfaceType_library;
|
||||
|
||||
if (!_inLibrary && m_interfaceType.is_initialized())
|
||||
if (!_inLibrary && m_interfaceType.has_value())
|
||||
return *m_interfaceType;
|
||||
|
||||
TypeResult result{TypePointer{}};
|
||||
@@ -2166,7 +2166,7 @@ TypeResult StructType::interfaceType(bool _inLibrary) const
|
||||
}
|
||||
};
|
||||
|
||||
m_recursive = m_recursive.get() || (CycleDetector<StructDefinition>(visitor).run(structDefinition()) != nullptr);
|
||||
m_recursive = m_recursive.value() || (CycleDetector<StructDefinition>(visitor).run(structDefinition()) != nullptr);
|
||||
|
||||
std::string const recursiveErrMsg = "Recursive type not allowed for public or external contract functions.";
|
||||
|
||||
@@ -2179,13 +2179,13 @@ TypeResult StructType::interfaceType(bool _inLibrary) const
|
||||
else
|
||||
m_interfaceType_library = TypeProvider::withLocation(this, DataLocation::Memory, true);
|
||||
|
||||
if (m_recursive.get())
|
||||
if (m_recursive.value())
|
||||
m_interfaceType = TypeResult::err(recursiveErrMsg);
|
||||
|
||||
return *m_interfaceType_library;
|
||||
}
|
||||
|
||||
if (m_recursive.get())
|
||||
if (m_recursive.value())
|
||||
m_interfaceType = TypeResult::err(recursiveErrMsg);
|
||||
else if (!result.message().empty())
|
||||
m_interfaceType = result;
|
||||
|
||||
@@ -31,11 +31,11 @@
|
||||
#include <libdevcore/CommonIO.h>
|
||||
#include <libdevcore/Result.h>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/rational.hpp>
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
@@ -769,8 +769,8 @@ private:
|
||||
Type const* m_baseType;
|
||||
bool m_hasDynamicLength = true;
|
||||
u256 m_length;
|
||||
mutable boost::optional<TypeResult> m_interfaceType;
|
||||
mutable boost::optional<TypeResult> m_interfaceType_library;
|
||||
mutable std::optional<TypeResult> m_interfaceType;
|
||||
mutable std::optional<TypeResult> m_interfaceType_library;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -865,12 +865,12 @@ public:
|
||||
|
||||
bool recursive() const
|
||||
{
|
||||
if (m_recursive.is_initialized())
|
||||
return m_recursive.get();
|
||||
if (m_recursive.has_value())
|
||||
return m_recursive.value();
|
||||
|
||||
interfaceType(false);
|
||||
|
||||
return m_recursive.get();
|
||||
return m_recursive.value();
|
||||
}
|
||||
|
||||
std::unique_ptr<ReferenceType> copyForLocation(DataLocation _location, bool _isPointer) const override;
|
||||
@@ -898,9 +898,9 @@ public:
|
||||
private:
|
||||
StructDefinition const& m_struct;
|
||||
// Caches for interfaceType(bool)
|
||||
mutable boost::optional<TypeResult> m_interfaceType;
|
||||
mutable boost::optional<TypeResult> m_interfaceType_library;
|
||||
mutable boost::optional<bool> m_recursive;
|
||||
mutable std::optional<TypeResult> m_interfaceType;
|
||||
mutable std::optional<TypeResult> m_interfaceType_library;
|
||||
mutable std::optional<bool> m_recursive;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user