Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
aligned_storage.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2022 Roc Streaming 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/aligned_storage.h
10
//! @brief Aligned storage.
11
12
#ifndef ROC_CORE_ALIGNED_STORAGE_H_
13
#define ROC_CORE_ALIGNED_STORAGE_H_
14
15
#include "
roc_core/stddefs.h
"
16
17
namespace
roc
{
18
namespace
core {
19
20
//! Fixed-size maximum-aligned storage.
21
template
<
size_t
Size>
class
AlignedStorage
{
22
public
:
23
//! Get storage size.
24
static
size_t
size
() {
25
return
sizeof
(Memory);
26
}
27
28
//! Get storage memory.
29
const
void
*
memory
()
const
{
30
return
memory_.payload;
31
}
32
33
//! Get storage memory.
34
void
*
memory
() {
35
return
memory_.payload;
36
}
37
38
private
:
39
union
Memory {
40
double
d;
41
void (*fp)();
42
char
payload[Size != 0 ? Size : 1];
43
};
44
45
Memory memory_;
46
};
47
48
}
// namespace core
49
}
// namespace roc
50
51
#endif
// ROC_CORE_ALIGNED_STORAGE_H_
roc::core::AlignedStorage
Fixed-size maximum-aligned storage.
Definition
aligned_storage.h:21
roc::core::AlignedStorage::memory
const void * memory() const
Get storage memory.
Definition
aligned_storage.h:29
roc::core::AlignedStorage::memory
void * memory()
Get storage memory.
Definition
aligned_storage.h:34
roc::core::AlignedStorage::size
static size_t size()
Get storage size.
Definition
aligned_storage.h:24
roc
Root namespace.
stddefs.h
Commonly used types and functions.
roc_core
aligned_storage.h
Generated by
1.9.7