Teuchos::{Array,ArrayView} Fix #2749
Created by: mhoemmen
@trilinos/teuchos
Teuchos::Array
and Teuchos::ArrayView
now have a .data()
method, for
compatibility with std::vector
and other C++ Standard Library classes
(as of C++11), as well as Kokkos::View
.
I took the liberty to use std::vector::data
in the implementation of
Teuchos::Array
instead of &vec[0]
, and to replace a few instances of 0
(in a pointer context) with nullptr
. Note that the Teuchos Memory
Management Classes always return nullptr
if the array length is zero;
std::vector
does not promise that.
By analogy with std::shared_ptr<T[]>
, I did not add a .data()
method
to Teuchos::ArrayRCP
. The whole point of the new methods is to
increase compatibility with the C++ Standard Library. Here is a table
of correspondences between Teuchos Memory Management Classes and C++
Standard Library classes:
Teuchos class | Standard Library class |
---|---|
Array |
std::vector |
ArrayView |
std::span (C++20 draft) |
ArrayRCP |
std::shared_ptr<T[]> |
Related Issues
- Closes #2749 (closed)