Artöm
Need the safety of Rust And need some magic of C++
Rust allows decent amount of magic with unsafe
MᏫᎻᎯᎷᎷᎬᎠ
Which is about the most awful thing.
Wait what?! Compile time code is what make most of modern C++ super freaking fast
Artöm
Nahh C# is cool but I put off easily with GC languages
C# has lots of ways to work without gc
MᏫᎻᎯᎷᎷᎬᎠ
Rust has it
Yeah Does rust has that awesome support of Metaprogramming as well?!
MᏫᎻᎯᎷᎷᎬᎠ
I don't think so
MᏫᎻᎯᎷᎷᎬᎠ
I put of from Rust after Actix
MᏫᎻᎯᎷᎷᎬᎠ
They are closing the doors rn
jot.rs
Yeah Does rust has that awesome support of Metaprogramming as well?!
It does. There are almighty procedural macros and constexpr functions
MᏫᎻᎯᎷᎷᎬᎠ
It does. There are almighty procedural macros and constexpr functions
Okay How about trying to make some variadics like parameters in a function or a struct?!
MᏫᎻᎯᎷᎷᎬᎠ
It doesn't even has function overload And they don't even have plans to implement them!!!
jot.rs
I guess discussing rust design is outside of this chat's scope 😆
MᏫᎻᎯᎷᎷᎬᎠ
See why I didn't want to give my reasons?
Artöm
Rust has no variadic parameters and that's for good
https://doc.rust-lang.org/std/primitive.tuple.html
jot.rs
It doesn't even has function overload And they don't even have plans to implement them!!!
Actually you don't need function overloading when you have generics
MᏫᎻᎯᎷᎷᎬᎠ
Actually you don't need function overloading when you have generics
Okay Why I can't have generics specialization in rust?!
Anonymous
I am new to C++, is reference good for beginners?
MᏫᎻᎯᎷᎷᎬᎠ
struct Object<T>; struct Object<u32>;
MᏫᎻᎯᎷᎷᎬᎠ
Unless it's in the impl block
MᏫᎻᎯᎷᎷᎬᎠ
And that's maybe good enough
MᏫᎻᎯᎷᎷᎬᎠ
MᏫᎻᎯᎷᎷᎬᎠ
https://doc.rust-lang.org/std/primitive.tuple.html
You see the magic of C++ here?! Rust has built-in tuples C++ didn't need to have built-in support It can be done only through bare hands of programmers by using bare hands of ordinary programmers like you and me
MᏫᎻᎯᎷᎷᎬᎠ
I'm not talking whether C++ is better than Rust or not Don't get me wrong ;)
MᏫᎻᎯᎷᎷᎬᎠ
what else?
std::variant It's like enum in rust
jot.rs
ок
MᏫᎻᎯᎷᎷᎬᎠ
ок
The most cool part of Rust is its pattern matching mechanism❤️
MᏫᎻᎯᎷᎷᎬᎠ
Btw There is a C++ pattern matching library out there Here you can check it https://github.com/mpark/patterns
MᏫᎻᎯᎷᎷᎬᎠ
jot.rs
Where? XD
I don't remember, but code looked like foo<A> foo<A, B> foo<A, B, C> …
salamandra
Hii
klimi
salamandra
I am Italian, but I understand something in English. I didn't understand one thing about the rules: can I ask something that I didn't understand about C ++ at school?
Anonymous
I am Italian, but I understand something in English. I didn't understand one thing about the rules: can I ask something that I didn't understand about C ++ at school?
Yes, sure you can You cannot ask somebody to solve your assignment But you can ask questions about C++ you don't get (preferably with googling before asking) and if you faced problems while doing your assignment, you can ask how to solve the problems (google before asking too)
salamandra
I checked on Google an exercise created in mind, but I found ways that not even the teacher wants. I have to merge two vectors into a third vector. Just to understand how
salamandra
Tell me if you understand.
Anonymous
no, just fusion
In random order?
Anonymous
Or what?
salamandra
Anonymous
Do not send pictures of screen
salamandra
Thanks for helping me understand
Anonymous
Did you understand actually?
Artöm
Tell me if you understand.
Ez // std::vector<T> v1, v2 std::vector<T> v3(v1.length() + v2.length()); std::copy(v1.begin(), v1.end(), v3.begin()); std::copy(v2.begin(), v2.end(), v3.begin() + v1.size());
Artöm
Make third vector, copy first, copy second
Artöm
Corrected
Anonymous
And shouldn't it be back_inserter?
Artöm
It could, but I created all elements initially
Anonymous
Oh yes
Anonymous
You're right
Artöm
Other option is reserve + inserter. Only one if T is not default constructible
Anonymous
It's just when you create ArrayList in Java the capacity, not the size
Artöm
Rewrite it using for and if then, algo is pretty straightforward
qwert
We don't use this. I have to use for + if (maximum one support variable).
void AddSrcToDst(const std::vector<T>& src, std::vector<T>& dst) { // for cycle } int main() { std::vector<T> vec1 {1,2,3}; std::vector<T> vec2 {4,5,6}; std::vector<T> vec12; AddSrcToDst(vec1, vec12); AddSrcToDst(vec2, vec12); }
Dima
/ban S A adding members of this group to random channels
Anonymous
Hey guys can someone help me to create user profile using firebase in web page
Dima
Go to #ot
Dima
#ot
Dima
Link is dead lol