Mihail
so » can't hurt ¯\_(ツ)_/¯
except that it can make your code a bit harder to understand
Mihail
especially if it's not just / 2
BinaryByter
BinaryByter
¯\_(ツ)_/¯
BinaryByter
lol
Anonymous
same sample in Rust struct A {} impl A { fn test() -> B { let b = B {}; return b; } } struct B {} impl B { fn test() -> A { let a = A {}; return a; } } it works !
BinaryByter
By introducing block scope
Anonymous
this code is similar to.... class A; class B; class B { A test() { A a; return a; } }; class A { B test() { B b; return b; } };
BinaryByter
except C++ doesnt have a blockscope
BinaryByter
+ doing that is stupid
Anonymous
no, this is C++ compiler stupidity
BinaryByter
you are free to leave the group if you dont like C++
BinaryByter
again: i can't imagine a case where you'd need to do that
Anonymous
this sample is striped version from real code
Anonymous
this is NOT my imagination. it's real needs
BinaryByter
can you tell me what exactly you are trying to achieve?
BinaryByter
Circular dependencies in OOP are not really a good sign
Anonymous
I am doing binary packs parser
Anonymous
each pack is encapsulated in class
Anonymous
But come pack fields have as content, other packs
BinaryByter
Instead, make a function that returns binary packs
BinaryByter
Packs contain a std::vector of packs
BinaryByter
if the pack need no more parsing, just dont use that field
BinaryByter
if it does need more parsing, put the packs into the vector
BinaryByter
now, this solution is inefficient since you have a spare std::vector
BinaryByter
Instead, make a base class for packs
BinaryByter
and make two inherited classes
BinaryByter
one for fully parsed packs
BinaryByter
and one for packs needing more parsing
Anonymous
a pack can looks like this class v3List { public: Cursor * data_; float x() {return (intBitsToFloat(get_bytes(data_->base.bytes, 0, 4))) ;} void x(float src) { set_bytes(*(uint32_t*) & (src), 4, data_->base.bytes, 0); } float y() {return (intBitsToFloat(get_bytes(data_->base.bytes, 4, 4))) ;} void y(float src) { set_bytes(*(uint32_t*) & (src), 4, data_->base.bytes, 4); } float z() {return (intBitsToFloat(get_bytes(data_->base.bytes, 8, 4))) ;} void z(float src) { set_bytes(*(uint32_t*) & (src), 4, data_->base.bytes, 8); } class Vector3 w() { if(data_->base.field_bit != 96 && !set_field(data_, 96, -1)) return nullptr; v3List ret{nullptr, data_->base.bytes + data_->BYTE }; return ret ; } class Vector3 w(class Vector3 * src) { if(data_->base.field_bit != 96) set_field(data_, 96, 0); uint8_t* bytes = data_->base.bytes + data_->BYTE ; if(src) memcpy(bytes, src, data_->item_vals); v3List ret{nullptr, bytes}; return ret; } };
Anonymous
some pack fields return and set primitives but field < w > return other pack by VALUE
Anonymous
this is not fantasy this is real project https://github.com/cheblin/BlackBox
Eduardo
Is it possible to convert and int number to an string array number by number?
Anonymous
I am trying to build C++ code generator. Just finished Rust generator
klimi
Ok
Anonymous
I know, my code is not fully ncorrect.. it is in refactoring process
Eduardo
What do you mean by number
Like, 1234 to string[0]=1,...
klimi
Ye
klimi
You can convert it to a string
Bader
OOP in general is more often than not bloat
That's what it seems, even though EVERYONE uses it haha
BinaryByter
That's what it seems, even though EVERYONE uses it haha
Yea usually 'everyone' has got no clue
BinaryByter
But most more advanced devs look further than their oop textbook
Bader
right. what paradigms would you look at?
BinaryByter
You should know them all
BinaryByter
But doing 'everything must be oop' ends up in java
Bader
Haha yep.
Bader
Lately been into Reactive programming
Light
/purge
Bader
it utilizes elements from functional programming, but emphasizes a lot more on async streams
Anonymous
FIXED class A; class B { A test(); }; class A { B test() { B b; return b; } }; A B::test() { A a; return a; }
Anonymous
oop? I am just using language properly, and getting what I can fully. it can be C https://github.com/cheblin/MAVLink2BlackBox_Demo/blob/master/ardupilotmega/InC/MicroAirVehicle/MicroAirVehicle.h
MᏫᎻᎯᎷᎷᎬᎠ
GCC 9.1 Released https://lwn.net/Articles/787385/ https://redd.it/bk7uha @r_cpp
MᏫᎻᎯᎷᎷᎬᎠ
olli
What is it?!🙃
Coroutines? Basically the async / await pattern. Since the compiler is completely aware of the internal state it can also perform some optimizations. Additionally I like how it can increase readability. To switch a thread you could write // Running on any thread ... co_await runOnUiThread(); // Now running on UI Thread
MᏫᎻᎯᎷᎷᎬᎠ
Got it
MᏫᎻᎯᎷᎷᎬᎠ
GCC 9.1 Released https://lwn.net/Articles/787385/ https://redd.it/bk7uha @r_cpp
Btw Has anyone tried to install it??! I'm installing it right now But when I wrote make in terminal It just takes forever l
Hl
Someone can recommend a source of information or a video and video that explains good about linked lists?
olli
While like 2 hours?
Yes.. I remember building clang on an ~8 year old laptop taking >3 hours
MᏫᎻᎯᎷᎷᎬᎠ
I guess I'll have to wait then
Mihail
That would be very slow indeed
Mihail
And you'd get backends for all the languages gcc supports
Mihail
You probably should've set some options when building it
Ludovic 'Archivist'
Ok then In what cases should I use selection sort,merge sort and insertion sort I am very much confused and this type of question is asked in interviews. How will a programmer know in advance that his data will be partially sorted of not and now its time to apply insertion sort in this case
Mergesort is a nice stable sort, it can also be implemented so that it doesn't require allocating a buffer space. Insertion sort is stable but require a new place for the data, so you will allocate more space for things to work. Low efficiency sorts like bubble sort are very nice for datasets that are almost sorted and/or small.
itsmanjeet
can i initilize a object of class in header file
itsmanjeet
..
Dima
why not
Al
array of ...?
Francisco
Ok but my question is how will a programmer know in advance that his array is almost sorted ?I don't think that it is possible practically.
Well, depends entirely on the data you're using. With that, you may have a hint about its layout
Ludovic 'Archivist'
Ok but my question is how will a programmer know in advance that his array is almost sorted ?I don't think that it is possible practically.
It depends on what you actually do, sometimes you WILL have data that is explicitly partially sorted
Ludovic 'Archivist'
Just like sometimes you WILL NOT be able to allocate