2 Copyright (C) 2001-2006, William Joseph.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #if !defined( INCLUDED_GENERIC_OBJECT_H )
23 #define INCLUDED_GENERIC_OBJECT_H
25 #include "globaldefs.h"
28 /// \brief Convenience functions (syntactic sugar) to wrap explicit constructor (aka in-place 'new') and destructor calls.
30 /// Use makeReference() to wrap non-const-reference constructor parameters.
32 #if GDEF_COMPILER_MSVC && _MSC_VER > 1000
33 #pragma warning(disable:4345) // behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized
38 template<typename Type>
39 inline void constructor( Type& object ){
43 template<typename Type, typename T1>
44 inline void constructor( Type& object, const T1& t1 ){
45 new( &object )Type( t1 );
48 template<typename Type, typename T1, typename T2>
49 inline void constructor( Type& object, const T1& t1, const T2& t2 ){
50 new( &object )Type( t1, t2 );
53 template<typename Type, typename T1, typename T2, typename T3>
54 inline void constructor( Type& object, const T1& t1, const T2& t2, const T3& t3 ){
55 new( &object )Type( t1, t2, t3 );
58 template<typename Type, typename T1, typename T2, typename T3, typename T4>
59 inline void constructor( Type& object, const T1& t1, const T2& t2, const T3& t3, const T4& t4 ){
60 new( &object )Type( t1, t2, t3, t4 );
63 template<typename Type, typename T1, typename T2, typename T3, typename T4, typename T5>
64 inline void constructor( Type& object, const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5 ){
65 new( &object )Type( t1, t2, t3, t4, t5 );
68 template<typename Type, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
69 inline void constructor( Type& object, const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6 ){
70 new( &object )Type( t1, t2, t3, t4, t5, t6 );
73 template<typename Type, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
74 inline void constructor( Type& object, const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7 ){
75 new( &object )Type( t1, t2, t3, t4, t5, t6, t7 );
78 template<typename Type, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
79 inline void constructor( Type& object, const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8 ){
80 new( &object )Type( t1, t2, t3, t4, t5, t6, t7, t8 );
83 template<typename Type>
84 inline void destructor( Type& object ){