chromium/third_party/blink/renderer/platform/bindings/transform_view.h

// 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.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_BINDINGS_TRANSFORM_VIEW_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_BINDINGS_TRANSFORM_VIEW_H_

#include <concepts>
#include <iterator>

namespace blink::bindings {

// This is somewhat similar in spirit to std::range::views, but really lean,
// mean and specifically tailored to exposing ranges of blink data to the
// generated bindings where those expect an IDLSequence<>.
// Some limitations include:
// - TransformedView only offers a forward iterator, even if
//     unedrlying collection can offer better iterators;
// - No sentinel support
// - Transform instance is not accepted as an argument or preserved
//     across calls.
// All of these may be re-evaluated if new usages arise.

template <typename Range, typename Transform>
  requires(std::forward_iterator<decltype(std::begin(
               std::declval<const Range&>()))> &&
           std::regular_invocable<Transform,
                                  decltype(*std::begin(
                                      std::declval<const Range&>()))>)
class TransformedView {};

template <typename TransformFunc, typename Range>
auto Transform(const Range& range) {}

}  // namespace blink::bindings

#endif  // THIRD_PARTY_BLINK_RENDERER_PLATFORM_BINDINGS_TRANSFORM_VIEW_H_