#struct

2025-11-21

StructPadding

Представляю свою библиотеку для обнуления байт выравнивания (padding) в unmanaged структурах. Обнуление байт паддинга (padding) обеспечивает детерминированное состояние памяти, что критически важно для двоичного сравнения или вычисления хэша. И не менее важно при бинарной сериализации.

habr.com/ru/articles/968650/

#padding #struct #nuget

hubertfhubertf
2025-08-01

Teaching structs to ghidra for fun and flags

struct definition in ghira
2025-05-15

readonly struct в C#

Привет, Хабр! Вы, вероятно, уже сталкивались с struct в C# и задумались: а зачем нужен readonly struct и когда он реально спасает, а когда, наоборот, начинает всё тормозить? Сегодня это и рассмотрим.

habr.com/ru/companies/otus/art

#c# #struct #readonly_struct

2025-02-28

Порядок инициализации полей, статики и всего остального в C#

Всем привет! Многие сталкиваются с трудностями на собеседовании на вопросе по типу "Расскажите о порядке иницализации в C#". Либо банально когда видят квиз, стараются вспомнить, а что там должно инициализироваться? Сегодня многие вспомнят, а кто-то узнает о порядке инициализации. Затронем не только классы, а также структуры, а точнее - ключевое слово default для них. Сделаем следующие классы и посмотрим, что будет при создании объекта B:

habr.com/ru/articles/886692/

#c# #net #net_core #struct #инициализация #поля

2024-12-09

Кастомная сериализация структур в UE

Допустим, вы создали свою USTRUCT в C++ и хотите её сериализовать. Обычно, достаточно просто пометить нужные поля как SaveGame . Но вот проблема, для этого эти поля сами должны поддерживать сериализацию. К сожалению одна из наших переменных не поддерживает сериализацию. В моем случае, это структура FNonSerializableStruct . Из-за этого сериализуется только вторая структура, хоть мы и пометили SaveGame обе.

habr.com/ru/articles/865170/

#usrtuct #struct #serialize #serializable #структура #сериализация #unreal_engine #ue #структуры #анрил

2024-09-30
Найменшенькийbalaraz@social.net.ua
2024-07-28

У C++20 зʼявились концепти й обмеження для функцій, класів/структур та інших шаблонів. Для функцій та методів вимоги можна вказувати після оголошення шаблону або після функції.

template<typename T>
    requires ...
T f() {}

template<typename T>
T f() requires ... {}

Якщо не шаблонний метод у шаблоні класу потребує додаткових вимог їх можна вказати після оголошення методу.

template<typename T>
class S {
    T f() requires integer<T> {}
};

У такому випадку клас може згенеруватись з будь-яким типом, але це метод буде присутній тільки якщо шаблонний тип відповідає вимогам.

Але іноді може знадобитись використати поточний клас у вимогах. Наприклад при CRTP.

template<typename D>
class Base requires std::derived_from<D, Base> {...};

На жаль зараз такого немає.

#cpp #cxx #cpp20 #concepts #constrains #requires #class #template #struct #CRTP #proposal #програмування #шаблони #вимоги #обмеження #пропозиція

Orhun Parmaksız 👾orhun@fosstodon.org
2024-07-22

Derive more! 🔥

🦀 derive_more: Derive traits for structs and enums to avoid boilerplate.

📚 Docs: docs.rs/derive_more

⭐ GitHub: github.com/JelteF/derive_more

#rustlang #derive #struct #enum #boilerplate #programming #library #opensource

Mark Nichols (LGBTQIA+ Ally)zanshin@hachyderm.io
2024-07-01

I like the second way better too. I also like the idea of splitting the struct and its impls to its own file. Thanks everyone for your input.

#Rust #Trait #Impl #Struct

Mark Nichols (LGBTQIA+ Ally)zanshin@hachyderm.io
2024-06-30

In Rust if I have some structs that each implement a couple traits, what is the preferred way to order things?

trait … {}
trait …{}

struct …{}
struct …{}
struct …{}

impl…for …{}
impl…for …{}
impl…for …{}
impl…for …{}
impl…for …{}
impl…for …{}

OR

trait …{}
trait …{}

struct …{}
impl…for …{}
impl…for …{}

struct …{}
impl…for …{}
impl…for …{}

struct …{}
impl…for …{}
impl…for …{}

OR, something else entirely?

#Rust #Trait #Impl #Struct

Ramesh #NotGoingBackrameshgupta
2024-06-11

⬆️ @gooba42

Another one of my favorites is carryover of from .

In , everything is a class. Using one requires mem alloc from heap, and passed by reference, then later de-allocated. Mutable objects are costly in cycles, but also unsafe across threads.

Swift structs are immutable, passed by value on stack, no need to allocate and deallocate, and they can have functions/methods just like classes, but not overrideable.

Swift has a full complement of modern language constructs

Найменшенькийbalaraz@social.net.ua
2024-03-05

Ніяк не міг зрозуміти чому наступний код не компілюється.

template <typename T, size_t N>
struct Arr {
    T[N] arr;
	
    T* begin() { return arr; }
    T* end()   { return arr + N; }
};

Хвилин пʼять сидів над ним якщо не довше.

#cpp #arrey #class #struct #template #шаблони #масив #клас #структура #структури

Aljoscha Rittner (beandev)beandev@social.tchncs.de
2022-07-29

Aber ich bin fast sicher, dass #struct da sinnvoller ist. Ich habe nämlich einige feste Enums für einen Health-Status (up, down, unknown und out_of_service), aber grundsätzlich kann man beliebige haben. Zu jeden Status gibt es einen HTTP Status Code (2* oder 5*) und ggf. Details.
Ich dachte, perfekt für Enum Varianten, aber Pustekuchen. Viel zu viel bad smelling code und serde serialisert an meinen Erwartungen vorbei (aber nachvollziehbar) und ich muss da umdenken.

Client Info

Server: https://mastodon.social
Version: 2025.07
Repository: https://github.com/cyevgeniy/lmst