flatten 20260225

This commit is contained in:
Timothy Prepscius
2026-02-25 12:39:24 -05:00
commit fa54be052a
315 changed files with 49791 additions and 0 deletions

46
tjp/core/in_place/InPlace.h Executable file
View File

@@ -0,0 +1,46 @@
// TJP COPYRIGHT HEADER
// draft
#pragma once
#include <tjp/core/types/Types.h>
namespace tjp {
namespace core {
template<typename T, size_t size, size_t alignment>
struct InPlace
{
struct Value {
char memory [size];
} __attribute__ ((aligned (alignment)));
Value v;
T *operator ->()
{
return (T *)&v.memory;
}
T *operator ->() const
{
return (const T *)&v.memory;
}
template<typename ... Args>
InPlace(Args&& ... args)
{
(*this)->T(std::forward<Args>(args)...);
static_assert(sizeof(T) == size);
}
~InPlace ()
{
(*this)->~T();
}
} ;
} // namespace
} // namespace