Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_ArrayConversions.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Teuchos: Common Tools Package
4//
5// Copyright 2004 NTESS and the Teuchos contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef TEUCHOS_ARRAY_CONVERSIONS_H
11#define TEUCHOS_ARRAY_CONVERSIONS_H
12
16
17#include "Teuchos_Ptr.hpp"
18#include "Teuchos_RCP.hpp"
19#include "Teuchos_Array.hpp"
20#include "Teuchos_Assert.hpp"
21
22
23namespace Teuchos {
24
25
30template<class ArrayPtrT_in, class T_out>
31void arrayViewPtrConv( const ArrayPtrT_in &a_in,
32 const ArrayView<Ptr<T_out> > &a_out )
33{
34 using Teuchos::as;
35#ifdef TEUCHOS_DEBUG
37 as<Teuchos_Ordinal>(a_out.size()));
38#endif
39 for (Teuchos_Ordinal i = 0; i < as<Teuchos_Ordinal>(a_in.size()); ++i) {
40 a_out[i] = a_in[i].ptr();
41 }
42}
43
44
48template<class ArrayPtrT_in, class T_out>
49void arrayViewRcpConv( const ArrayPtrT_in &a_in,
50 const ArrayView<RCP<T_out> > &a_out )
51{
52 using Teuchos::as;
53#ifdef TEUCHOS_DEBUG
55 as<Teuchos_Ordinal>(a_out.size()));
56#endif
57 for (Teuchos_Ordinal i = 0; i < as<Teuchos_Ordinal>(a_in.size()); ++i) {
58 a_out[i] = a_in[i];
59 }
60}
61
62
83template<class T_out, class ArrayPtrT_in>
84Array<Ptr<T_out> > arrayPtrConv(const ArrayPtrT_in &a_in)
85{
86 using Teuchos::as;
87 Array<Ptr<T_out> > a_out(a_in.size());
88 arrayViewPtrConv(a_in, a_out());
89 return a_out;
90}
91
92
99template<class T_out, class ArrayPtrT_in>
100Array<RCP<T_out> > arrayRcpConv(const ArrayPtrT_in &a_in)
101{
102 using Teuchos::as;
103 Array<RCP<T_out> > a_out(a_in.size());
104 arrayViewRcpConv(a_in, a_out());
105 return a_out;
106}
107
108
119template<class T>
120ArrayView<const Ptr<const T> >
122{
124}
125
126
137template<class T>
138ArrayView<const RCP<const T> >
140{
142}
143
144
145} // namespace Teuchos
146
147
148#endif // TEUCHOS_ARRAY_CONVERSIONS_H
149
Templated array class derived from the STL std::vector.
Reference-counted pointer class and non-member templated function implementations.
Replacement for std::vector that is compatible with the Teuchos Memory Management classes.
Nonowning array view.
ArrayView< T2 > av_reinterpret_cast(const ArrayView< T1 > &p1)
Reinterpret cast of underlying ArrayView type from T1* to T2*.
Simple wrapper class for raw pointers to single objects where no persisting relationship exists.
Smart reference counting pointer class for automatic garbage collection.
#define TEUCHOS_ASSERT_EQUALITY(val1, val2)
This macro is checks that to numbers are equal and if not then throws an exception with a good error ...
TypeTo as(const TypeFrom &t)
Convert from one value type to another.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
void arrayViewPtrConv(const ArrayPtrT_in &a_in, const ArrayView< Ptr< T_out > > &a_out)
Utility function to convert from an an input Array[View,RCP]<[const] PTR<T_in> > object to an output ...
ArrayView< const RCP< const T > > arrayConstRcpConstCast(const ArrayView< const RCP< T > > &a_in)
Utility function that does a reinterpret case to convert an ArrayView<const RCP<T> > object to an Arr...
Array< Ptr< T_out > > arrayPtrConv(const ArrayPtrT_in &a_in)
Utility function to convert an Array[View,RCP]<[const] PTR<T_in> > object to an Array<Ptr<T_out> > ob...
ArrayView< const Ptr< const T > > arrayConstPtrConstCast(const ArrayView< const Ptr< T > > &a_in)
Utility function that does a reinterpret case to convert an ArrayView<const Ptr<T> > object to an Arr...
void arrayViewRcpConv(const ArrayPtrT_in &a_in, const ArrayView< RCP< T_out > > &a_out)
Utility function to convert from an input Array[View,RCP]<[const] RCP<T_in> > object to an output Arr...
Array< RCP< T_out > > arrayRcpConv(const ArrayPtrT_in &a_in)
Utility function to convert any Array[View,RCP]<[const] RCP<T_in> > object to an Array<RCP<T_out> > o...