intermediate

Building Applications with Qt and boost

I'm starting a series on my blog and youtube channel, about building an application in C++:

Building Applications with Qt and boost

by Jens Weller

From the article:

This is the start of a series of posts, in which I'll try to document my weekly work on a new application, build with Qt and boost. This first post is rather short, but I'd quickly try to give you an overview, why I use both Qt and boost in the same application. Regarding Qt, I wrote an introduction a two years ago, also for boost, there is an excellent website/tutorial about boost by Boris Schäling (buy his book! wink). This series is not meant as a general introduction, yet I try to show you how and what I use of Qt and boost.

std::shared_ptr's secret constructor -- Anthony Williams

std::shared_ptr has a secret: the aliasing constructor, that most users don't even know exists, but which is surprisingly useful. 

std::shared_ptr's secret constructor

by Anthony Williams

From the article:

What does this secret constructor do for us? It allows us to construct a new shared_ptr instance that shares ownership with another shared_ptr, but which has a different pointer value...

 

 

CppCon 2014 Hourglass Interfaces for C++ APIs--Stefanus DuToit

Have you registered for CppCon 2015 in September? Don’t delay – Registration is open now.

While we wait for this year’s event, we’re featuring videos of some of the 100+ talks from CppCon 2014 for you to enjoy. Here is today’s feature:

Hourglass Interfaces for C++ APIs

by Stefanus DuToit

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

C++ provides a much richer set of abstractions than C. Classes, templates, overloading, and other core C++ features can be leveraged for more readable syntax, better compile time typechecking, more open ended genericity and improved modularity. On the flip side, C89 still boasts some advantages over C++, especially when viewed through a pragmatic lens. C ABIs on many platforms have been stable for decades, practically every language supports binding to C code through foreign function interfaces, and including nearly any C89 header has a negligible effect on compile time on modern computers.

The Hourglass pattern provides the best of both worlds. It's a way to structure libraries that retains the pragmatic benefits of C89 while still providing C++'s richness both at an interface and implementation level. It makes providing bindings from other languages to C++ libraries easier, and insulates from ABI issues such as incompatibilities between debug and release variants of runtimes. This talk provides an overview of the pattern, teaches practical techniques for its implementation using C++98 and C++11, and shares experience from using the pattern in real world projects.

RVO V.S. std::move -- Zhao Wu

Discussion about the RVO optimization technique & std::move.

RVO V.S. std::move

by Zhao Wu

From the article:

To summarize, RVO is a compiler optimization technique, while std::move is just an rvalue cast, which also instructs the compiler that it's eligible to move the object. The price of moving is lower than copying but higher than RVO, so never apply std::move to local objects if they would otherwise be eligible for the RVO.

CppCon 2014 C++ Test-driven Development--Peter Sommerlad

Have you registered for CppCon 2015 in September? Don’t delay – Registration is open now.

While we wait for this year’s event, we’re featuring videos of some of the 100+ talks from CppCon 2014 for you to enjoy. Here is today’s feature:

C++ Test-driven Development

by Peter Sommerlad

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

Unit Testing and TDD, if applied correctly, lead to high quality and simple code. If done by hand, both often require writing some boiler-plate code and can be slow and cumbersome. Especially refactoring without good tool support can be a burden. Java and C# developers are used to have good tool support for these tasks to be effective. Many C++ developers often aren't even aware of the need for the practices, because without tool support and training of the goals, they are hard to discover.

This talk introduces C++ Unit Testing, Test-driven Development, and Refactoring and demonstrates the tooling available for Eclipse CDT for free on www.cevelop.com that was inspired and implemented by the author and his team.

For example, when phrasing a unit test to use a to-be-defined class, the class is generated automatically from its name used as a type. Another tool feature is simplifying a function, by extracting a sub-function and placing a call in its place.

Efficient optional values -- Andrzej Krzemieński

Andrzej goes into some details of optional values in his recent blog post.

Efficient optional values

by Andrzej Krzemieński

From the article:

What do you use Boost.Optional for? In my experience, the answer was typically one of the following:

  1. Because my type T has no null state (like -1) that would indicate that I have no proper value.
  2. Because, I need to perform a two-phase initialization (I cannot initialize my T yet, but I already need it alive).
  3. Because I need an interface that would indicate to the type system that my value may not be there and that its potential absence should be checked by the users.

In this post we will focus exclusively on the third motivation.

PeriodicFunction--Tony “Bulldozer00” (BD00) DaSilva

An interesting article showing how to call a function periodically:

PeriodicFunction

by Tony “Bulldozer00” (BD00) DaSilva

From the article:

In the embedded systems application domain, there is often the need to execute one or more background functions at a periodic rate. Before C++11 rolled onto the scene, a programmer had to use a third party library like ACE/Boost/Poco/Qt to incorporate that functionality into the product. However, with the inclusion of std::thread, std::bind, and std::chrono in C++11, there is no longer the need to include those well-crafted libraries into the code base to achieve that specific functionality...

Cache-friendly binary search--Joaquín M López Muñoz

An interesting approach to sorted search:

Cache-friendly binary search

by Joaquín M López Muñoz

From the article:

High-speed memory caches present in modern computer architectures favor data structures with good locality of reference, i.e. the property by which elements accessed in sequence are located in memory addresses close to each other. This is the rationale behind classes such as Boost.Container flat associative containers, that emulate the functionality of standard C++ node-based associative containers while storing the elements contiguously (and in order)...

Set-up and tear-down--Andrzej Krzemieński

Today, you have an article about a specific aspect of unit-testing:

Set-up and tear-down

by Andrzej Krzemieński

From the article:

Recently as part of program run-time performance optimization effort, I was scanning through the code for occurrences of keyword new. The goal was to find unnecessary memory allocations. I was surprised to find most of news in the unit test module. Not that there was any particular need for memory allocation: it is just that the framework that was chosen (a fairly popular one) enforces on the programmers bad practices of manually controlling the life-time of their objects...