Alex
https://www.geeksforgeeks.org/map-associative-containers-the-c-standard-template-library-stl/
Pavel
Is there a difference in calling push_back and emplace_back on an rvalue reference? I mean we have std::vector<T> vec; and doing vec.push_back(std::move(value)); or in the same situation doing vec.emplace_back(std::move(value)); Will it be default constructed then move assigned in the first case? Or it will be just move constructed in both cases?
Pavel
you do it wrong. you should provide arguments of costructor T in emplace_back, not T value
Yes, but I already have an object that I want to move to this container, so I'm actually providing arguments of a constructor (move constructor)
Alex
or it will compile using move constructor
Alex
in the first move constructor will be called. the second is weird.
Alex
I suppose T(T&&) will be called, and the the result is emplaced. like T t(T&&) if no optimization
Pavel
So I've made a test: created a class that has its default constructor and move assignment operator deleted as well as copy constructor and copy assignment operator. So only move constructor is left from the default 5. It successfully passed with these two variants as T, so I guess these are the same in this case (and push_back is preferable as it is less weird).
Marián
Marián
ok this got me, fucking relatable
Pavel
😄
Artöm
That said, emplace_back can be worse for eg std::map. For vector it should be same
Artöm
I meant emplace vs insert
Anonymous
oh
Anonymous
even then, there should be no reason for emplace to be worse
Ballack Osei Antwi
Hi
Ballack Osei Antwi
Pls can someone assist me on this work
Ballack Osei Antwi
Dima
Pls can someone assist me on this work
Try to write a code yourself, it’s very easy.
Liam
Yes, but I already have an object that I want to move to this container, so I'm actually providing arguments of a constructor (move constructor)
In this case, there is no difference between calling emplace_back and push_back, since push_back has a rvalue-reference version, which will call the move constructor of T.
Pavel
Thanks guys for your answers
Mercy
Thank you
Anonymous
Kk
Anonymous
I want to hack wifi password anybody help me
Anonymous
Plz
Anonymous
No
Why
Anonymous
I need help
klimi
Why
Read rules
klimi
I need help
Sure... I can help you with some normal stuff...
Monday Morning
I want to hack wifi password anybody help me
You can afford a smart phone and use telegram but can't manage to pay for wifi ?!? Sort out your priority man
☬ੴ Bassi
guys what woudl you say is the best interactive online place to learn cpp
klimi
Cuz it has short URL :D
☬ੴ Bassi
Stefan
this is not wpa that uses rc4 anymore
Abimbola
Thanks I know it so hard
Abimbola
Thanks I know it so hard
well maybe I should learn c before cplusplus because I saw this really really good game engine written in c and c plus plus the name of the game engine is gold SCR
Stefan
i started learning c++ since 14 so
Stefan
its ok i guess
Abimbola
i started learning c++ since 14 so
I am 11 check my profile you will know
Stefan
and to be honest, i taught it myself, that's why i sucked at algorithm because i haven't received proper education on this back in the day
Stefan
logic and algorithm/ds is much harder
Stefan
and if you wrote program long enough, you'll realized that they're all just the same
Anonymous
You really miss a lot of important topics when you're self taught. Things have changed now I guess with the availability of resources and the web.
Stefan
despite i have no formal proof
Abimbola
I think I need a mentor in c get started and start making my games thank you
Stefan
its more important to learn something called linear algebra if you want to make games tbh
j
I am 11 check my profile you will know
why dont you go play to the park?
Stefan
learning physics is a plus
klimi
Abimbola
Abimbola
Some game engine are written in it
j
c++ is used for games
Mar!o
its more important to learn something called linear algebra if you want to make games tbh
I don't think so. For math like vectors, matrices and quaternions you can use a library. And gameplay programming only requires basics
Anonymous
YouTube level is quite high but in school you will get it in more uniform package
From what I've experienced school is more about the building blocks. From Logic ( programming language) to some industry ones, they're usually taught in order to get familiar with the methods so you can "think" that way
klimi
Depends on school
klimi
You can chose practical or theoretical
Stefan
I don't think so. For math like vectors, matrices and quaternions you can use a library. And gameplay programming only requires basics
and how you control these variables like position, view angle and collision box and stuff? they are all LA anyway
Mar!o
Some game engine are written in it
Sure but you want some more abstraction and tools for games. Good luck rewriting a std::vector every time you need it in a game in C
Abimbola
Algebra and physics sounds hard and boring
Anonymous
I don't think so. For math like vectors, matrices and quaternions you can use a library. And gameplay programming only requires basics
Algorithms is a must to be honest. You need to know the optimization strategies even for simple games :_: