gslcpp
Modern-C++ Wrapper for GSL
Public Member Functions | Private Member Functions | Private Attributes | List of all members
gsl::v_stor< T, S > Class Template Reference

Generic v_stor is interface to storage with two key properties: (1) that size of storage is known statically, at compile-time, and (2) that it is owned by instance of v_stor. More...

#include <v-stor.hpp>

Inheritance diagram for gsl::v_stor< T, S >:
[legend]
Collaboration diagram for gsl::v_stor< T, S >:
[legend]

Public Member Functions

 v_stor (size_t n=S)
 Initialize GSL's view of static storage, but do not initialize elements. More...
 
auto * v ()
 Pointer to GSL's interface to vector. More...
 
const auto * v () const
 Pointer to GSL's interface to vector. More...
 

Private Member Functions

 v_stor (v_stor const &)=delete
 Disable copy-construction.
 
v_storoperator= (v_stor const &)=delete
 Disable copy-assignment.
 

Private Attributes

d_ [S]
 Storage for data.
 
w_vector_view< T > cview_
 GSL's view of data.
 

Detailed Description

template<typename T, size_t S = 0>
class gsl::v_stor< T, S >

Generic v_stor is interface to storage with two key properties: (1) that size of storage is known statically, at compile-time, and (2) that it is owned by instance of v_stor.

Specialization gsl::v_stor<T,0> is for storage-size determined at run-time.

Template Parameters
TType of each element in vector.
SCompile-time size of vector (0 for size specified at run-time).

Definition at line 22 of file v-stor.hpp.

Constructor & Destructor Documentation

◆ v_stor()

template<typename T , size_t S = 0>
gsl::v_stor< T, S >::v_stor ( size_t  n = S)
inline

Initialize GSL's view of static storage, but do not initialize elements.

If number n of elements intended for vector be not S, then throw.

Parameters
nNumber of elements intended for vector.

Definition at line 35 of file v-stor.hpp.

35  : cview_(w_vector_view_array(d_, 1, S)) {
36  if(n != S) throw "mismatch in size";
37  }

Member Function Documentation

◆ v() [1/2]

template<typename T , size_t S = 0>
auto* gsl::v_stor< T, S >::v ( )
inline

Pointer to GSL's interface to vector.

Returns
Pointer to GSL's interface to vector.

Definition at line 41 of file v-stor.hpp.

41 { return &cview_.vector; }

◆ v() [2/2]

template<typename T , size_t S = 0>
const auto* gsl::v_stor< T, S >::v ( ) const
inline

Pointer to GSL's interface to vector.

Returns
Pointer to GSL's interface to immutable vector.

Definition at line 45 of file v-stor.hpp.

45 { return &cview_.vector; }

The documentation for this class was generated from the following file:
gsl::v_stor::d_
T d_[S]
Storage for data.
Definition: v-stor.hpp:23
gsl::v_stor::cview_
w_vector_view< T > cview_
GSL's view of data.
Definition: v-stor.hpp:26
gsl::w_vector_view_array
auto w_vector_view_array(double *b, size_t s, size_t n)
Initialize view of C-style array as vector.
Definition: vector-view-array.hpp:17