Teuchos Package Browser (Single Doxygen Collection)
Version of the Day
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
core
test
MemoryManagement
RCP_Abort.cpp
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
#include "
Teuchos_RCP.hpp
"
11
12
// This test will abort for TEUCHOS_DEBUG only. RCPNode will detect an
13
// exception in the destructor of A and then execute the abort because handling
14
// the exception would not be thread safe.
15
int
main
(
int
argc,
char
* argv[])
16
{
17
// create a test class which throws on destruct
18
class
A
{
19
public
:
20
~A
()
TEUCHOS_NOEXCEPT_FALSE
{
21
throw
std::runtime_error(
"Test Class A throws on destructor..."
);
22
}
23
};
24
25
// create RCP of the test class
26
Teuchos::RCP<A>
a =
Teuchos::rcp
(
new
A
);
27
28
// release RCP - will trigger the exception from the destructor of A
29
a =
Teuchos::null
;
30
31
// we should not get here because this test should only be running
32
// in debug mode and it should have aborted already.
33
std::cout <<
"Unexpected RCP_Abort should have aborted"
<< std::endl;
34
return
0;
35
}
A
Definition:
core/example/RefCountPtr/cxx_main.cpp:13
Teuchos::rcp
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
Definition:
Teuchos_RCPDecl.hpp:1234
A::~A
virtual ~A()
Definition:
core/example/RefCountPtr/cxx_main.cpp:16
TEUCHOS_NOEXCEPT_FALSE
#define TEUCHOS_NOEXCEPT_FALSE
Definition:
TeuchosCore_ConfigDefs.hpp:23
main
int main(int argc, char *argv[])
Definition:
core/example/CommandLineProcessor/cxx_main.cpp:21
Teuchos::null
Definition:
Teuchos_ENull.hpp:22
Teuchos::RCP< A >
Teuchos_RCP.hpp
Reference-counted pointer class and non-member templated function implementations.
Generated on Thu Nov 21 2024 09:21:38 for Teuchos Package Browser (Single Doxygen Collection) by
1.8.5