Код: Выделить всё
struct A
{
int16_t Index;
static inline A* Instances;
};
< /code>
И я определяю в thandle.h Следующий шаблон, служащий ручкой или как его называют (всегда 2 байта): < /p>
template
struct THandle
{
int16_t Index = -1;
THandle() = default;
THandle(int16_t index) : Index(index) {}
__forceinline T* operator->() const { return &T::Instances[Index]; }
__forceinline explicit operator bool() const { return Index != -1; }
};
< /code>
хранить в произвольном классе B, определенный в B.H: < /p>
class B
{
THandle SomeAInstance;
};
Подробнее здесь: https://stackoverflow.com/questions/795 ... -in-the-bo
Мобильная версия