10#ifndef TEUCHOS_ARRAY_VIEW_HPP 
   11#define TEUCHOS_ARRAY_VIEW_HPP 
   14#include "Teuchos_ArrayViewDecl.hpp" 
   15#include "Teuchos_ArrayRCP.hpp" 
   25template<
class T> 
inline 
   32template<
class T> 
inline 
   41template<
class T> 
inline 
   45#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK 
 
   65template<
class T> 
inline 
   69#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK 
   90template<
class T> 
inline 
   98template<
class T> 
inline 
  107template<
class T> 
inline 
  109  std::vector<
typename std::remove_const_t<T>>& vec
 
  111  : ptr_( vec.empty() ? 0 : vec.data() ), size_(vec.size())
 
 
  116template<
class T> 
inline 
  118  std::vector<
typename std::remove_const_t<T>>& vec
 
  120  : ptr_( vec.empty() ? 0 : vec.data() ), size_(vec.size())
 
  126template<
class T> 
inline 
  128  const std::vector<
typename std::remove_const_t<T>>& vec
 
  130  : ptr_( vec.empty() ? 0 : vec.data() ), size_(vec.size())
 
 
  135template<
class T> 
inline 
  137  const std::vector<
typename std::remove_const_t<T>>& vec
 
  139  : ptr_( vec.empty() ? 0 : vec.data() ), size_(vec.size())
 
  145template<
class T> 
inline 
  150#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK 
 
  156template<
class T> 
inline 
  161#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK 
  168template<
class T> 
inline 
  172template<
class T> 
inline 
  195template<
class T> 
inline 
  202template<
class T> 
inline 
  214  std::ostringstream 
