26 lines · c
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-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef LIBCPP_TEST_STD_UTILITIES_MEMORY_SPECIALIZED_ALGORITHMS_BUFFER_H11#define LIBCPP_TEST_STD_UTILITIES_MEMORY_SPECIALIZED_ALGORITHMS_BUFFER_H12 13template <typename T, int N>14struct Buffer {15 alignas(T) char buffer[sizeof(T) * N] = {};16 17 T* begin() { return reinterpret_cast<T*>(buffer); }18 T* end() { return begin() + N; }19 const T* cbegin() const { return reinterpret_cast<const T*>(buffer); }20 const T* cend() const { return cbegin() + N; }21 22 constexpr int size() const { return N; }23};24 25#endif // LIBCPP_TEST_STD_UTILITIES_MEMORY_SPECIALIZED_ALGORITHMS_BUFFER_H26