chromium/third_party/skia/include/private/base/SkAnySubclass.h

/*
 * Copyright 2023 Google LLC
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkAnySubclass_DEFINED
#define SkAnySubclass_DEFINED

#include "include/private/base/SkAssert.h"

#include <cstddef>
#include <new>
#include <type_traits>  // IWYU pragma: keep
#include <utility>

/**
 *  Stores any subclass `T` of `Base`, where sizeof(T) <= `Size`, without using the heap.
 *  Doesn't need advance knowledge of T, so it's particularly suited to platform or backend
 *  implementations of a generic interface, where the set of possible subclasses is finite and
 *  known, but can't be made available at compile-time.
 */
template <typename Base, size_t Size>
class SkAnySubclass {};

#endif  // SkAnySubclass_DEFINED