How to store ANY data in C++

preview_player
Показать описание


This video is sponsored by Skillshare
Рекомендации по теме
Комментарии
Автор

In today's lesson: how to break a typing system.

therealdecross
Автор

Very happy that you make general C++ videos again. Your engine series is probably great, but I just don't write engines or games so I only watched it sometimes for entertainment purposes. You just got a new supporter on Patreon ;)

MsJavaWolf
Автор

rvalue\lvalue video would be really nice

denarz
Автор

I am totally okay with seeing you doing sponsorships since you do this full time. Very nice video and also nice is that you renamed to The Cherno :)

whythosenames
Автор

I could see it being useful for something like parsing/serializing structured data such as JSON and still being able to use basic types like std::vector, etc.

tonychristney
Автор

It's crazy to think that I started this playlist about a year ago and i just got to the most recent episode :). Thanks again for posting these, you've been a great help to me and many other people wanting to learn to program!

TrogdorPlays
Автор

Your tutorials are the very best C++ resource on the web! Thank you for all the effort!

MikeOchtman
Автор

Cherno! I love to see how your channel grows! As usual, extreme quality content!

krisitak
Автор

you are awesome, never stop uploading pls you are my teacher

hashcash
Автор

I'd like to ask you to do a video about exceptions in C++: how do we use them, distinct them and I'm curious if they are very different than in Java. Great tutorial btw!

elgrito
Автор

nice episode as always.
I wonder would you consider redoing your serialization series but in c++ this time

abdullahamrsobh
Автор

I would really want to see video about std::atomic :)

fryderykst
Автор

Your videos are really helpful + You give practical application of things Which makes me more interested .

JustinZaf
Автор

Love that laid back beat in the background. Did you produce that?

JohnnyGintonic
Автор

One case where you might want to use any is if you want to concatenate stuff together in a string, such as what a stringstream is. But you can override the string class's new to do this, removing the need for a string stream. That's all I have in mind. But feel free to correct me if I'm wrong.

vikinggeorge
Автор

If you look at how it's implemented in the stl, it's essentially a union of a void pointer or a stack pointer (if the object is small, just store on stack, otherwise the heap) and some typeid RTTIpointer with information about the type stored. Any casts just checks that the cast type matches the typeid type and then performs a reinterpret cast. ReLly easy to abuse and if you're constantly reaching for it, your design is probably broken.although it does have some legit use cases. For example dealing with native handles that will be different types on different platforms

ultimatesoup
Автор

One of systems that I have worked in past had a system that users of sdk must send set of properties to a internal UI system that will display them in a HUD. Since we provide only the SDK, users of the SDK might send 'any' type of properties that is mixed in arbitary order. In that case it was very useful. Funny thing is that at that time we used c+11 compiler and we had to create std::any type by our self.

amilamad
Автор

A video about type traits is what i'am waiting for

Автор

A use case would be that std::any allows passing ownership of arbitrary values across boundaries that don't know about those types. Your code might know about type T but need to produce it, pass it to some third-party library, and then expect that library to later pass it back into your application. From your perspective the value will only ever be a T and never anything else, but from the library's perspective it could literally be anything.
Handling event data in messaging systems may be a thing where this is useful.

dieSpinnt
Автор

Actually speaking of types and not wasting time with web stuff: You're actually missing out on some fascinating stuff, like TypeScript.
TypeScript is a typed superset of JavaScript, getting eventually compiled to JavaScript before getting executed. And it's type system is quite fascinating. As it's code gets compiled to JavaScript it's a static type system, like C(++), and because it's made not to get in your way when using/porting JavaScript code it's also a structural type system, and allows for flow-based typing: You can I.e. type a variable as a union, like `number | string | object`, and I.e. if you test for one of the types with an `if` it not only narrows it down to that type in the if block, but in the else block it'll be narrowed down to the remaining types, i.e. `number | object`.

That's just one of the interesting details of it's typing system.

SMTM