TempBuffer.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 
9 #include "Utilities/TMPL.hpp"
11 
12 /*!
13  * \ingroup DataStructuresGroup
14  * \brief A TempBuffer holds a set of `Tensor<DataType>`s, where
15  * DataType is either a `DataVector` (or similar type) or a
16  * fundamental type, in a way that minimizes allocations.
17  *
18  * The user gets references to Tensors inside of the TempBuffer using,
19  * e.g., `auto& variable = get<Tag>(temp_buffer)`, where `Tag` is one
20  * of the Tags in the `TagList`.
21  *
22  * If DataType is a DataVector or similar, than TempBuffer is a
23  * Variables. If DataType is a fundamental type, then TempBuffer is a
24  * TaggedTuple.
25  *
26  */
27 template <typename TagList,
28  bool is_fundamental = cpp17::is_fundamental_v<
29  typename tmpl::front<TagList>::type::value_type>>
30 struct TempBuffer;
31 
32 template <typename TagList>
33 struct TempBuffer<TagList, true> : tuples::tagged_tuple_from_typelist<TagList> {
34  explicit TempBuffer(const size_t /*size*/) noexcept
35  : tuples::tagged_tuple_from_typelist<TagList>::TaggedTuple(){}
36 };
37 
38 template <typename TagList>
39 struct TempBuffer<TagList, false> : Variables<TagList> {
40  using Variables<TagList>::Variables;
41 };
Defines class tuples::TaggedTuple.
A TempBuffer holds a set of Tensor<DataType>s, where DataType is either a DataVector (or similar type...
Definition: TempBuffer.hpp:30
Defines class Variables.
Wraps the template metaprogramming library used (brigand)