Debian Codegraph @

include/private/base/SkAlignedStorage.h

raw
1 // Copyright 2022 Google LLC
2 // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3
4 #ifndef SkAlignedStorage_DEFINED
5 #define SkAlignedStorage_DEFINED
6
7 #include <cstddef>
8 #include <iterator>
9
10 template <int N, typename T> class SkAlignedSTStorage {
11 public:
12 SkAlignedSTStorage() {}
13 SkAlignedSTStorage(SkAlignedSTStorage&&) = delete;
14 SkAlignedSTStorage(const SkAlignedSTStorage&) = delete;
15 SkAlignedSTStorage& operator=(SkAlignedSTStorage&&) = delete;
16 SkAlignedSTStorage& operator=(const SkAlignedSTStorage&) = delete;
17
18 // Returns void* because this object does not initialize the
19 // memory. Use placement new for types that require a constructor.
20 void* get() { return fStorage; }
21 const void* get() const { return fStorage; }
22
23 // Act as a container of bytes because the storage is uninitialized.
24 std::byte* data() { return fStorage; }
25 const std::byte* data() const { return fStorage; }
26 size_t size() const { return std::size(fStorage); }
27
28 private:
29 alignas(T) std::byte fStorage[sizeof(T) * N];
30 };
31
32 #endif // SkAlignedStorage_DEFINED