wrap a value in a type that can be type checked but when the code is compiled it will be removed as if it was never there so there is no performance penalty. You can make the code that does the wrapping as complex as you like so you can use this to ensure the value has certain properties. Is there anything like that in C?
interface?
Huh?
i meant ,like an interface? that define a shape of data/object that is for the compiler only?
I suppose it is a bit like that but this is just C I'm talking here so no objects
Makes me think of: https://source.chromium.org/chromium/chromium/src/+/main:base/types/strong_alias.h
typedef void Foo; I guess You can then have functions that take and return *Foo, and it's treated like an opaque type
Ahh ok dunno about c prob can do it.. in cpp read about type erasure
Обсуждают сегодня