Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
scoped_destructor.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Roc authors
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 */
8
9//! @file roc_core/scoped_destructor.h
10//! @brief Scoped destructor.
11
12#ifndef ROC_CORE_SCOPED_DESTRUCTOR_H_
13#define ROC_CORE_SCOPED_DESTRUCTOR_H_
14
16
17namespace roc {
18namespace core {
19
20//! Destroys the object via custom deleter.
21template <class T, void (*Func)(T)> class ScopedDestructor : public NonCopyable<> {
22public:
23 //! Initialize.
24 explicit ScopedDestructor(T obj)
25 : obj_(obj) {
26 }
27
28 //! Destroy.
30 Func(obj_);
31 }
32
33private:
34 T obj_;
35};
36
37} // namespace core
38} // namespace roc
39
40#endif // ROC_CORE_SCOPED_DESTRUCTOR_H_
Base class for non-copyable objects.
Definition: noncopyable.h:23
Destroys the object via custom deleter.
ScopedDestructor(T obj)
Initialize.
Root namespace.
Non-copyable object.