F5 Case Study: LineRate's C++98 to C++11 Migration -- Lenny Maiorani

f5-linerate.PNGFresh on the F5 dev blog:

Case Study: LineRate's C++98 to C++11 Migration

by Lenny Maiorani

From the article:

Have you heard about C++11 and the huge changes in the language?

Are you terrified to turn on the flag in your compiler?

Are your developers clamouring for modern language features?

The LineRate team['s ...] migration to [modern] C++ has been a breeze...

Add a Comment

Comments are closed.

Comments (2)

0 0

Random said on Nov 11, 2014 05:01 AM:

There are many errors in this article (I don't have an account at the site, so I can't post there):

1:
if (myT)
is considered an explicit bool cast, so is not in fact an error.
2a: "std::make_pair<T,U> args must be rvalue references" this is wrong. make_pair has forwarding references as arguments, which can be lvalue or rvalue.
2b:
std::pair<int, int> pairMaker(int v1, int v2) {
return std::make_pair(v1, v2); // error!
}
<- not an error
4:
q.reset(p.release()); // OK
ugh. The correct way to move ownership between unique_ptrs is std::move:
q = std::move(p);

5: This is a wierd one. It seems to only be an error because unique_ptr has overloads for both nullptr and "pointer". Ironically, if it didn't have the nullptr overload 0 would actually work.
0 0

Juan Alcántara said on Nov 16, 2014 01:01 PM:

When you put that example of case 2

std::pair<int, int> pairMaker(int v1, int v2) {
int a{v1}, b{v2};
return std::make_pair(a, b); // OK
}

std::pair<int, int> pairMaker(int v1, int v2) {
return std::make_pair(std::move(v1), std::move(v2)); // OK
}

I think you missed to differentiate the copy vs the move, are the same and there isn´t overloading, this maybe can lead that the move function is never called, i dont know for sure