Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <cstddef> 7 : 8 : #include "DataStructures/Variables.hpp" 9 : #include "Utilities/TMPL.hpp" 10 : #include "Utilities/TaggedTuple.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 = std::is_fundamental_v< 29 : typename tmpl::front<TagList>::type::value_type>> 30 1 : struct TempBuffer; 31 : 32 : template <typename TagList> 33 0 : struct TempBuffer<TagList, true> : tuples::tagged_tuple_from_typelist<TagList> { 34 0 : explicit TempBuffer(const size_t /*size*/) 35 : : tuples::tagged_tuple_from_typelist<TagList>::TaggedTuple() {} 36 : }; 37 : 38 : template <typename TagList> 39 0 : struct TempBuffer<TagList, false> : Variables<TagList> { 40 : using Variables<TagList>::Variables; 41 : };