10#ifndef TEUCHOS_ARRAY_VIEW_DECL_HPP
11#define TEUCHOS_ARRAY_VIEW_DECL_HPP
15#include "Teuchos_ENull.hpp"
16#include "Teuchos_NullIteratorTraits.hpp"
123#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
173 ArrayView (std::vector<
typename std::remove_const_t<T>>& vec);
176 ArrayView (
const std::vector<
typename std::remove_const_t<T>>& vec);
207 inline T*
data()
const;
337#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
352#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
356 void setUpIterators(
const ERCPNodeLookup rcpNodeLookup = RCP_ENABLE_NODE_LOOKUP);
358 void debug_assert_not_null()
const {
359#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
365 (void)offset; (void)size_in;
366#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
371 void debug_assert_valid_ptr()
const {
372#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
381 T* access_private_ptr()
const
384#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
385 ArrayRCP<T> access_private_arcp()
const
400class ArrayView<const T> {
402 typedef Teuchos_Ordinal Ordinal;
403 typedef Ordinal size_type;
404 typedef Ordinal difference_type;
405 typedef const T value_type;
406 typedef const T* pointer;
407 typedef const T* const_pointer;
408 typedef const T& reference;
409 typedef const T& const_reference;
411#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
415 typedef pointer iterator;
416 typedef const_pointer const_iterator;
424 ArrayView (
const ArrayView<const T>& array);
426 ArrayView (std::vector<
typename std::remove_const_t<T>>& vec);
428 ArrayView (
const std::vector<
typename std::remove_const_t<T>>& vec);
430 ArrayView<const T>&
operator= (
const ArrayView<const T>& array);
436 size_type
size()
const;
442 inline const T*
data()
const;
446 const T&
front()
const;
448 const T&
back()
const;
450 ArrayView<const T>
view( size_type offset, size_type size )
const;
452 ArrayView<const T>
operator()( size_type offset, size_type size )
const;
463 iterator
begin()
const;
465 iterator
end()
const;
469 const ArrayView<const T>&
assert_in_range( size_type offset, size_type size )
const;
471#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
486#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
490 void setUpIterators(
const ERCPNodeLookup rcpNodeLookup = RCP_ENABLE_NODE_LOOKUP);
492 void debug_assert_not_null()
const {
493#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
499 (void)offset; (void)size_in;
500#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
505 void debug_assert_valid_ptr()
const {
506#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
515 const T* access_private_ptr()
const {
return ptr_; }
517#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
518 ArrayRCP<const T> access_private_arcp()
const {
return arcp_; }
606std::ostream&
operator<<( std::ostream& out,
const ArrayView<T>& av );
617template<
class T2,
class T1>
633template<
class T2,
class T1>
Reference-counted pointer node classes.
Reference-counted smart pointer for managing arrays.
ArrayRCP< T > arcp(const RCP< Array< T > > &v)
Wrap an RCP<Array<T> > object as an ArrayRCP<T> object.
const ArrayRCP< T > & assert_valid_ptr() const
If the object pointer is non-null, assert that it is still valid.
ArrayView< const T > getConst() const
Return a const view of *this.
ArrayView< const T > arrayViewFromVector(const std::vector< T > &vec)
Construct a const view of an std::vector.
T * pointer
Type of a pointer to an array element.
bool is_null() const
Returns true if the underlying pointer is null.
iterator end() const
Return an iterator to past the end of the array of data.
ArrayView< T2 > av_const_cast(const ArrayView< T1 > &p1)
Const cast of underlying ArrayView type from const T* to T*.
const ArrayView< T > & assert_in_range(size_type offset, size_type size) const
Throws NullReferenceError if this->get()==NULL orthis->get()!=NULL, throws RangeError if (offset < 0 ...
iterator begin() const
Return an iterator to beginning of the array of data.
ArrayView(ENull null_arg=null)
Constructor that initializes to NULL (implicitly or explicitly).
T & front() const
Get the first element.
const T * const_pointer
Type of a const pointer to an array element.
Teuchos_Ordinal Ordinal
Integer index type used throughout ArrayView.
bool nonnull(const ArrayView< T > &av)
Returns true if av.get()!=NULL.
T & reference
Type of a reference to an array element.
Ordinal difference_type
Type representing the difference between two size_type values.
ArrayView< T > arrayViewFromVector(std::vector< T > &vec)
Construct a non-const view of an std::vector.
ArrayView< T > & operator=(const ArrayView< T > &array)
Shallow copy assignment operator.
const ArrayView< T > & assert_not_null() const
Throws NullReferenceError if this->get()==NULL, otherwise returns reference to *this.
const_pointer const_iterator
Type of a const iterator.
std::vector< T > createVector(const ArrayView< T > &av)
Get a new std::vector<T> object out of an ArrayView<T> object.
ArrayView< T > view(size_type offset, size_type size) const
Return a view of a contiguous range of elements.
const T & const_reference
Type of a const reference to an array element.
T * data() const
Return a raw pointer to beginning of array.
ArrayView< T2 > av_reinterpret_cast(const ArrayView< T1 > &p1)
Reinterpret cast of underlying ArrayView type from T1* to T2*.
ArrayView< const T > getConst() const
Return a const view of a possibly nonconst view.
std::ostream & operator<<(std::ostream &out, const ArrayView< T > &av)
Output stream inserter.
std::vector< T > createVector(const ArrayView< const T > &av)
Get a new std::vector<T> object out of an ArrayView<const T> object.
const ArrayView< T > & operator()() const
Return *this (just for compatibility with Array and ArrayPtr).
pointer iterator
Type of a nonconst iterator.
size_type size() const
The total number of items in the managed array.
T & back() const
Get the last element.
void assign(const ArrayView< const T > &array) const
Copy the data from one array view object to this array view object.
std::string toString() const
Convert an ArrayView<T> to an std::string.
T value_type
Type of each array element.
bool is_null(const ArrayView< T > &av)
Returns true if av.is_null()==true.
T * getRawPtr() const
Return a raw pointer to beginning of array or NULL if unsized.
T & operator[](size_type i) const
Random object access.
Ordinal size_type
Type representing the number of elements in an ArrayRCP or view thereof.
ArrayView< T > arrayView(T *p, typename ArrayView< T >::size_type size)
Construct a const or non-const view to const or non-const data.
ERCPNodeLookup
Used to determine if RCPNode lookup is performed or not.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...