Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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:
21  throw std::runtime_error( "Test Class A throws on destructor..." );
22  }
23  };
24 
25  // create RCP of the test class
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 }
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
#define TEUCHOS_NOEXCEPT_FALSE
int main(int argc, char *argv[])
Reference-counted pointer class and non-member templated function implementations.