BinaryByter
This admin guy who figured it out is just too smart
BinaryByter
lets kill him
Pavel
Well, let me try to explain in more details In the code that I pasted I wanted to resize the vector if the new index doesn't fit it. Basically, I want to check the size and if it smaller, call resize. But, I will probably need to resize it further in the future, so there are two options: 1) resize allocates memory for a vector of given to resize size (capacity = size). then any next push_back or resize to a bigger size will call another rellocation 2) resize will allocate more memory than the given size (capacity > size). something like capacity = size * 2. So my question basically is: is the first case true or the second is true? If first than I need to manage it myself how I did in my code example. Otherwise every resize will trigger reallocation.
Pavel
this check is already done in push back
yes, but I don't want to use push_back, because I don't need to push zeros for any empty object
BinaryByter
resize does exactly the same thing ;)
Pavel
yes, but it does it only when needed and all at once
BinaryByter
there is no definition of how much anything allocates
BinaryByter
yes, but it does it only when needed and all at once
it is not inconcievable to implement resize as a loop of push_backs
Pavel
it is not inconcievable to implement resize as a loop of push_backs
well, if I have vector of size 3, then I have 100 empty objects that I don't care about, and then I want to insert 101-st. then - resize (or reserve+resize) will make 1 allocation - push_back will make more allocations (~6?)
BinaryByter
why would you ... push them into a vector?
Pavel
why would you ... push them into a vector?
it's an exaggurated case, but it is still possible in theory I want the vector to be consistent with others (it's kind of Structure of Arrays thing that I'm working on)
BinaryByter
Well yea, when doing many pushbacks, you can and should resize first
Mat
If you know your upper and lower size bounds and they don't really differ from each other, you can allocate the vector using the upper bound value to save time
14•08
😂😂😂😂 lol
Anonymous
http://yosefk.com/c++fqa/defective.html
14•08
/warn non-english
😂😂😂 I wondered none of them wasn't given warning
14•08
K bye
😂😂😂😂 i laugh again ..
Mihail
http://yosefk.com/c++fqa/defective.html
What are you trying to prove with this?
Anonymous
Nothing, I Just was reading
Mihail
All arguments are literally named by the convention: Defective + *literally every cpp feature* And all the arguments themselves are either non-sense or they resolve around duplication of C code (false no matter from where you look at it) or marketing (yeah, really... 😂)
Mihail
Also someone seems to be so keen on hating cpp (y tho?) that he even has a special way to send him articles related to the quirks of cpp that you don't personally like
BinaryByter
In naturally written C++ code, changing the private members of a class requires recompilation of the code using the class. When the class is used to instantiate member objects of other classes, the rule is of course applied recursively. This makes C++ interfaces very unstable - a change invisible at the interface level still requires to rebuild the calling code, which can be very problematic when that code is not controlled by whoever makes the change. So shipping C++ interfaces to customers can be a bad idea.
BinaryByter
wtf?
BinaryByter
"changing code requires compilation.. buwhuuuhuuuuuhuhuuhuuu 😢😢😢😢"
Mihail
"you can't printf to an iostream" ummmm literally what
BinaryByter
BWHOOHOOOHOOO :(:(:( WHY ISNT OLD STUFF COMPATIBLE TO NEWER BETTER STUFF :(:(:(
Mihail
You printf to stdout
Mihail
Like
Mihail
What is he even saying
BinaryByter
he wants to be able to specify an ostream to the printf function probably
BinaryByter
except printf is already a thing
BinaryByter
and it was already a thing
BinaryByter
before ostreams were a thing
BinaryByter
idk
Mihail
Me neither
BinaryByter
Mihail
I think I've had enough Internet for today tbh
Mihail
Gn
14•08
Gn
Same bro ....
Johnny
Johnny
Can anyone tell me what's wrong?
Johnny
I'm trying to do a bubble sort order
BinaryByter
google the syntax for for
BinaryByter
basically, inCpp, you separate the "arguments" with a ;
Johnny
with a?
Johnny
oh ok
Johnny
oh sorry
Johnny
now that I realized my mistake, what a shame.
Johnny
google the syntax for for
Thanks, if you want, you can delete the messages!
Johnny
😅
Anonymous
o/
Anonymous
helli
Anonymous
hello*
Anonymous
Can I ask about hanging of laptop
Liam
hello*
Error: hello doesn't name a type.
Parra
I do the same with metacall because of that (the plugin system has C interface)
Parra
you avoid nightmares like in v8 with this methodology
Alay
Okay I'll ask the most irritating question What's the best source to learn c++ ?😂
olli
that's why people distributes software with C API sometimes
I doubt this is the reason why C APIs are shipped. This problem applies to C as well if you make a previously "exported"/availabe function static. C makes it really easy to call functions from different languages since no name mangling is needed.
Parra
it doesn't happen in c if you modify a static method
Parra
or at least that what I understood
olli
but.. if you change a private method you change the vtable
No, you don't. First of all the standard does not define "vtable". Second a vtable is generally not present for non virtual classes
Parra
what I mean is that he talk about recompiling if you change a private method
Parra
recompiling the calling application or lib
olli
what I mean is that he talk about recompiling if you change a private method
What he said basically applies to every language. Breaking API changes are nothing special for c++
Parra
if you change a static function only visible in a .c in C language do you have to recompile the calling application?
Parra
I don't think so
Parra
you never have to recompile calling lib/app if you dont touch the API in C
olli
if you change a static function only visible in a .c in C language do you have to recompile the calling application?
Oh I think is misread the initial statement, my bad. However also C does not protect against ABI or API changes. (The standard does not define ABI anyway) To solve this problem you could make use of the PIMPL idiom