Merge pull request #9644 from ethereum/msvc-adl-fix

Fixes compilation with MSVC.
This commit is contained in:
chriseth 2020-08-19 14:47:57 +02:00 committed by GitHub
commit 9e488f12fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,7 +37,10 @@
#include <utility>
#include <type_traits>
/// Operators need to stay in the global namespace.
namespace std
{
/// Operator overloads for STL containers should be in std namespace for ADL to work properly.
/// Concatenate the contents of a container onto a vector
template <class T, class U> std::vector<T>& operator+=(std::vector<T>& _a, U& _b)
@ -78,6 +81,7 @@ template <class U, class... T> std::set<T...>& operator+=(std::set<T...>& _a, U&
_a.insert(std::move(x));
return _a;
}
/// Concatenate two vectors of elements.
template <class T>
inline std::vector<T> operator+(std::vector<T> const& _a, std::vector<T> const& _b)
@ -86,6 +90,7 @@ inline std::vector<T> operator+(std::vector<T> const& _a, std::vector<T> const&
ret += _b;
return ret;
}
/// Concatenate two vectors of elements, moving them.
template <class T>
inline std::vector<T> operator+(std::vector<T>&& _a, std::vector<T>&& _b)
@ -97,6 +102,7 @@ inline std::vector<T> operator+(std::vector<T>&& _a, std::vector<T>&& _b)
ret += std::move(_b);
return ret;
}
/// Concatenate something to a sets of elements.
template <class T, class U>
inline std::set<T> operator+(std::set<T> const& _a, U&& _b)
@ -105,6 +111,7 @@ inline std::set<T> operator+(std::set<T> const& _a, U&& _b)
ret += std::forward<U>(_b);
return ret;
}
/// Concatenate something to a sets of elements, move variant.
template <class T, class U>
inline std::set<T> operator+(std::set<T>&& _a, U&& _b)
@ -140,6 +147,8 @@ inline std::multiset<T...>& operator-=(std::multiset<T...>& _a, C const& _b)
return _a;
}
} // end namespace std
namespace solidity::util
{