This file contains hidden or 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
| #pragma once | |
| /* | |
| * Scary abuse of the sizeof syntax so static_assert gets evaluated. | |
| * If it passes, we don't want to modify the result though, so AND with 0. | |
| * This is illegal in C++! | |
| */ | |
| #define MODE_ASSERT(x, m) sizeof(struct { static_assert(x, m); char _ghost; }) & 0 | |
| /* |
This file contains hidden or 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
| using System.Runtime.InteropServices; | |
| namespace BlockImpl; | |
| /// <summary> | |
| /// Manages a sequential area of memory like <see cref="Span{T}"/>, but on the unmanaged heap. | |
| /// When used on managed or stack memory, make sure to call <see cref="MarkMemoryAsFragile"/>. | |
| /// </summary> | |
| /// <typeparam name="T">Underlying type.</typeparam> | |
| public unsafe class Block<T> : IDisposable where T : unmanaged |