C++ Weekly - Ep 51 - Advanced Stateful Lambdas

In this episode we try to see just how far we can take the idea of a “stateful lambda” by building one that can be manipulated and interacted with from the caller side.

C++ Weekly - Ep 50 - Inheriting Lambdas vs Generic Lambdas

Now that we know why we would inherit lambdas, and merge them into one implementation (to make a visitor, for instance), how and why does this compare to using a generic lambda? What advantage does one have over the other?

C++ Weekly - Ep 49 - Why Inherit From Lambdas?

What is the practical application of for inheriting from lambdas in C++?

C++ Weekly SE - Why 0xFFFFFFFF == 1

Understanding integeral literal sizing and binary arithmetic rules in C and C++.

C++ Weekly - Ep 48 - C++17's Variadic `using`

In this episode I build from episode 40’s discussion on inheriting lambdas and show how several C++17 features (including variadic using declarations) can be combined to create a succinct merging of lambdas.

C++ Weekly - Ep 47 - My Visual C++ Pet Peeve

Last episode I showed you why you should be taking Visual C++ seriously. This episode I show you my personal pet peeve with Visual Studio that has caused many of my portability issues with cross platform development.

C++ Weekly - Ep 46 - Start Using Visual C++

In this episode I demonstrate why you should take Visual C++ seriously and make it a part of your automated build environment.

C++ Weekly - Ep 45 - Compile Time Maze Generator (and Solver)

In this episode I demonstrate how to build a random maze generator (and solver) that can be executed at compile time with constexpr.

C++ Weekly - Ep 44 - constexpr Compile Time Random

In this episode I demonstrate a constexpr enabled random number generator. I then it to generate a different random number sequence each time it is compiled.

C++ Weekly - Ep 43 - Stack Elision?

Is stack elision a thing? What would that imply if it were?

C++ Weekly - Ep 42 - Clang's Heap Elision

In this episode I explore Clang’s ability to elide heap operations.

C++ Weekly - Ep 41 - C++17's constexpr Lambda Support

In this episode I demonstrate how C++17’s support for lambdas in a constexpr context can clean up many constexpr use cases.

C++ Weekly - Ep 40 - Inheriting From Lambdas

In this episode I discuss how (and why) you can inherit from a lambda function along with possible use cases.

C++ Weekly - Ep 39 - C++17's Deduction Guides

C++17’s automatic class template deduction feature brings with it a new sub-feature called “deduction guides” which are used to help the compiler with class template type deduction. I give examples of what they are and how they are used in this episode.

C++ Weekly - Ep 38 - C++17's Class Template Type Deduction

Experimenting with C++17’s class template argument type deduction feature and learning what its limitations are.

C++ Weekly - Ep 37 Stateful Lambdas

Creating stateful lambdas using capture expressions in C++14.

C++ Weekly - Ep 36 Reading Assembly Language - Part 3

Part 3 of our basic introduction to understanding the assembly output from your compiler. In this episode we do some reverse engineering of other non-Intel architectures.

C++ Weekly - Ep 35 Reading Assembly Language - Part 2

Part 2 of our basic introduction to understanding the assembly output from your compiler.

C++ Weekly - Ep 34 Reading Assembly Language - Part 1

Basic introduction to understanding the assembly output from your compiler.

C++ Weekly SE - Visual C++ 1.52 (1993) Review

Review of using Visual C++ 1.52 from 1993. This is the oldest version of Visual C++ available on MSDN.

C++ Weekly - Ep 33 Start Using Default Member Initializers

Why you should use C++11’s default member initializers.

C++ Weekly SE - g++ 2.4.5 (1993) Review

Reviewing g++ 2.4.5 from 1993 on Slackware Linux 1.01.

C++ Weekly - Ep 32 Lambdas For Free

Examining the (free) cost of using lambdas in C++.

C++ Weekly Special Edition - Borland Turbo C++ 3.0 Review - Part 2

In this Special Edition episode I continue my exploration of Borland Turbo C++ 3.0 from 1992.

C++ Weekly - Ep 31 IncludeOS

I explore what IncludeOS is and how you might use it for OS experimentation.

C++ Weekly Special Edition - Borland Turbo C++ 3.0 Review

In this Special Edition episode I explorer Borland Turbo C++ 3.0 from 1992.

C++ Weekly - Ep 30 C++17's [[nodiscard]] Attribute

Wrapping up our C++17 attribute coverage with possibly the most interesting yet: [[nodiscard]].

C++ Weekly - Ep 29 C++17's [[maybe_unused]] Attribute

Using C++17’s new [[maybe_unused]] attribute.

Destructuring Standard Containers in C++17

A comment was made on my YouTube channel that destructuring in C++17 would be much more useful if it worked with standard containers. At the moment I responsed that this would be someone impossible to get right without adding too much overhead.

C++ Weekly - Ep 28 C++17's [[fallthrough]] Attribute

Understanding C++17’s new [[fallthrough]] attribute.

C++ Weekly - Ep 27 C++17 Sequence Container Changes

What changes to expect to the sequence containers (for example, std::vector) in the upcoming C++17.

