All posts in "Expressive code"

Getting Along With The Comma Operator in C++

Published July 31, 2018 - 11 Comments
comma operator C++

The comma operator is a curious operator and seldom used, but it happens to encounter it in code. And sometimes by mistake. Such encounters can give a hard time understanding the code. For this reason it is useful to know what it does, and what it doesn’t do. This article is not made to show […]

How to Convert a String to an int in C++

Published July 24, 2018 - 14 Comments

Today’s guest post is written by guest author jft. In this article, he presents us a thorough comparison between the various ways C++ offers to extract number from a string. You will see how they differ from each other in terms of features as well as in term of ease of use in code. Interested […]

Simplicity in C++ Code (Podcast)

Published July 20, 2018 - 1 Comment

Last week, Jon Kalb and Phil Nash, the organizers of C++Chat, invited Kate Gregory and I on the show to discuss “Simplicity” in C++ code, and in designing code in general. We had a very interesting discussion, that includes topics such as: how to measure complexity, coupling in code, levels of abstraction, the hard decisions […]

How to Construct C++ Objects Without Making Copies

Published July 17, 2018 - 19 Comments

Today’s guest post is written by guest author Miguel Raggi. Miguel is a Computer Science and Math professor at UNAM, Mexico’s largest university. He loves clean, expressive, performant C++ code (and strives to convince students to write it in this way!). Miguel is the author of discreture, an open source C++ library to efficiently generate […]

The Incredible Const Reference That Isn’t Const

Published July 13, 2018 - 23 Comments
cont reference not const

While working on the NamedType library I came across a situation that left me stunned in bewilderment: a const reference that allows modification of the object it refers to. Without a const_cast. Without a mutable. Without anything up the sleeve. How can this be? And how to enforce the const in that const reference? A const reference […]

3 Simple C++17 Features That Will Make Your Code Simpler

Published June 19, 2018 - 0 Comments

This article is a guest post written by guest author jft. C++17 has brought a lot of features to the C++ language. Let’s dig into three of them that help make coding easier, more concise, intuitive and correct. We’ll begin with Structured Bindings. These were introduced as a means to allow a single definition to […]

Should structs Have Constructors in C++

Published June 15, 2018 - 10 Comments

I originally wrote this article for Morning Cup of Coding. Morning Cup of Coding is a newsletter for software engineers to be up to date with and learn something new from all fields of programming. Curated by Pek and delivered every day, it is designed to be your morning reading list. Learn more. C++ structs are little bundles […]

A Concrete Example of Naming Consistency

Published May 29, 2018 - 18 Comments

One of the common guidelines about naming things in code is to be consistent. But what does that mean, in practice? I had the chance to be at C++Now this year, and attend Tony Van Eerd’s great talk called Words of Wisdom, where he gave a very practical approach to that question (amongst many other […]