Patrick
I use g++ on Ubuntu
Anonymous
what about sizeof?
It doesn't work that way
Anonymous
I use g++ on Ubuntu
https://github.com/gcc-mirror/gcc/tree/master/libstdc%2B%2B-v3 Probably this one
Anonymous
why?
Because you have no access to the control block type
Patrick
https://github.com/gcc-mirror/gcc/tree/master/libstdc%2B%2B-v3 Probably this one
Thank you! Now to read some very complicated source code 😂
Patrick
Waw, that sounds like one way to do it yeah... All I could find so far is the shared and weak counters are atomic words
Patrick
I mean size wise, that it's two words
Anonymous
Thanks! Didn't know that
Patrick
Mmmm, I think it's the size of an int though
Patrick
I thinkkkk my curiosity isn't so strong actually 😂 I'm just glad I went with my own reference counting rather than shared_ptr
Patrick
I'm reinventing the wheel because I know I won't use weak pointers, I know it's single-threaded, I know I'll never have more than 255 copies, so it's not too complex to implement
Patrick
It has reduced the size of my most passed around object from 24B to 8B per reference and other memory I was trying to find out
Patrick
so skinny, fast :) I'm unsure about your second question though
Patrick
It's not, I'm writing a VM for a programming language I'm making
Patrick
I'm just afraid of getting it wrong, I'm not a very strong C++ programmer. I've covered the "big 3", construction, copying, assignment, and then destruction
Anonymous
I'm just afraid of getting it wrong, I'm not a very strong C++ programmer. I've covered the "big 3", construction, copying, assignment, and then destruction
You need to cover "big 5": 1) default constructor 2) copy constructor 3) copy assignment 4) move constructor 5) move assignment
Patrick
Ohhhh, thank you
Patrick
Though I've never actually used std::move before, I suppose that's what 4/5 refer to?
Marcelo
Could someone recommend me a tutorial or book about bootloader?
Patrick
You didn't read the pinned message
Amit
In the example: Class Entity { // }; Entity e; e= Entity (8) string s = "stringval" ;
Anya
Can some one help me with CS and Data science??
Amit
In the example: Class Entity { // }; Entity e; e= Entity (8) string s = "stringval" ;
Why we pass value to object ....typecasting value (8) with class name......but for string directly pass the string?
Amit
In the example I can directly pass integer value like : Entity e= 8;
Amit
So what's the point of typecasting integer value with class name like ( Entity (8) )
Amit
Okie will check
Alex
std::map<unsigned int, const cmap_t&> cmap_cache; this works const cmap_t &v = cmap_cache.at(5); this produces lots of template compilation errors const cmap_t &v = cmap_cache[5]; I suspect this is about reference forwarding. does anybody know?
Artöm
Use pointers or reference_wrapper
Alex
You cannot store references in std containers
https://stackoverflow.com/questions/24719044/unordered-map-with-reference-as-value
Artöm
Edited
Pavel
You cannot store references in std containers
that's also not completely true
Artöm
that's also not completely true
Yeah, my mistake, didnt know its a thing
Dima
#ot
Alion🦁
It's okay Danya, don't have a spite against me 😃
Hermann
if i have mpzt array i hava to inits all elements?
Artöm
mpzt?
Hermann
is bad way free pointer inside loop?
Hermann
is it wrong to free pointer memory inside a loop? because if I free the memory after the loop, some of the information will be overwritten instead of being freed.
Yash
Anyone have a question bank for competitive programming on DSA..?
Jano
Hi, please somebody understand the use of two assert her👆
Antonio
Hi good day, I need help.. I am trying to use the wampcc library in a Qt application. Qt version: QtEmbedded-4.8.6-arm Toolchain: 4.9.3 (arm-cortexa9-linux-gnueabihf) But when compiling, many errors appear: 4.9.3 / chrono: 221: 6: error: macro "max" requires 2 arguments, but only 1 is provided Checking chrono the error it is inside the block "#ifdef _GLIBCXX_USE_C99_STDINT_TR1" which is not defined. Any idea of ​​the problem?
Antonio
My problem is similar to the one posted at https://stackoverflow.com/questions/55364206/qt-5-8-compile-issues-with-stdchrono
Amit
In the code: Class Complex{ Public: Double real Double imag; Bool operator==(Complex rha){ Return(real ==rha.real && imag==rha.imag)? True:false; } }; Int main(){ Complex com1(3.0,3.0); If(com1== 3.0) //Do something
Amit
My doubt here is......if we calling overloaded operator as (com1==3.0)....we should insert two arguments into the overloaded function declaration right? One the object com1 and other is the number may be?
Amit
What I don't understand -> how we decide what goes inside operator overloading function's arguments while declaring
Antonio
Do not directly include any header files that do this. I did a test compiling an example of using the wampcc library without using Qt and using the same toolchain and it compiles without problem. So I think it has to do with Qt.
Antonio
Antonio
yes, is chrono lib. Ok, I search in the Qt headers.
Amit
Guess I want to overload this operator (<<) left shift operator to print string class obj like: Cout<<string (string header file not included)
Amit
So in defination Class string{ Public: Char *str; String& operator<<( const string& other) { //Here is passing just the string //obj is sufficient enough to print the string....as overloaded func is now a class member? } };
Amit
Calling this as - String s = "xyz"; Cout << s;
Amit
Yeah that's what I understand.....so the question again come down to how will I decide what all goes inside the overloaded func arguments?
Amit
Like the operator is written between two operands? So do I need
Amit
To pass those two operands as arguments
Antonio
I looked in the entire QtEmbedded-4.8.6-arm folder and did not find that definition. I only found it in 2 files but from the ..toolchain/4.9.3 .. /opt/scv/toolchain/4.9.3/arm-cortexa9-linux-gnueabihf/sys-root/usr/include/sys/param.h /opt/scv/toolchain/4.9.3/lib/gcc/arm-cortexa9-linux-gnueabihf/4.9.3/plugin/include/system.h
Anonymous
I'm new to C, where should i start learning Any tips guys
Amit
I understand overloaded func being class member and outside class logic....I was struggling for for urinary and binary operators
Amit
Will check some examples on that
Amit
Btw just one thing.... can't a unary operator be overloaded as a binary operator func?
Amit
Cool....that's clear the confusion ... thanks 👍
Antonio
Ok, one question.. I understand that a code block that is inside of #ifdef, is only compiled if the value is defined, is it correct? I ask why the lines where the error indicates is inside a block, which if value is not defined (#ifdef _GLIBCXX_USE_C99_STDINT_TR1).
Antonio
I don't understand why if _GLIBCXX_USE_C99_STDINT_TR1 is not defined, the errors appear?
Amit
In the following code: Class Entity { Public: Entity(int x){} Entity(const string & s){} }; Int main() { Entity e= 5;. //valid Entity s= "value";. //not valid?? //Needed to Entity s= Entity("value");
Amit
Here in example why I no need to typecast the integer while passing to object
Amit
But need to typecast string value to pass to object???
Amit
I have already read a quite some stuff on c++..... cannot understand typecasting here
Amit
As most of the implicit conversation takes place for string object
Amit
Yeah that solves the confusion 👍
Amit
But then: Entity e1= "value";. //Invalid for obvious reasons Entity e2(" value") ; works fine for some reason
Amit
How const char* "value" passed in second case get converted to string object there
Amit
Ok got it's.....seems like copy intiliazation is intializing a object Entity e1 with another object "value"(const char*)....so that we need to explicitly typecast "value" here to Entity type