ShadowPtrPolicy.h
Go to the documentation of this file.
1 #ifndef _utl_ShadowPtrPolicy_h_
2 #define _utl_ShadowPtrPolicy_h_
3 
4 #include <iostream>
5 #ifdef __GNUC__
6 # include <cxxabi.h>
7 # include <cstdlib>
8 #endif
9 #include <utl/AugerException.h>
10 
11 
12 namespace utl {
13 
15  public:
16  template<typename T>
17  static void Examine(T* const)
18  { }
19  };
20 
21 
23  public:
24  template<typename T>
25  static
26  void
27  Examine(T* const ptr)
28  {
29  if (!ptr) {
30  std::stringstream err;
31  err << "Dereferencing zero pointer to ";
32 #ifdef __GNUC__
33  int status;
34  char* const rName =
35  abi::__cxa_demangle(typeid(T).name(), 0, 0, &status);
36  err << rName;
37  free(rName);
38 #else
39  err << typeid(T).name();
40 #endif
41  std::cerr << err.str() << std::endl;
42  throw utl::NonExistentComponentException(err.str());
43  }
44  }
45  };
46 
47 }
48 
49 
50 #endif
Base class for exceptions trying to access non-existing components.
static void Examine(T *const)
static void Examine(T *const ptr)

, generated on Tue Sep 26 2023.