OpenShot Library | libopenshot-audio 0.2.0
juce_ContainerDeletePolicy.h
1
2/** @weakgroup juce_core-memory
3 * @{
4 */
5/*
6 ==============================================================================
7
8 This file is part of the JUCE library.
9 Copyright (c) 2017 - ROLI Ltd.
10
11 JUCE is an open source library subject to commercial or open-source
12 licensing.
13
14 The code included in this file is provided under the terms of the ISC license
15 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
16 To use, copy, modify, and/or distribute this software for any purpose with or
17 without fee is hereby granted provided that the above copyright notice and
18 this permission notice appear in all copies.
19
20 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
21 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
22 DISCLAIMED.
23
24 ==============================================================================
25*/
26
27namespace juce
28{
29
30//==============================================================================
31/**
32 Used by container classes as an indirect way to delete an object of a
33 particular type.
34
35 The generic implementation of this class simply calls 'delete', but you can
36 create a specialised version of it for a particular class if you need to
37 delete that type of object in a more appropriate way.
38
39 @see ScopedPointer, OwnedArray
40
41 @tags{Core}
42*/
43template <typename ObjectType>
45{
46 static void destroy (ObjectType* object)
47 {
48 // If the line below triggers a compiler error, it means that you are using
49 // an incomplete type for ObjectType (for example, a type that is declared
50 // but not defined). This is a problem because then the following delete is
51 // undefined behaviour. The purpose of the sizeof is to capture this situation.
52 // If this was caused by a ScopedPointer to a forward-declared type, move the
53 // implementation of all methods trying to use the ScopedPointer (e.g. the destructor
54 // of the class owning it) into cpp files where they can see to the definition
55 // of ObjectType. This should fix the error.
56 ignoreUnused (sizeof (ObjectType));
57
58 delete object;
59 }
60};
61
62} // namespace juce
63
64/** @}*/
Holds a resizable array of primitive or copy-by-value objects.
Definition juce_Array.h:60
Used by container classes as an indirect way to delete an object of a particular type.