All posts in "Templates"

How to Implement std::conjunction and std::disjunction in C++11

Published April 30, 2021 - 0 Comments
conjunction

Among the many features that C++17 introduced, the standard library got std::conjunction and its brother (or is it a sister?) std::disjunction. std::conjunction allows to perform a logical AND on a variadic pack of boolean values, and std::disjunction a logical OR: std::conjunction<Bs…>::value // is true if all Bs… are true, false otherwise std::disjunction<Bs…>::value // is true if at least one […]

A Classic Compilation Error with Dependent Types

Published December 11, 2020 - 0 Comments

There is a compilation error that occurs often when writing template code that uses dependent types. If you know what’s going on, it is easy to fix it immediately. But if you don’t, you can spend a while staring a what looks like reasonable code, and wondering why the complier won’t have it. I’ve been […]

Replacing CRTP Static Polymorphism With Concepts

Published September 11, 2020 - 0 Comments

This is a guest post from Matthew Guidry. Matthew works as a software engineer in the CAD industry. He designs libraries and cross platform desktop applications, and is interested in using modern C++ techniques to improve overall software architecture. You can find Matthew online on Twitter @mguid2088. One of the usages of the CRTP is […]

How to Make SFINAE Pretty and Robust

Published August 23, 2019 - 0 Comments

Today we have a guest post by Ádám Balázs. Ádám is a software engineer at Verizon Smart Communities Hungary developing video analytics for embedded systems. One of his passions is compile time optimizations so he immediately agreed to write a guest post on this topic. You can find Ádám online on LinkedIn. In the series […]

STL Algorithms on Tuples

Published March 8, 2019 - 0 Comments

When you manipulate a collection of objects in C++–which is quite a common thing to do when programming in C++–STL algorithms are your loyal companions to perform operations with expressive code. But the STL algorithms, shipped in the standard library with C++, only apply to collections that are filled at runtime, during the execution of […]