Move semantics in C++ – Move-return of local variables
My understanding is that in C++11, when you return a local variable from a function by value, the compiler is allowed to treat that variable as an r-value reference and ‘move’ it out of the function to return it (if RVO/NRVO doesn’t happen instead, of course).
Who is to blame for this range based for over a reference to temporary?
The following code looks rather harmless on first sight. A user uses the function bar()
to interact with some library functionality. (This may have even worked for a long time since bar()
returned a reference to a non-temporary value or similar.) Now however it is simply returning a new instance of B
. B
again has a function a()
that returns a reference to an object of the iterateable type A
. The user wants to query this object which leads to a segfault since the temporary B
object returned by bar()
is destroyed before the iteration begins.
Who is to blame for this range based for over a reference to temporary?
The following code looks rather harmless on first sight. A user uses the function bar()
to interact with some library functionality. (This may have even worked for a long time since bar()
returned a reference to a non-temporary value or similar.) Now however it is simply returning a new instance of B
. B
again has a function a()
that returns a reference to an object of the iterateable type A
. The user wants to query this object which leads to a segfault since the temporary B
object returned by bar()
is destroyed before the iteration begins.
Too many parameters to data processing class constructor
I have a conceptually simple application: data comes in as small encrypted packets, they decrypted and validated, some are stored in the database, some rules are applied, and a reply might be encrypted and sent. Packets arrive at a rate of high hundreds of thousands per thread per second, so performance is a consideration. I am leaving out most of the performance elements here to focus on the design.
Message Queue for RTOS for microcontrollers
I’m currently writing an RTOS for microcontrollers. The whole thing is written in C++11 – if anyone is interested, and the link to the repository is at the bottom.
Why lambda/closures expressions came so late to C++?
I was reading a really great Bjarne Stroustrup’s article where he exposes some C++ myths.
I look at code that focus my attention, because I wouldn’t know that C++ supports this kind of expressions. I’m talking about lambda expressions, or closures.
Why lambda/closures expressions came so late to C++?
I was reading a really great Bjarne Stroustrup’s article where he exposes some C++ myths.
I look at code that focus my attention, because I wouldn’t know that C++ supports this kind of expressions. I’m talking about lambda expressions, or closures.
How to make max-heap stable with counter and account for counter overflow?
Generally I need size-efficient data structure similar to std::priority_queue
but stable (preserving order of insertion).
How to make max-heap stable with counter and account for counter overflow?
Generally I need size-efficient data structure similar to std::priority_queue
but stable (preserving order of insertion).
How to deal with historic exception specifications in maintained C++ code
Today, I discovered a few exception specifications in legacy code I’ve to maintain, when Cppcheck 1.68 ([Inconclusive]
but correctly) pointed out that the specified exceptions are not handled in specific portions of the code.