2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 /** @file flexarray.h Flexible array support. */
13 /** Flexible array base struct to delete several methods. */
14 struct FlexArrayBase
{
21 FlexArrayBase (const FlexArrayBase
&) DELETED
;
23 FlexArrayBase
& operator = (const FlexArrayBase
&) DELETED
;
25 void *operator new (size_t size
) DELETED
;
28 /** Flexible array base struct to provide custom operator new. */
30 struct FlexArray
: FlexArrayBase
{
32 /** Custom operator new to account for the variable-length buffer. */
33 void *operator new (size_t size
, size_t extra1
, size_t extra2
= 1)
35 return ::operator new (size
+ extra1
* extra2
* sizeof(T
));
39 #endif /* FLEXARRAY_H */