Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos::ArrayView< const T > Class Template Reference

Partial specialization of ArrayView for const T. More...

#include <Teuchos_ArrayViewDecl.hpp>

Public Member Functions

ArrayView< const T > getConst () const
 Return a const view of *this.
Views
 operator ArrayView< const T > () const
 Implicitly convert an ArrayView<T> to an ArrayView<const T>.
Assignment
void assign (const ArrayView< const T > &array) const
 Copy the data from one array view object to this array view object.

(Note that these are not member symbols.)

ArrayView< T > arrayView (T *p, typename ArrayView< T >::size_type size)
 Construct a const or non-const view to const or non-const data.
ArrayView< T > arrayViewFromVector (std::vector< T > &vec)
 Construct a non-const view of an std::vector.
ArrayView< const T > arrayViewFromVector (const std::vector< T > &vec)
 Construct a const view of an std::vector.
std::vector< T > createVector (const ArrayView< T > &av)
 Get a new std::vector<T> object out of an ArrayView<T> object.
std::vector< T > createVector (const ArrayView< const T > &av)
 Get a new std::vector<T> object out of an ArrayView<const T> object.
bool is_null (const ArrayView< T > &av)
 Returns true if av.is_null()==true.
bool nonnull (const ArrayView< T > &av)
 Returns true if av.get()!=NULL.
std::ostream & operator<< (std::ostream &out, const ArrayView< T > &av)
 Output stream inserter.
ArrayView< T2 > av_const_cast (const ArrayView< T1 > &p1)
 Const cast of underlying ArrayView type from const T* to T*.
ArrayView< T2 > av_reinterpret_cast (const ArrayView< T1 > &p1)
 Reinterpret cast of underlying ArrayView type from T1* to T2*.

Detailed Description

template<class T>
class Teuchos::ArrayView< const T >

Partial specialization of ArrayView for const T.

The main documentation for ArrayView explains why this class needs a partial specialization for const types.

Definition at line 400 of file Teuchos_ArrayViewDecl.hpp.

Member Function Documentation

◆ getConst()

template<class T>
ArrayView< const T > Teuchos::ArrayView< const T >::getConst ( ) const

Return a const view of *this.

This object is already const (this is a specialization for const T), so this method is trivial; it just returns *this.

◆ operator ArrayView< const T >()

Teuchos::ArrayView< T >::operator ArrayView< const T > ( ) const
inline

Implicitly convert an ArrayView<T> to an ArrayView<const T>.

Note
This conversion operator does not exist if T is already a const type (that is, if T is const T' for some type T'). In that case, the assignment operator and copy constructor achieve the same syntactic effect.

Definition at line 262 of file Teuchos_ArrayView.hpp.

◆ assign()

void Teuchos::ArrayView< T >::assign ( const ArrayView< const T > & array) const

Copy the data from one array view object to this array view object.

Preconditions:

  • this->size() == array.size()
Note
This method does not exist if T is already a const type (that is, if T is const T' for some type T'). This is because assignment to a const right-hand side does not make sense.
This function does modify the right-hand side's data. However, it is declared const, because it does not change the right-hand side's pointer or the number of entries in the view. The pointer is const, even though the data (to which the pointer points) are not.

Definition at line 286 of file Teuchos_ArrayView.hpp.

◆ arrayView()

ArrayView< T > arrayView ( T * p,
typename ArrayView< T >::size_type size )
related

Construct a const or non-const view to const or non-const data.

◆ arrayViewFromVector() [1/2]

ArrayView< T > arrayViewFromVector ( std::vector< T > & vec)
related

Construct a non-const view of an std::vector.

◆ arrayViewFromVector() [2/2]

ArrayView< const T > arrayViewFromVector ( const std::vector< T > & vec)
related

Construct a const view of an std::vector.

◆ createVector() [1/2]

std::vector< T > createVector ( const ArrayView< T > & av)
related

Get a new std::vector<T> object out of an ArrayView<T> object.

Note that a copy of data is made!

◆ createVector() [2/2]

std::vector< T > createVector ( const ArrayView< const T > & av)
related

Get a new std::vector<T> object out of an ArrayView<const T> object.

Note that a copy of data is made!

◆ is_null()

bool is_null ( const ArrayView< T > & av)
related

Returns true if av.is_null()==true.

◆ nonnull()

bool nonnull ( const ArrayView< T > & av)
related

Returns true if av.get()!=NULL.

◆ operator<<()

std::ostream & operator<< ( std::ostream & out,
const ArrayView< T > & av )
related

Output stream inserter.

The implementation of this function just prints pointer addresses and therefore puts no restrictions on the data types involved.

◆ av_const_cast()

ArrayView< T2 > av_const_cast ( const ArrayView< T1 > & p1)
related

Const cast of underlying ArrayView type from const T* to T*.

The function will compile only if (const_cast<T2*>(p1.get());) compiles.

◆ av_reinterpret_cast()

ArrayView< T2 > av_reinterpret_cast ( const ArrayView< T1 > & p1)
related

Reinterpret cast of underlying ArrayView type from T1* to T2*.

The function will compile only if (reinterpret_cast<T2*>(p1.get());) compiles.

Warning! Do not use this function unless you absolutely know what you are doing. Doing a reinterpret cast is always a tricking thing and must only be done by developers who are 100% comfortable with what they are doing.


The documentation for this class was generated from the following files: