Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Main Page
Namespaces
Classes
Files
File List
File Members
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
15
#include "
roc_core/noncopyable.h
"
16
17
namespace
roc
{
18
namespace
core {
19
20
//! Destroys the object via custom deleter.
21
template
<
class
T,
void
(*Func)(T)>
class
ScopedDestructor
:
public
NonCopyable
<> {
22
public
:
23
//! Initialize.
24
explicit
ScopedDestructor
(T obj)
25
: obj_(obj) {
26
}
27
28
//! Destroy.
29
~ScopedDestructor
() {
30
Func(obj_);
31
}
32
33
private
:
34
T obj_;
35
};
36
37
}
// namespace core
38
}
// namespace roc
39
40
#endif // ROC_CORE_SCOPED_DESTRUCTOR_H_
roc
Root namespace.
roc::core::ScopedDestructor::~ScopedDestructor
~ScopedDestructor()
Destroy.
Definition:
scoped_destructor.h:29
roc::core::ScopedDestructor::ScopedDestructor
ScopedDestructor(T obj)
Initialize.
Definition:
scoped_destructor.h:24
roc::core::NonCopyable
Base class for non-copyable objects.
Definition:
noncopyable.h:23
roc::core::ScopedDestructor
Destroys the object via custom deleter.
Definition:
scoped_destructor.h:21
noncopyable.h
Non-copyable object.
roc_core
scoped_destructor.h
Generated by
1.8.11