-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
38f4fa5
commit 17f43a0
Showing
3 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
modules/common/chowdsp_data_structures/Helpers/chowdsp_ArenaHelpers.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
namespace chowdsp::arena | ||
{ | ||
template <typename T, typename I, typename Arena> | ||
std::span<T> make_span (Arena& arena, I size, size_t alignment = alignof (T)) | ||
{ | ||
return { arena.template allocate<T> (size, alignment), static_cast<size_t> (size) }; | ||
} | ||
|
||
template <typename Arena> | ||
std::string_view alloc_string (Arena& arena, const std::string_view& str) | ||
{ | ||
auto* data = arena.template allocate<char> (str.size()); | ||
std::copy (str.begin(), str.end(), data); | ||
return std::string_view { data, str.size() }; // NOLINT | ||
}; | ||
|
||
#if CHOWDSP_USING_JUCE | ||
template <typename Arena> | ||
std::string_view alloc_string (Arena& arena, const juce::String& str) | ||
{ | ||
return alloc_string (arena, toStringView (str)); | ||
} | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters