Posts tagged C++11

Accessing APIs

:: C++11, API, POCO, HTTP

I was curious about all the great sites I know of releasing their API. Twitter, Google, Facebook, Yelp, are only a few examples of websites providing a way to access their services in a programmatic way. In this post, I have investigated a simple but very interesting API, offered by Rotten Tomatoes, a website about movies.

Use files

:: C++11, files, regex, streams

Chinese Lanterns

Chinese Lanterns

Recently I’ve found myself in the common situation where I have to open a file and make something with its content. This is a basic task and should present no difficulties to a programmer; I happened, however, to get stuck for a while in search of a good way to carry out this apparently simple task. In particular, I have run into the recent addition of regular expression processing to the STL. Spoiler alert: I was not particularly happy of what I’ve found along the way.

Time in C++

:: C++11, chrono, clock, duration, time_point,

Using time: the chrono header

Until before the introduction of the chrono library in the STL with the C++11 standard, we were forced to deal with time in a couple of ways, notably using Boost or using some wrapper around the time.h library header, from C.

Lambdas in C++11

:: C++11, closures, lambdas

Lambda expressions have been introduced to C++ with the most recent standard, presented in Section [expr.prim.lambda]. They allow the creation of simple functions without giving them a name. What are they good for? Being simple is not really the point here; the most useful case that I have found in my limited experience has been as a convenient replacement for Functors (also known as Function objects).

In this post, I’ll give a quick introduction to how to use lambdas in your code. In the next installment, I will discuss a small example of functor, and will show side by side a piece of code with functors and its substitution with a clean lambda.