[jumbo] Mark Span and Input as satisfying view and borrowed_range.

These concepts are appropriate for these types, and we also enable them
for e.g. base::span.

This is necessary for Chromium to annotate more base::span constructors
with LIFETIMEBOUND without producing false positive warnings with these
types. It only has an effect under C++20 (but should preprocess away to
nothing on older C++ versions).

Bug: none
Change-Id: Ib2b8cba4b7bd2d5028ce27de4fd9c44fca7d5560
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/70068
Reviewed-by: David Benjamin <davidben@google.com>
Auto-Submit: Peter Kasting <pkasting@google.com>
This commit is contained in:
Peter Kasting
2024-08-10 13:56:24 +00:00
committed by Adam Langley
parent aaf59e8d8d
commit 11f334121f
2 changed files with 44 additions and 0 deletions
+22
View File
@@ -30,6 +30,28 @@ extern "C++" {
#include <string_view>
#endif
#if defined(__has_include)
#if __has_include(<version>)
#include <version>
#endif
#endif
#if defined(__cpp_lib_ranges) && __cpp_lib_ranges >= 201911L
#include <ranges>
BSSL_NAMESPACE_BEGIN
template <typename T>
class Span;
BSSL_NAMESPACE_END
// Mark `Span` as satisfying the `view` and `borrowed_range` concepts. This
// should be done before the definition of `Span`, so that any inlined calls to
// range functionality use the correct specializations.
template <typename T>
inline constexpr bool std::ranges::enable_view<bssl::Span<T>> = true;
template <typename T>
inline constexpr bool std::ranges::enable_borrowed_range<bssl::Span<T>> = true;
#endif
BSSL_NAMESPACE_BEGIN
template <typename T>
+22
View File
@@ -14,6 +14,28 @@
#include <openssl/base.h>
#include <openssl/span.h>
#if defined(__has_include)
#if __has_include(<version>)
#include <version>
#endif
#endif
#if defined(__cpp_lib_ranges) && __cpp_lib_ranges >= 201911L
#include <ranges>
namespace bssl::der {
class OPENSSL_EXPORT Input;
}
// Mark `Input` as satisfying the `view` and `borrowed_range` concepts. This
// should be done before the definition of `Input`, so that any inlined calls to
// range functionality use the correct specializations.
template <>
inline constexpr bool std::ranges::enable_view<bssl::der::Input> = true;
template <>
inline constexpr bool std::ranges::enable_borrowed_range<bssl::der::Input> =
true;
#endif
namespace bssl::der {
// An opaque class that represents a fixed buffer of data of a fixed length,