xref: /llvm-project/libcxx/test/std/utilities/memory/specialized.algorithms/buffer.h (revision 754ea6fd4d52f4699644a3c6dfc854a231c881c4)
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LIBCPP_TEST_STD_UTILITIES_MEMORY_SPECIALIZED_ALGORITHMS_BUFFER_H
11 #define LIBCPP_TEST_STD_UTILITIES_MEMORY_SPECIALIZED_ALGORITHMS_BUFFER_H
12 
13 template <typename T, int N>
14 struct Buffer {
15   alignas(T) char buffer[sizeof(T) * N] = {};
16 
beginBuffer17   T* begin() { return reinterpret_cast<T*>(buffer); }
endBuffer18   T* end() { return begin() + N; }
cbeginBuffer19   const T* cbegin() const { return reinterpret_cast<const T*>(buffer); }
cendBuffer20   const T* cend() const { return cbegin() + N; }
21 
sizeBuffer22   constexpr int size() const { return N; }
23 };
24 
25 #endif // LIBCPP_TEST_STD_UTILITIES_MEMORY_SPECIALIZED_ALGORITHMS_BUFFER_H
26