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
26 /// \brief Convenience functions (syntactic sugar) to wrap explicit constructor (aka in-place 'new') and destructor calls.
28 /// Use makeReference() to wrap non-const-reference constructor parameters.
30 #if _MSC_VER > 1000 && defined( WIN32 )
31 #pragma warning(disable:4345) // behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized
36 template<typename Type>
37 inline void constructor( Type& object ){
41 template<typename Type, typename T1>
42 inline void constructor( Type& object, const T1& t1 ){
43 new( &object )Type( t1 );
46 template<typename Type, typename T1, typename T2>
47 inline void constructor( Type& object, const T1& t1, const T2& t2 ){
48 new( &object )Type( t1, t2 );
51 template<typename Type, typename T1, typename T2, typename T3>
52 inline void constructor( Type& object, const T1& t1, const T2& t2, const T3& t3 ){
53 new( &object )Type( t1, t2, t3 );
56 template<typename Type, typename T1, typename T2, typename T3, typename T4>
57 inline void constructor( Type& object, const T1& t1, const T2& t2, const T3& t3, const T4& t4 ){
58 new( &object )Type( t1, t2, t3, t4 );
61 template<typename Type, typename T1, typename T2, typename T3, typename T4, typename T5>
62 inline void constructor( Type& object, const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5 ){
63 new( &object )Type( t1, t2, t3, t4, t5 );
66 template<typename Type, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
67 inline void constructor( Type& object, const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6 ){
68 new( &object )Type( t1, t2, t3, t4, t5, t6 );
71 template<typename Type, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
72 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 ){
73 new( &object )Type( t1, t2, t3, t4, t5, t6, t7 );
76 template<typename Type, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
77 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 ){
78 new( &object )Type( t1, t2, t3, t4, t5, t6, t7, t8 );
81 template<typename Type>
82 inline void destructor( Type& object ){