ss;
 
  222    if (
i + 1 < size ()) {
 
  234  std::ostringstream ss;
 
  239  for (size_type i = 0; i < size (); ++i) {
 
  241    ss << operator[] (i);
 
  242    if (
i + 1 < size ()) {
 
  254TEUCHOSCORE_LIB_DLL_EXPORT std::string
 
  260TEUCHOSCORE_LIB_DLL_EXPORT std::string
 
  266TEUCHOSCORE_LIB_DLL_EXPORT std::string
 
  272TEUCHOSCORE_LIB_DLL_EXPORT std::string
 
  279template<
class T> 
inline 
  286template<
class T> 
inline 
  293template<
class T> 
inline 
  300template<
class T> 
inline 
  307template<
class T> 
inline 
  311  debug_assert_in_range(
i,1);
 
 
  315template<
class T> 
inline 
  319  debug_assert_in_range(
i,1);
 
  324template<
class T> 
inline 
  332template<
class T> 
inline 
  340template<
class T> 
inline 
  345  return *(ptr_+size_-1);
 
 
  348template<
class T> 
inline 
  353  return *(ptr_+size_-1);
 
  360template<
class T> 
inline 
  363  if (
size_in == 0) { 
return null; }
 
 
  376template<
class T> 
inline 
  379  if (
size_in == 0) { 
return null; }
 
  381  debug_assert_in_range(offset, size_in);
 
  382  return ArrayView<const T>(
 
  384#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
 
  385    ,arcp_.persistingView(offset, size_in)
 
  393template<
class T> 
inline 
  399template<
class T> 
inline 
  406template<
class T> 
inline 
  413template<
class T> 
inline 
  421template<
class T> 
inline 
  425#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK 
 
  432template<
class T> 
inline 
  438template<
class T> 
inline 
  455  debug_assert_in_range(0,
array.size());
 
 
  469#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK 
 
  480#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK 
  492#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK 
 
  503#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK 
  518    throw_null_ptr_error(
typeName(*
this));
 
 
  526    throw_null_ptr_error(
typeName(*
this));
 
  537    "Error, size=0 is not allowed!" );
 
  545    typeName(*
this)<<
"::assert_in_range():" 
  547    " does not lie in the range [0,"<<this->size()<<
")!" 
 
 
  558    "Error, size=0 is not allowed!" );
 
  566    typeName(*
this)<<
"::assert_in_range():" 
  568    " does not lie in the range [0,"<<this->size()<<
")!" 
  574#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK 
  578  : ptr_(arcp.getRawPtr()), size_(arcp.size()), arcp_(arcp)
 
  583  : ptr_(arcp.getRawPtr()), size_(arcp.size()), arcp_(arcp)
 
  589  : ptr_(p), size_(size_in), arcp_(arcp)
 
  594  : ptr_(p), size_(size_in), arcp_(arcp)
 
  605void ArrayView<T>::setUpIterators(
const ERCPNodeLookup rcpNodeLookup)
 
  607#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK 
  608  if (ptr_ && arcp_.is_null()) {
 
  609    arcp_ = ArrayRCP<T>(ptr_, 0, size_, 
false, rcpNodeLookup);
 
  612  (void) rcpNodeLookup; 
 
  617void ArrayView<const T>::setUpIterators(
const ERCPNodeLookup rcpNodeLookup)
 
  619#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK 
  620  if (ptr_ && arcp_.is_null()) {
 
  621    arcp_ = ArrayRCP<const T>(ptr_, 0, size_, 
false, rcpNodeLookup);
 
  624  (void) rcpNodeLookup; 
 
  637template<
class T> 
inline 
  639Teuchos::arrayView( T* p, 
typename ArrayView<T>::size_type size )
 
  643  return ArrayView<T>(p, size);
 
  647template<
class T> 
inline 
  652  return ArrayView<T>(vec);
 
  656template<
class T> 
inline 
  661  return ArrayView<const T>(vec);
 
  667template<
class T> 
inline 
  668std::vector<T> Teuchos::createVector( 
const ArrayView<T> &av )
 
  670  std::vector<T> v(av.begin(), av.end());
 
  677template<
class T> 
inline 
  678std::vector<T> Teuchos::createVector( 
const ArrayView<const T> &av )
 
  680  std::vector<T> v(av.begin(), av.end());
 
  685template<
class T> 
inline 
  692template<
class T> 
inline 
  702  return out << p.toString();
 
  706template<
class T2, 
class T1>
 
  709Teuchos::av_const_cast(
const ArrayView<T1>& p1)
 
  711  T2 *ptr2 = 
const_cast<T2*
>(p1.getRawPtr());
 
  712  return ArrayView<T2>(ptr2, p1.size());
 
  717template<
class T2, 
class T1>
 
  720Teuchos::av_reinterpret_cast(
const ArrayView<T1>& p1)
 
  722  typedef typename ArrayView<T1>::size_type size_type;
 
  723  const int sizeOfT1 = 
sizeof(T1);
 
  724  const int sizeOfT2 = 
sizeof(T2);
 
  725  size_type size2 = (p1.size()*sizeOfT1) / sizeOfT2;
 
  726  T2 *ptr2 = 
reinterpret_cast<T2*
>(p1.getRawPtr());
 
  727  return ArrayView<T2>(
 
  729#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
 
  730    ,arcp_reinterpret_cast<T2>(p1.access_private_arcp())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Definition of Teuchos::as, for conversions between types.
 
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.
 
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.
 
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.
 
ArrayView< T > view(size_type offset, size_type size) const
Return a view of a contiguous range of elements.
 
T * data() const
Return a raw pointer to beginning of array.
 
ArrayView< const T > getConst() const
Return a const view of a possibly nonconst view.
 
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 * 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.
 
Smart reference counting pointer class for automatic garbage collection.
 
RCP< const T > getConst() const
Return an RCP<const T> version of *this.
 
RCP< T > create_weak() const
Create a new weak RCP object from another (strong) RCP object.
 
bool is_null() const
Returns true if the underlying pointer is null.
 
T * getRawPtr() const
Get the raw C++ pointer to the underlying object.
 
const RCP< T > & assert_not_null() const
Throws NullReferenceError if this->get()==NULL, otherwise returns reference to *this.
 
const RCP< T > & debug_assert_valid_ptr() const
Calls assert_valid_ptr() in a debug build.
 
const RCP< T > & debug_assert_not_null() const
Calls assert_not_null() in a debug build.
 
Range error exception class.
 
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
This macro is designed to be a short version of TEUCHOS_TEST_FOR_EXCEPTION() that is easier to call.
 
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
 
bool is_null(const std::shared_ptr< T > &p)
Returns true if p.get()==NULL.
 
bool nonnull(const std::shared_ptr< T > &p)
Returns true if p.get()!=NULL.
 
TypeTo as(const TypeFrom &t)
Convert from one value type to another.
 
std::string typeName(const T &t)
Template function for returning the concrete type name of a passed-in object.
 
const T & getConst(T &t)
Return a constant reference to an object given a non-const reference.
 
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,...