19 Dec 2012

Perfect Forwarding to Async Lambdas (Part 2)

In Part 1, the “value of rvalues” was discussed, as well as their use in the context of std::async. A problem was observed with how lvalues are handled, so in this part I will introduce perfect forwarding to deal with rvalues and lvalues generically and try to provide an optimal approach in that context.

Read More... ()
  • c++
  • c++11
  • advanced

18 Dec 2012

Perfect Forwarding to Async Lambdas (Part 1)

Perfect forwarding allows template functions to forward the arguments “as is” to any other function they call. This helps minimize the number of unnecessary copies and conversions when delegating information to other functions. In a quest to get rid of copying completely in a library I was writing, I came across the problem of perfect forwarding to functions launched on a separate thread.

Read More... ()
  • c++
  • c++11
  • advanced

08 Oct 2012

Functionality != Semantics

Very rarely, a case comes up where a new function is required even if it is functionally identical to another one. In these cases another meaning is attached to these functions beyond their interface, and machine instructions; reusing it will actually be counterproductive. We examine such a case I encountered at my workplace.

Read More... ()
  • c++
  • design

21 Aug 2012

Objects and Threads in C++ and Qt (Part 1)

When I first started working on a team using Qt (in a C++ environment), I would hear co-workers talk about “objects being on threads”, and then immediately talk about how several threads are accessing the same object. These two seemingly opposite ideas confused me at first. Let’s untagle the mystery!

Read More... ()
  • c++
  • qt
  • threading