Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_getRawPtr.hpp
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_GETRAWPTR_HPP
11#define TEUCHOS_GETRAWPTR_HPP
12
13#include "Teuchos_ArrayRCP.hpp"
14
15namespace Teuchos {
16
17template<class Container>
18class RawPointerConversionTraits {
19 // Empty : will fail if specialization doesn't exist
20};
21
22
23template<class Container>
24typename RawPointerConversionTraits<Container>::Ptr_t
25getRawPtr( const Container& c )
26{
27 return RawPointerConversionTraits<Container>::getRawPtr(c);
28}
29
30
31// partial specialization for C pointer
32template<class RawType>
33class RawPointerConversionTraits<RawType*>
34{
35public:
36 typedef RawType* Ptr_t;
37 static Ptr_t getRawPtr( RawType* p ) { return p; }
38};
39
40// partial specialization for ArrayRCP
41template<class T>
42class RawPointerConversionTraits<ArrayRCP<T> >
43{
44public:
45 typedef typename ArrayRCP<T>::pointer Ptr_t;
46 static Ptr_t getRawPtr( const ArrayRCP<T>& arcp ) { return arcp.getRawPtr(); }
47};
48
49// ToDo: Add specializations as needed!
50
51} // namespace Teuchos
52
53#endif // TEUCHOS_GETRAWPTR_HPP
54
T * pointer
Type of a (raw) (nonconstant) pointer to an array element.
T * getRawPtr() const
Get the raw C++ pointer to the underlying object.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...