# HG changeset patch # User Bob Owen Minor reversions for changes that require c++20 support. diff --git a/base/check_op.h b/base/check_op.h --- a/base/check_op.h +++ b/base/check_op.h @@ -65,17 +65,17 @@ BASE_EXPORT char* StreamValToStr(const v #ifdef __has_builtin #define SUPPORTS_BUILTIN_ADDRESSOF (__has_builtin(__builtin_addressof)) #else #define SUPPORTS_BUILTIN_ADDRESSOF 0 #endif template inline std::enable_if_t< - base::internal::SupportsOstreamOperator && + base::internal::SupportsOstreamOperator::value && !std::is_function_v::type>, char*> CheckOpValueStr(const T& v) { auto f = [](std::ostream& s, const void* p) { s << *reinterpret_cast(p); }; // operator& might be overloaded, so do the std::addressof dance. @@ -90,18 +90,19 @@ CheckOpValueStr(const T& v) { #endif return StreamValToStr(vp, f); } #undef SUPPORTS_BUILTIN_ADDRESSOF // Overload for types that have no operator<< but do have .ToString() defined. template -inline std::enable_if_t && - base::internal::SupportsToString, +inline std::enable_if_t< + !base::internal::SupportsOstreamOperator::value && + base::internal::SupportsToString::value, char*> CheckOpValueStr(const T& v) { // .ToString() may not return a std::string, e.g. blink::WTF::String. return CheckOpValueStr(v.ToString()); } // Provide an overload for functions and function pointers. Function pointers // don't implicitly convert to void* but do implicitly convert to bool, so @@ -114,18 +115,19 @@ inline std::enable_if_t< char*> CheckOpValueStr(const T& v) { return CheckOpValueStr(reinterpret_cast(v)); } // We need overloads for enums that don't support operator<<. // (i.e. scoped enums where no operator<< overload was declared). template -inline std::enable_if_t && - std::is_enum_v, +inline std::enable_if_t< + !base::internal::SupportsOstreamOperator::value && + std::is_enum_v, char*> CheckOpValueStr(const T& v) { return CheckOpValueStr( static_cast::type>(v)); } // Takes ownership of `v1_str` and `v2_str`, destroying them with free(). For // use with CheckOpValueStr() which allocates these strings using strdup(). diff --git a/base/containers/contiguous_iterator.h b/base/containers/contiguous_iterator.h --- a/base/containers/contiguous_iterator.h +++ b/base/containers/contiguous_iterator.h @@ -38,17 +38,19 @@ struct IsStringIterImpl // // Note: Requires indirection via `IsStringIterImpl` to avoid triggering a // `static_assert(is_trivial_v)` inside libc++'s std::basic_string. template struct IsStringIter : std::conjunction< std::disjunction, char>, std::is_same, wchar_t>, +#if !defined(MOZ_SANDBOX) std::is_same, char8_t>, +#endif std::is_same, char16_t>, std::is_same, char32_t>>, IsStringIterImpl> {}; // An iterator to std::array is contiguous. // Reference: https://wg21.link/array.overview#1 template , 1>> struct IsArrayIter diff --git a/base/strings/to_string.h b/base/strings/to_string.h --- a/base/strings/to_string.h +++ b/base/strings/to_string.h @@ -18,18 +18,21 @@ namespace base { template std::string ToString(const Ts&... values); namespace internal { +template +struct SupportsToString : std::false_type {}; template -concept SupportsToString = requires(const T& t) { t.ToString(); }; +struct SupportsToString().ToString()))> + : std::true_type {}; // I/O manipulators are function pointers, but should be sent directly to the // `ostream` instead of being cast to `const void*` like other function // pointers. template constexpr bool IsIomanip = false; template constexpr bool @@ -51,50 +54,50 @@ template struct ToStringHelper { static void Stringify(const T& v, std::ostringstream& ss) { ss << "[" << sizeof(v) << "-byte object at 0x" << std::addressof(v) << "]"; } }; // Most streamables. template -struct ToStringHelper && - !WillBeIncorrectlyStreamedAsBool>> { +struct ToStringHelper< + T, std::enable_if_t::value && + !WillBeIncorrectlyStreamedAsBool>> { static void Stringify(const T& v, std::ostringstream& ss) { ss << v; } }; // Functions and function pointers. template -struct ToStringHelper && - WillBeIncorrectlyStreamedAsBool>> { +struct ToStringHelper< + T, std::enable_if_t::value && + WillBeIncorrectlyStreamedAsBool>> { static void Stringify(const T& v, std::ostringstream& ss) { ToStringHelper::Stringify(reinterpret_cast(v), ss); } }; // Non-streamables that have a `ToString` member. template -struct ToStringHelper && - SupportsToString>> { +struct ToStringHelper< + T, std::enable_if_t::value && + SupportsToString::value>> { static void Stringify(const T& v, std::ostringstream& ss) { // .ToString() may not return a std::string, e.g. blink::WTF::String. ToStringHelper::Stringify(v.ToString(), ss); } }; // Non-streamable enums (i.e. scoped enums where no `operator<<` overload was // declared). template struct ToStringHelper< - T, - std::enable_if_t && std::is_enum_v>> { + T, std::enable_if_t::value && + std::is_enum_v>> { static void Stringify(const T& v, std::ostringstream& ss) { using UT = typename std::underlying_type_t; ToStringHelper::Stringify(static_cast(v), ss); } }; // Tuples. Will recursively apply `ToString()` to each value in the tuple. template diff --git a/base/types/strong_alias.h b/base/types/strong_alias.h --- a/base/types/strong_alias.h +++ b/base/types/strong_alias.h @@ -149,17 +149,17 @@ class StrongAlias { protected: UnderlyingType value_; }; // Stream operator for convenience, streams the UnderlyingType. template >> + internal::SupportsOstreamOperator::value>> std::ostream& operator<<(std::ostream& stream, const StrongAlias& alias) { return stream << alias.value(); } } // namespace base #endif // BASE_TYPES_STRONG_ALIAS_H_ diff --git a/sandbox/win/src/sandbox_policy_base.cc b/sandbox/win/src/sandbox_policy_base.cc --- a/sandbox/win/src/sandbox_policy_base.cc +++ b/sandbox/win/src/sandbox_policy_base.cc @@ -805,12 +805,12 @@ absl::optional return absl::nullopt; } void PolicyBase::AddDelegateData(base::span data) { CHECK(data.size() > 0u); // Can only set this once - as there is only one region sent to the child. CHECK(!delegate_data_); delegate_data_ = - std::make_unique>(data.begin(), data.end()); + std::make_unique>(data.begin(), data.end()); } } // namespace sandbox diff --git a/sandbox/win/src/sandbox_policy_base.h b/sandbox/win/src/sandbox_policy_base.h --- a/sandbox/win/src/sandbox_policy_base.h +++ b/sandbox/win/src/sandbox_policy_base.h @@ -248,17 +248,17 @@ class PolicyBase final : public TargetPo // Returns nullopt if no data has been set, or a view into the data. absl::optional> delegate_data_span(); // The user-defined global policy settings. HANDLE stdout_handle_; HANDLE stderr_handle_; // An opaque blob of data the delegate uses to prime any pre-sandbox hooks. - std::unique_ptr> delegate_data_; + std::unique_ptr> delegate_data_; std::unique_ptr dispatcher_; // Contains the list of handles being shared with the target process. // This list contains handles other than the stderr/stdout handles which are // shared with the target at times. base::HandlesToInheritVector handles_to_share_; Job job_;