Literally
Alr
Simple Sorcerer
I maked tihs 'int v = (char)v' and solved😁🙏🙏
There are essentially no errors. But I think it's better to replace it here (char) on (int)
Simple Sorcerer
I think you're a little confused
Simple Sorcerer
I maked tihs 'int v = (char)v' and solved😁🙏🙏
Char is also just a number (1 byte), only it is used to display characters. Int is also a number (4 bytes) and can also be used to display characters. I won't mislead you further. but treat char as a number.
Simple Sorcerer
As for encodings. on wikipedia you can see how UTF-8 (UTF-16, ....) encodings are built, in your case you want to use ASCII. you can go to wikipedia and read what character corresponds to what code. for example: 48 = '0' 49 = '1' 50 = '2'
Drs
what is the best way to master c++'s oop?
Drs
sources
Drs
me
should i start a course or practice on online site ? if so kindly recommend some resources to start something
klimi
should i start a course or practice on online site ? if so kindly recommend some resources to start something
Well, we have some resources in the pinned message, and otherwise i think that the best way to master anything is through practice... so just make some projects?
Anonymous
I maked tihs 'int v = (char)v' and solved😁🙏🙏
I just wanted to use a group of decimal values ​​that correspond to 0 to 4. And I did it this way so that any value or character entered outside the scope the program closes, that's the idea. There was a bug but it was resolved with the cast😊
Anonymous
int cast(char &cvalue){ short codeascii = (short)cvalue; if(codeascii >= 48 && codeascii <= 52) return 1; else return 0; }
MᏫᎻᎯᎷᎷᎬᎠ
Does destructive moves outperforms that extra check of the moved-from object state in non-destructive move? Do compilers have a way to workaround that extra hit?
MᏫᎻᎯᎷᎷᎬᎠ
I understand that destructive moves are just something like memberwise memcpy And preventing the dtor of the moved from object to get called Which leaves it with the stack frame destruction
MᏫᎻᎯᎷᎷᎬᎠ
Value has one owner(variable) Checked at compile time
Danya🔥
С++ move semantic differs from Rust's
MᏫᎻᎯᎷᎷᎬᎠ
Yeah C++ moves requires a lot of checking If (this != &rhs) in move assignment And the one mentioned above
Danya🔥
STD::move is quite performant
Yes, because it's noop😂
MᏫᎻᎯᎷᎷᎬᎠ
Yeah C++ moves requires a lot of checking If (this != &rhs) in move assignment And the one mentioned above
I mean that looks totally ugly Dunno if the standard committe is working on solving this problem
MᏫᎻᎯᎷᎷᎬᎠ
STD::move is quite performant
Just an unconditional rvalue cast, but kills the whole purpose of zero cost abstraction Edit: Maybe little
Danya🔥
MᏫᎻᎯᎷᎷᎬᎠ
> but kills the whole purpose of zero cost abstraction Lol, how?
You wouldn't write such code in pure C counterpart if( this != &rhs)
Danya🔥
What is your actual question?
MᏫᎻᎯᎷᎷᎬᎠ
So?
And you do so in C++ Move assignment It's just annoying thing
Danya🔥
And you do so in C++ Move assignment It's just annoying thing
In C there is no move semantics, only pain semantics, do you know that?
Danya🔥
MᏫᎻᎯᎷᎷᎬᎠ
In C you are just manipulating pointers
MᏫᎻᎯᎷᎷᎬᎠ
Danya🔥
And in dtor check?
What destructor check?
MᏫᎻᎯᎷᎷᎬᎠ
What destructor check?
Like in the case std::unique_ptr
Danya🔥
Like in the case std::unique_ptr
I don't understand you
MᏫᎻᎯᎷᎷᎬᎠ
It checks whether it's nullptr or not So to decide whether to delete it or not
MᏫᎻᎯᎷᎷᎬᎠ
What?!
Danya🔥
delete nullptr; is valid code
Danya🔥
It does nothing
MᏫᎻᎯᎷᎷᎬᎠ
Didn't know that such thing is a valid But anyway, the point still stands, it doesn't need to deal memory, there other type of recourses
Danya🔥
I don't understand your point
MᏫᎻᎯᎷᎷᎬᎠ
I don't understand your point
When you have a class that manages some resources and that class supports move operations You need to add extra checks inside the destructor to check for the validity of the objects managed by that class So my question is: Do compilers normally optimize out that extra check?
Danya🔥
Usually you just swap the states of the objects
Danya🔥
The moved-from state means that an object has a valid arbitrary state, so you can call the destructor on the object.
MᏫᎻᎯᎷᎷᎬᎠ
The moved-from state means that an object has a valid arbitrary state, so you can call the destructor on the object.
I don't get your point In case of unique_ptr There is still a check for nullptr in order to avoid double free issue
MᏫᎻᎯᎷᎷᎬᎠ
https://t.me/programminginc/512924 Are you serious?
You can check the dtor implementation of std::unique_ptr It has that extra check
MᏫᎻᎯᎷᎷᎬᎠ
Double free and use after free are common issues in C/C++ and causes ub
أحمد
It's really a happy and fulfilling life.
Name of series second profile pic. from
MᏫᎻᎯᎷᎷᎬᎠ
The burden of proof is on you
Am I allowed to send screenshot?
Danya🔥
Am I allowed to send screenshot?
Send link to the code. The three main implementations of the standard library are open-source
MᏫᎻᎯᎷᎷᎬᎠ
Here is cppreference link https://en.cppreference.com/w/cpp/memory/unique_ptr/~unique_ptr
Danya🔥
Yes, because it's noop😂
Why tf do you dislike the truth lol
MᏫᎻᎯᎷᎷᎬᎠ
MᏫᎻᎯᎷᎷᎬᎠ
Anyway If you do not know the implementation of unique_ptr is not my problem So I guess you cannot provide any help
Danya🔥
The check is there because there is a deleter function, not a delete call
Danya🔥
And nullptr is a VALID state of the unique_ptr
Danya🔥
You can get it just from a default constructor
MᏫᎻᎯᎷᎷᎬᎠ
You're trying to solve a problem that doesn't exist
It does exist There is no way to avoid that extra check and that's the problem Unique_ptr is just an example
MᏫᎻᎯᎷᎷᎬᎠ
There is no need for this check
You seems to be contradicting yourself
Manav
should be quite easy to check, generate a test function, see if there's a weird jump instruction
Danya🔥
.
Fuck
Danya🔥
I don't understand how you can't understand this
Danya🔥
https://t.me/programminginc/512948 Do you understand this?!