Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / wtf / ConditionalDestructor.h
blobfc6410dad322f549b2cb7aeb271b9fddc8102afe
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef ConditionalDestructor_h
6 #define ConditionalDestructor_h
8 namespace WTF {
10 // ConditionalDestructor defines the destructor of the derived object.
11 // This base is used in order to completely avoid creating a destructor
12 // for an object that does not need to be destructed. By doing so,
13 // the clang compiler will have correct information about whether or not
14 // the object has a trivial destructor.
15 // Note: the derived object MUST release all its recources at the finalize()
16 // method.
17 template<typename Derived, bool noDestructor>
18 class ConditionalDestructor {
19 public:
20 ~ConditionalDestructor() { static_cast<Derived*>(this)->finalize(); }
23 template<typename Derived>
24 class ConditionalDestructor<Derived, true> { };
28 #endif // ConditionalDestructor_h