Mihail
especially if it's not just / 2
BinaryByter
Mihail
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
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
klimi
klimi
Ye
klimi
You can convert it to a string
BinaryByter
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
olli
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
Hl
Someone can recommend a source of information or a video and video that explains good about linked lists?
olli
MᏫᎻᎯᎷᎷᎬᎠ
olli
While like 2 hours?
Yes.. I remember building clang on an ~8 year old laptop taking >3 hours
MᏫᎻᎯᎷᎷᎬᎠ
MᏫᎻᎯᎷᎷᎬᎠ
I guess I'll have to wait then
Mihail
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
itsmanjeet
can i initilize a object of class in header file
itsmanjeet
..
Dima
why not
Unknown
Al
array of ...?
Francisco
Unknown
Ludovic 'Archivist'
Ludovic 'Archivist'
Just like sometimes you WILL NOT be able to allocate