C++ Weekly - Ep 26 Language Features Removed In C++17

C++17 has not only added many new interesting things, it has removed and deprecated a few outdated features as well.

C++ Weekly - Ep 25 C++17's Aggregate Initializations

Continuing coverage of C++17’s new features with new aggregate initialization of base classes.

C++ Weekly - Ep 24 C++17's Structured Bindings

Our continuing series on C++17’s new features with an introduction to C++17’s structured bindings.

C++ Weekly - Ep 23 C++17's __has_include

I continue my series on C++17’s features with the new __has_include functionality.

C++ Weekly - Ep 22 C++17's Nested Namespaces and `std::clamp`

This week I introduce C++17’s nested namespaces and std::clamp library function.

C++ Weekly - Ep 21 C++17's `if` and `switch` Init Statements

This week I introduce C++17’s new support for if and switch init statements.

C++ Weekly - Ep 20 C++17's Fold Expressions - Introduction

This week I introduce C++17’s fold expressions.

C++ Weekly - Ep 19 C++14 For The Commodore 64

Using modern C++ to write extremely efficient high level programs for the Commodore 64.

C++ Weekly Special Edition - Using C++17's constexpr if

In this SE we follow up episode 18’s constexpr if with some concrete examples of where it can be used in existing code.

C++ Weekly - Ep 18 C++17's constexpr if

This week I preview C++17’s upcoming “constexpr if” functionality.

C++ Weekly - Ep 17 C++17's `std::invoke`

This week I preview one of my favorite up coming new features of C++17: std::invoke.

C++ Weekly - Ep 16 Avoiding `std::bind`

Last week we discussed how to use std::bind. this week we discuss why you should never use std::bind

C++ Weekly - Ep 15 Using `std::bind`

Introduction to std::bind from C++11 and how it can be used.

C++ Weekly - Ep 14 Standard Library Gems: `next` and `exchange`

Two somewhat obscure and surprisingly helpful C++ standard library functions.

C++ Weekly - Ep13 Fibonacci: You're Doing It Wrong

Many of the different ways you might implement a Fibonacci sequence in C++ plus one you’ve probably never considered.

C++ Weekly - Ep12 C++17's std::any

In this episode I introduce std::any from the upcoming proposed C++17 standard.

C++ Weekly - Ep11 std::future Part 2

In this episode I correct some of the details of the “std::future Quick Start” episode while expanding on the info provided.

Folds (ish) In C++11

It is possible to perform some form of the variadic folds that are coming in C++17 with the C++11 and C++14 compilers that we have available today by using just a little bit of creativity.

C++ Weekly - Ep10 Variadic Expansion Wrap-Up

In this episode Jason wraps up what we’ve learned so far about variadic templates and shows some additional techniques to consider.

C++ Weekly - Ep9 std::future Quick-Start

In this episode Jason gives a very fast quick-start to what std::future is and how to use std::async to run a function in another thread.

C++ Weekly - Ep8 C++ Name Demangling

In this episode Jason discusses some of what C++ name mangling is, and how to demangle names at runtime.

C++ Weekly - Ep7 Stop Using std::endl

In this episode Jason quickly tries to convince you to stop using std::endl.

C++ Weekly - Ep6 Intro To Variadic Templates

In this episode I give a brief introduction to C++ variadic templates and cover some compile time and runtime performance considerations.

C++ Weekly - Ep5 Intro To ChaiScript

C++ Weekly - Ep4 Variadic Template Refactor

So You Want to Embed A Scripting Language in Your Application

Note: this article was originally written in 2005. I’m importing some missed content into my new site and this is one of those articles. Much of the information in this article is out of date, but it still has some relevance. To see my personal take on the best way to embed scripting in C++, checkout ChaiScript.

C++ Weekly - Ep3 Intro to clang-tidy

C++ Weekly - Ep2 Cost of Using Statics

C++ Weekly - Ep1 ChaiScript_Parser Initialization Refactor

ChaiScript 6 Years Later

It’s been a little more than a year since our last update.

Template Code Bloat Revisited: A Smaller make_shared

Back in 2008 I wrote an article on template code bloat. In that article I concluded that the use of templates does not necessarily cause your binary code to bloat and may actually result in smaller code! This ended up becoming one of my more significant articles and has been referenced on wikipedia.

Complex Object Initialization Optimization with IIFE in C++11

IIFE (Immediately-Invoked Function Expression) is a common tool used in JavaScript. The idea is to both define an anonymous function and call it in the same expression. The point is to produce a local scope for variables so they do not pollute the global scope.

Make Sure You Provide Virtual Destructors

If you make use of inheritance, it’s likely that you need to provide a virtual destructor for your classes. Modern compilers will warn if you do not, but this is a pretty recent development.

ChaiScript (almost) 5 Years Later

July 13, 2009 Reddit covered Release 1.0 of ChaiScript. Many things changed in the last 5 years. Features added, dependencies removed, and performance increased. With all of the changes, we decided it was time to provide a 5 year retrospective and give the world a second first-look at ChaiScript.

C++11: Auto

