]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - libs/generic/object.h
my own uncrustify run
[xonotic/netradiant.git] / libs / generic / object.h
1 /*
2    Copyright (C) 2001-2006, William Joseph.
3    All Rights Reserved.
4
5    This file is part of GtkRadiant.
6
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.
11
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.
16
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
20  */
21
22 #if !defined( INCLUDED_GENERIC_OBJECT_H )
23 #define INCLUDED_GENERIC_OBJECT_H
24
25 /// \file
26 /// \brief Convenience functions (syntactic sugar) to wrap explicit constructor (aka in-place 'new') and destructor calls.
27 ///
28 /// Use makeReference() to wrap non-const-reference constructor parameters.
29
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
32 #endif
33
34 #include <new>
35
36 template<typename Type>
37 inline void constructor( Type& object ){
38         new( &object )Type();
39 }
40
41 template<typename Type, typename T1>
42 inline void constructor( Type& object, const T1& t1 ){
43         new( &object )Type( t1 );
44 }
45
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 );
49 }
50
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 );
54 }
55
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 );
59 }
60
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 );
64 }
65
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 );
69 }
70
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 );
74 }
75
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 );
79 }
80
81 template<typename Type>
82 inline void destructor( Type& object ){
83         object.~Type();
84 }
85
86
87
88 #endif