|
| vector (vector const &src) |
| Copy data from other vector of same type. More...
|
|
| vector (vector &&)=default |
| Enable move-constructor in gsl::v_stor to work.
|
|
vector & | operator= (vector const &)=default |
| Enable explicitly defined copy-constructor in gsl::v_iface. More...
|
|
template<size_t N, template< typename, size_t > class V, typename = enable_if_t<sz_ok<N>::V && !is_const_v<T>>> |
| vector (v_iface< T const, N, V > const &src) |
| Copy data from vector of different type (different element-constness, different compile-time number of elements, or different storage-interface). More...
|
|
template<size_t N, template< typename, size_t > class V, typename = enable_if_t<sz_ok<N>::V>> |
| vector (v_iface< T, N, V > const &src) |
| Copy data from vector of different type (different compile-time number of elements or different storage-interface). More...
|
|
| vector (T const *d, size_t n, size_t s=1) |
| Copy from standard (decayed) C-array. More...
|
|
| vector (T const (&d)[S]) |
| Copy from non-decayed C-array. More...
|
|
| vector (std::initializer_list< T > i) |
| Copy from initializer-list. More...
|
|
iterator | begin () |
| Iterator that points to first element. More...
|
|
const_iterator | begin () const |
| Iterator that points to first element. More...
|
|
iterator | end () |
| Iterator that points to element just past last element. More...
|
|
const_iterator | end () const |
| Iterator that points to element just past last element. More...
|
|
size_t | size () const |
| Size of vector. More...
|
|
T * | data () |
| Pointer to first element in vector. More...
|
|
const T * | data () const |
| Pointer to first element in immutable vector. More...
|
|
T | get (size_t i) const |
| Read element with bounds-checking. More...
|
|
void | set (size_t i, T const &x) |
| Write element with bounds-checking. More...
|
|
const T & | operator[] (size_t i) const |
| Read element without bounds-checking. More...
|
|
T & | operator[] (size_t i) |
| Write element without bounds-checking. More...
|
|
T * | ptr (size_t i) |
| Retrieve pointer to i th element with bounds-checking. More...
|
|
const T * | ptr (size_t i) const |
| Retrieve pointer to i th element with bounds-checking. More...
|
|
void | set_all (T const &x) |
| Set every element. More...
|
|
void | set_zero () |
| Set every element to zero.
|
|
int | set_basis (size_t i) |
| Set element at offset i to unity and every other element to zero. More...
|
|
int | fwrite (FILE *f) const |
| Write non-portable binary-image of vector to file. More...
|
|
int | fread (FILE *f) |
| Read non-portable binary-image of vector from file. More...
|
|
int | fprintf (FILE *flp, char const *fmt) const |
| Write ASCII-formatted representation of vector to file. More...
|
|
int | fscanf (FILE *f) |
| Read ASCII-formatted representation of vector from file. More...
|
|
v_iface< element_t< T >, N, v_view > | real () |
| View of real-part of complex vector. More...
|
|
v_iface< element_t< T > const, N, v_view > | real () const |
| View of real-part of complex vector. More...
|
|
v_iface< element_t< T >, N, v_view > | imag () |
| View of imaginary-part of complex vector. More...
|
|
v_iface< element_t< T > const, N, v_view > | imag () const |
| View of imaginary-part of complex vector. More...
|
|
v_iface< T, N, v_view > | subvector (size_t n, size_t i=0, size_t s=1) |
| View of subvector of vector. More...
|
|
v_iface< T const, N, v_view > | subvector (size_t n, size_t i=0, size_t s=1) const |
| View of subvector of vector. More...
|
|
v_iface< T, N, v_view > | view () |
| View of vector. More...
|
|
v_iface< T const, N, v_view > | view () const |
| View of vector. More...
|
|
int | swap_elements (size_t i, size_t j) |
| Swap elements within this vector. More...
|
|
int | reverse () |
| Reverse order of elements. More...
|
|
int | add (v_iface< T, ON, OV > const &b) |
| Add contents of b into this vector in place. More...
|
|
int | sub (v_iface< T, ON, OV > const &b) |
| Subtract contents of b from this vector in place. More...
|
|
int | mul (v_iface< T, ON, OV > const &b) |
| Multiply contents of b into this vector in place. More...
|
|
int | div (v_iface< T, ON, OV > const &b) |
| Divide contents of b into this vector in place. More...
|
|
v_iface & | operator+= (v_iface< T, ON, OV > const &b) |
| Add contents of b into this vector in place. More...
|
|
v_iface & | operator+= (T const &x) |
| Add constant into each element of this vector in place. More...
|
|
v_iface & | operator-= (v_iface< T, ON, OV > const &b) |
| Subtract contents of b from this vector in place. More...
|
|
v_iface & | operator*= (v_iface< T, ON, OV > const &b) |
| Multiply contents of b into this vector in place. More...
|
|
v_iface & | operator*= (T const &x) |
| Multiply scalar into this vector in place. More...
|
|
v_iface & | operator/= (v_iface< T, ON, OV > const &b) |
| Divide contents of b into this vector in place. More...
|
|
v_iface & | operator= (v_iface< T, ON, OV > const &b) |
| Copy contents of b into this vector. More...
|
|
v_iface & | operator= (v_iface const &b) |
| Copy contents of b into this vector. More...
|
|
| v_iface (v_iface &&)=default |
| Enable move-constructor in gsl::v_stor to work.
|
|
int | scale (T const &x) |
| Multiply scalar into this vector in place. More...
|
|
int | add_constant (T const &x) |
| Add constant into each element of this vector in place. More...
|
|
T | sum () const |
| Sum of elements. More...
|
|
T | max () const |
| Greatest value of any element. More...
|
|
T | min () const |
| Least value of any element. More...
|
|
void | minmax (T &min, T &max) const |
| Greatest value and least value of any element. More...
|
|
size_t | max_index () const |
| Offset of greatest value. More...
|
|
size_t | min_index () const |
| Offset of least value. More...
|
|
void | minmax_index (size_t &imin, size_t &imax) const |
| Offset of least value and offset of greatest value. More...
|
|
bool | isnull () const |
| True only if every element have zero value. More...
|
|
bool | ispos () const |
| True only if every element be positive. More...
|
|
bool | isneg () const |
| True only if every element be negative. More...
|
|
bool | isnonneg () const |
| True only if every element be non-negative. More...
|
|
| 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...
|
|
template<typename T, size_t S = 0>
struct gsl::vector< T, S >
Constructor-type for vector whose storage is owned by instance of vector.
vector has its interface to storage given by gsl::v_stor, and most of the ordinary vector-interface is given by gsl::v_iface.
vector inherits these and provides template-constructors for an instance of type gsl::v_iface<T, S, v_stor>.
Each constructor copies data from the source or (in the case of the move-constructor, when both the source is an r-value with S = 0
, and the destination has S = 0
) moves the data into the instance.
Template-value-parameter S
indicates the number of elements in the vector at compile-time. If S
be zero, then the number of elements in the vector is determined at run-time.
Although move-construction is provided, move-assignment is not provided. Once a chunk of memory is allocated to a vector, that same chunk, and only ever that chunk, is associated with the vector until it is destroyed.
When using vector, one typically does not need to specify template-parameters:
int main() {
double g[]= {1, 2, 3, 4, 5, 6};
double const *h= g;
return 0;
}
- Template Parameters
-
T | Type of each element in vector. |
S | Compile-time number of elements (0 for number set at run-time). |
Definition at line 67 of file vector.hpp.