C++ code samples before and after Ranges

The Ranges library proposal has been accepted for C++20 at the San Diego meeting of the standard committee in November last year. The library provides components for handling ranges of values aimed at simplifying our code. Unfortunately, the Ranges library is not very well documented, which makes it harder to grasp for those that want to learn it. This post is intended as an introduction based on examples of code written with and without Ranges.

Join the East Const revolution!

The C++ community has worked hard in the past decade and more to move the language forward, to enrich but also simplify it, and to adopt new paradigms and coding styles. Yet, a single topic, a simple matter of style is splitting the community, in a pure Swiftian manner: the use of the const qualifier that some prefer it on the left of what it modifies, as it has been the de facto standard for decades, and which is now called West const, or to the right of that it modifies, that is a style that more and more people are adopting, and which is now called East const. I don’t particularly like this terms, I would rather use left const and right const, but if this is what the community prefers to use let’s call them so for consistency.

moneycpp – a C++ library for handling monetary values

I have been working lately on a C++ library for handling monetary values, currencies, rounding and other related features. It is called moneycpp and it’s a C++ 17 header-only, cross-platform library available on GitHub.

The library is intended for being used in a variety of types of application including ERP systems, banking, finance, insurance, games, and others.

The following is a list of its core requirements:

When a type is not a type

Class template argument deduction is a useful feature in C++17 that helps developers to simplify the code by avoiding writing the template argument list when initializing objects of class templates (or when performing function-style casts). The compiler provides an implicit set of deduction guides, which are fictional function templates for a hypothetical class and uses them to perform template argument deduction and overload resolution. However, you can extend this set of deduction guides with your own, and in some cases, such as for aggregate types, you need to do so.

croncpp – a C++ library for CRON expressions

A CRON expression is a string composed of six fields (in some implementation seven), separated by a whites space, representing a time schedule. CRON expressions are used in various job schedulers (such as the Linux job scheduler, the Quartz scheduler, Azure scheduler for functions, etc.). Recently, I have written a C++ library for parsing such expressions and determining the next occurrence of the scheduled time. The library is called croncpp. It is written in C++17, is header-only, open-source and cross-platform, and can be found on GitHub.