« first day (1927 days earlier)      last day (930 days later) » 

12:01 AM
2. taking T&& in deduced context is actually "universal reference" or "forwarding reference" and means different template argument type deduction rules. In deed this is where the perfect forwarding comes in as you expected. godbolt.org/z/eczoxx6j6
(here the copy and the move are avoided, instead the member is directly constructed from the argument value)
Typically, yes. `T const&` doesn't **need** to lead to copy semantics (because the receiver might actually store a const reference or read-access through it).
Neither does `T&&` **need** to lead to move semantics (as I mentioned before: `std::move()` is still required and might be a on conditional code path.
 
OK, thanks. I got some reading to do. I will look closely at your examples from godbolt in a couple of hours
got some sleepng to do first :p
2 am...
 
Night!
 
@sehe Back from work. Where are you located? I thought it's the Netherlands??!
 
It is
So it's also late here
 
12:08 AM
What time is it there? By the way, I am in the Boston area, US
 
2:08am
 
I wanted to talk to you right after work, but checked the time there and realized it's too late.
I think it would be nice to have a different room if that's okay. I need a teacher who can help me learn c++. Learning by myself is just taking too long especially with this language haha.
@sehe Okay, I will try to figure out how to deal with this io_context and threading stuff tonight. Will update you whether I was successful or not.
 
 
6 hours later…
6:10 AM
@sehe thanks for that
 
6:34 AM
Hi guys, can anyone help me understand this for loop?
void Truckload::listBoxes() const
{
const size_t boxesPerLine{ 4 };
size_t count{};
for (Package* package{ m_head }; package; package = package->getNext())
{
std::cout << ' ';
package->getBox()->listBox();
if (!(++count % boxesPerLine)) std::cout << std::endl;
}
if (count % boxesPerLine) std::cout << std::endl;
}
I particularly don't understand the condition in the for loop which is just 'package'
 
 
2 hours later…
nwp
8:21 AM
@Electrical_engineer_student The middle is evaluated like a bool. package is a Package* and pointers are convertible to bool. nullptr is evaluated as false and everything else is evaluated as true similar to integers. Effectively the loop keeps going until eventually package->getNext() returns nullptr which means you ran out of packages.
 
 
6 hours later…
2:27 PM
Say I have a function that excepts a lot of parameters, and is called multiple times in another function where each time only 1 or 2 parameters are changed. I thought about packing all the parameters inside a struct and passing the struct instead, thus reducing duplication of code. Is this a common idea to do?
 
nwp
It's generally very difficult to tell what the average C++ programmer does, but it seems obvious and useful enough to me that I assume most of them do it.
It's especially good if you can give that struct a decent name.
 
 
4 hours later…
6:05 PM
@Eminem yes, other strategies include a more OOP approach to avoid passing arguments.
void step1(args); void step2(args); void step3(args);
becomes
struct runner()
{
runner(args);
void do_steps();
void step1();//args part of the constructor
void step2();
void step3()
}
 

« first day (1927 days earlier)      last day (930 days later) »