We’ve already covered C++11 decltype and why you should start using C++11 features today. Now we will move on to one of the most widely supported C++11 features: the new auto keyword.; auto is supported currently by g++ as of 4.4, clang and msvc since 10. So you are safe using it today if you don’t need to support any older compilers. The auto keyword is used to let the compiler determine the type of a variable. This seemingly simple concept can really help clean up your code in some situations. For example:

Are You Using make_shared Yet?

Recently, while watching the GoingNative conference, I learned about the new std::shared_ptr helper function std::make_shared.

Trigraphs, Digraphs and Alternative Tokens

Quick, which language is the following code written in?

Start Using C++11 Now

Every major platform and compiler now supports some aspect of the new C++ standard accepted in 2011. This means it is currently possible to write code that uses some of C++11 while maintaining cross-platform compatibility. Why should you care?

Double vs. Float, Which is Better?

Neither C++ Coding Standards nor Effective C++ addresses the question of which float point type is best to use and in what situations. There are three floating point types in C and C++:

C++11: Decltype

decltype is a type specifier introduced in C++11. It behaves like a function that evaluates to the type of an object at compile time. This article is helping provide some more background information necessary for the more meatier C++11 articles to come.

C++ Partial Specialization of Templates

In this article we are going to introduce the concept of C++ Template Partial Specialization. This is meant to be just a primer on the topic and not exhaustive. The examples here will be used and referenced in later articles. A series of discussions about C++11, now that the language has been finalized, will be coming shortly. In C++ a template class such as this:

Nobody Understands C++: Part 11: Including Me (aka, Provide Consistent Semantics)

I just spent the better part of the day debugging an insidious little bug. It really shouldn’t have taken that long… I even had unit tests in place that covered the code in question! Right!?

Microsoft's Failing Support For C++

Microsoft recently posted a video on Channel 9 and their blogs describing the upcoming work they have planned for C++. The abstract of the video tries to point out Microsoft’s unfailing devotion to C++ development:


Considering the number of articles and polls we come across asking if C++ is dying or dead combined with the decrease in C++ job posting I have personally noticed, C++ sure is alive and well in the AI frontier. C++ takes or ties the top 27 places at the 2010 Google AI Challenge

Nobody Understands C++: Part 10: C++ Is Not an Object Oriented Programming Language

In the context of the rest of the Nobody Understands C++ series, I feel like this one is redundant. But it seems like it needs to be said. C++ is not an object oriented programming language. C++ is a multi-paradigm language that supports most of the major programming paradigms that have been widely accepted. Specifically, C++ supports:

C++0x Final Committee Draft

As others have pointed out, the Final Committee Draft (FCD) of the next C++ standard is now available for anyone to download.

Upcoming GCC 4.5 Features

GCC 4.5.0 has frozen and the release has made it to thefront page. This is significant to me for 2 main reasons.

Developer Day - Boulder 2009

This past Saturday I attended the Developer Day meeting in Boulder, CO. Overall the day was beneficial and interesting even tho it was more dynamic languages centric and very few things applied directly to my C++ development. I did present ChaiScript during a lightning talk.

Nobody Understands C++: Part 9: Error Handling

I was recently at a talk where the speaker was discussing the history of C++. He argued that one problem with C++ was that its design requirements included backward compatibility with C code, and one fallout of this was the requirement to support all previous types of error handling as well as adding exceptions. That is, C++ supports:

Nobody Understands C++: Part 8: Operator Overloading

There has been much discussion over the years about the usefulness of operator overloading in C++ as well as the ability to get it right.

Understanding the ChaiScript clone Function

In ChaiScript variable assignments create a copy of the object being assigned.

ChaiDraw: Programming Toy and Chaiscript Use Case

I have been working for the past few weeks on ChaiDraw. ChaiDraw is an application that’s both meant as an educational toy and as a showcase for how to effectively use ChaiScript in your application.

ChaiScript: Easy C++ Scripting

Jon and I released the first release of ChaiScript earlier today. ChaiScript is designed to make it trivially easy to use scripting in your C++ application and to expose your C++ to the scripting system.

Online C++ Resources

I often mention books that I use as resources, but rarely websites. It seems, on average, that online C++ resources are lacking. However, there are a few that I have found that provide quite valuable insight.

Using colorgcc in Ubuntu (and other Linux distributions)

colorgcc is an awesome little tool for colorizing the output of gcc and g++, making compiler errors and warnings much easier to spot.

Optimizing Massively Multithreaded C++ Applications - Where's the Output Going?

If you have dozens or hundreds of threads doing work they are probably producing some sort of output. I’m not referring to logger output, but to permanent storage, perhaps in a database. If you cannot store the data as quickly as you produce it, you will eventually run into problems. If you are just barely able to keep up with data storage then your scalability will be limited. In the system I am working on poor database performance caused a cascade of errors, making the root cause very difficult to track down. The queue used to store database inserts was growing so large that it was causing out of memory errors which resulted in news returning null. The library calling new did not check the return value, which then caused a segmentation fault when the library attempted to use the pointer.

Optimizing Massively Multithreaded C++ Applications - Beware of Heap Operations