A C++ 11 Header Only Convenience Function Library


Having spent several years programming in C++ every day I've had time to build up a library of functions that make programming easier. The focus of this library is on making calls to STL functionality less verbose, wrapping up common STL usage patters like calls to erase after remove, and adding a few functions that I thought were missing.

This library is not dogmatic. The only guiding principles were what I found convenient as I was programming. However, over time two themes emerged.

1. Wrapping Iterators Up

Lets face it, most of the time when you call an STL function that uses iterators the inputs are the begin and end iterators of the data structure.

As a general rule in any language the most frequently used words should be the shortest. This convenience library includes short functions that take in references to a data structure and operate on the entire thing.

The function calls for sorting, finding maxs and mins, and removing items from collections have short call signatures that don't require use of iterator related functions like begin and end.

2. Returning Data Structures as Values

Pre-C++ 11 there was no convenient way to return a data structure that had been created in a function as a value. Thanks to move semantics returning data structures as values is no longer a big deal, and this convenience library takes advantage of that.

Library Functionality

Searching By Scores

A very common pattern in searching is to compare objects by a function that generates a value from the items being compared and then compares the generated values. afk wraps up this functionality into functions max_e and min_e.

The result is returned as a value rather than as an iterator.

Data Structure Filtering

Copying and selection functions

Delete functions

Set operations

afk includes functions for performing intersection, union, and difference on vectors and sets.


Chain functions (apply between). Functions that operate on adjacent elements.

Leave a Reply

Your email address will not be published. Required fields are marked *