Teamcenter C++ API Reference
2312
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
base_utils
CheckedDelete.hxx
Go to the documentation of this file.
1
// Copyright 2022 Siemens Digital Industries Software
2
// ==================================================
3
// Copyright 2009.
4
// Siemens Product Lifecycle Management Software Inc.
5
// All Rights Reserved.
6
// ==================================================
7
// Copyright 2022 Siemens Digital Industries Software
8
22
/*
23
History:
24
Base implementation copied from NX. The code was copied as this class was available in
25
latest NX libraries which are currently not supported in Tc.
26
The implementation in NX uses code from Boost library, hence a reference to Boost license in included.
27
28
Changes were made to NX code to conform it to Tc. These changes include :
29
- namespace change
30
*/
31
32
/* Boost license: as base implementation comes for Boost, including its license.
33
34
Copyright (c) 2002, 2003 Peter Dimov
35
Copyright (c) 2003 Daniel Frey
36
Copyright (c) 2003 Howard Hinnant
37
38
Distributed under the Boost Software License, Version 1.0.
39
(See copy at http://www.boost.org/LICENSE_1_0.txt)
40
*/
41
42
#ifndef TEAMCENTER_BASE_UTILS_CHECKED_DELETE_HXX
43
#define TEAMCENTER_BASE_UTILS_CHECKED_DELETE_HXX
44
45
namespace
Teamcenter
46
{
47
namespace
Internal
48
{
49
51
template
<
class
T >
inline
void
checked_delete
( T* x );
52
54
template
<
class
T >
inline
void
checked_array_delete
( T* x );
55
57
template
<
class
T >
struct
checked_deleter
58
{
59
typedef
void
result_type
;
60
typedef
T*
argument_type
;
61
62
void
operator()
( T* x )
const
63
{
64
checked_delete
( x );
65
}
66
};
67
69
template
<
class
T >
struct
checked_array_deleter
70
{
71
typedef
void
result_type
;
72
typedef
T*
argument_type
;
73
74
void
operator()
( T* x )
const
75
{
76
checked_array_delete
( x );
77
}
78
};
79
80
// Implementation Details.
81
template
<
class
T >
inline
void
checked_delete
( T* x )
82
{
83
// intentionally complex - simplification causes regressions
84
typedef
char
type_must_be_complete[
sizeof
( T )? 1: -1 ];
85
(void)
sizeof
( type_must_be_complete );
86
delete
x;
87
}
88
89
template
<
class
T >
inline
void
checked_array_delete
( T* x )
90
{
91
typedef
char
type_must_be_complete[
sizeof
( T )? 1: -1 ];
92
(void)
sizeof
( type_must_be_complete );
93
delete
[]x;
94
}
95
96
}
// end namespace Internal
97
}
// end namespace Teamcenter
98
99
#endif // TEAMCENTER_BASE_UTILS_CHECKED_DELETE_HXX