Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Factory:Rebuild
nodejs-electron
chromium-122-avoid-SFINAE-TypeConverter.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File chromium-122-avoid-SFINAE-TypeConverter.patch of Package nodejs-electron
diff --git a/base/types/to_address.h.new b/base/types/to_address.h.new new file mode 100644 index 0000000..ac71b01 --- /dev/null +++ b/base/types/to_address.h @@ -0,0 +1,40 @@ +// Copyright 2024 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BASE_TYPES_TO_ADDRESS_H_ +#define BASE_TYPES_TO_ADDRESS_H_ + +#include <memory> +#include <type_traits> + +// SFINAE-compatible wrapper for `std::to_address()`. +// +// The standard does not require `std::to_address()` to be SFINAE-compatible +// when code attempts instantiation with non-pointer-like types, and libstdc++'s +// implementation hard errors. For the sake of templated code that wants simple, +// unified handling, Chromium instead uses this wrapper, which provides that +// guarantee. This allows code to use "`to_address()` would be valid here" as a +// constraint to detect pointer-like types. +namespace base { + +// Note that calling `std::to_address()` with a function pointer renders the +// program ill-formed. +template <typename T> + requires(!std::is_function_v<T>) +constexpr T* to_address(T* p) noexcept { + return p; +} + +// These constraints cover the cases where `std::to_address()`'s fancy pointer +// overload is well-specified. +template <typename P> + requires requires(const P& p) { std::pointer_traits<P>::to_address(p); } || + requires(const P& p) { p.operator->(); } +constexpr auto to_address(const P& p) noexcept { + return std::to_address(p); +} + +} // namespace base + +#endif // BASE_TYPES_TO_ADDRESS_H_ diff --git a/mojo/public/cpp/bindings/type_converter.h b/mojo/public/cpp/bindings/type_converter.h.new index 2eddbb0..317245f 100644 --- a/mojo/public/cpp/bindings/type_converter.h +++ b/mojo/public/cpp/bindings/type_converter.h @@ -11,6 +11,8 @@ #include <memory> #include <type_traits> +#include "base/types/to_address.h" + namespace mojo { // NOTE: When possible, please consider using StructTraits / UnionTraits / @@ -99,16 +99,16 @@ template <typename T, typename U> requires requires(const U& obj) { - not std::is_pointer_v<U>; - { mojo::ConvertTo<T>(std::to_address(obj)) } -> std::same_as<T>; + !std::is_pointer_v<U>; + { mojo::ConvertTo<T>(base::to_address(obj)) } -> std::same_as<T>; } inline T ConvertTo(const U& obj) { - return mojo::ConvertTo<T>(std::to_address(obj)); + return mojo::ConvertTo<T>(base::to_address(obj)); } template <typename T, typename U> requires requires(const U& obj) { - not std::is_pointer_v<U>; + !std::is_pointer_v<U>; TypeConverter<T, U>::Convert(obj); } inline T ConvertTo(const U& obj) {
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor