MGIS 3.1.0
Loading...
Searching...
No Matches
Buffer.hxx File Reference

Definition of the mgis::function::Buffer type, a container used to store the values of a function, and of the makeSpan helper functions, which build a std::span viewing the content of such a buffer. More...

#include <span>
#include <array>
#include <vector>
#include <type_traits>
#include <MGIS/Config.hxx>

Namespaces

namespace  mgis
 the namespace mgis encloses all the MGIS project.

Typedefs

template<size_type Extent = dynamic_extent>
using mgis::function::Buffer
 type used to store the values of a function

Functions

template<std::size_t Extent>
auto mgis::function::makeSpan (const std::array< real, Extent > &b) MGIS_NOEXCEPT
 returns a span viewing the values stored in a fixed size buffer
auto mgis::function::makeSpan (const std::vector< real > &b) MGIS_NOEXCEPT
 returns a span viewing the values stored in a buffer of dynamic size

Detailed Description

Definition of the mgis::function::Buffer type, a container used to store the values of a function, and of the makeSpan helper functions, which build a std::span viewing the content of such a buffer.

Author
Thomas Helfer
Date
30/04/2025

Typedef Documentation

◆ Buffer

template<size_type Extent = dynamic_extent>
using mgis::function::Buffer
Initial value:
std::conditional_t<Extent == dynamic_extent,
std::vector<real>,
std::array<real, static_cast<std::size_t>(Extent)>>
constexpr size_type dynamic_extent
a constant whose role is similar to std::dynamic_extent
Definition Config.hxx:143

type used to store the values of a function

A buffer of dynamic size is a std::vector<real>, whereas a buffer whose size is known at compile time is a std::array<real, Extent>, which avoids a dynamic allocation.

Template Parameters
Extentnumber of values stored in the buffer, dynamic_extent if the size of the buffer is only known at run time

Function Documentation

◆ makeSpan() [1/2]

template<std::size_t Extent>
auto mgis::function::makeSpan ( const std::array< real, Extent > & b)

returns a span viewing the values stored in a fixed size buffer

Template Parameters
Extentsize of the buffer
Parameters
[in]bbuffer
Returns
a std::span viewing the values of the buffer
Note
the extent of the returned span is only known at run time if Extent is std::dynamic_extent

◆ makeSpan() [2/2]

auto mgis::function::makeSpan ( const std::vector< real > & b)
inline

returns a span viewing the values stored in a buffer of dynamic size

Parameters
[in]bbuffer
Returns
a std::span viewing the values of the buffer