Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 137260

C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. This tag should be used for any question which requires knowledge or expertise with the C++ programming language. This is a general tag which is used for any of the C++ language standards (C++98, C++11, C++17, etc.). The question should identify the compiler being used, the operating system, and which of the C++ standards is being targeted.

11 votes
2 answers
5k views

C++17 saturating integer (arithmetic) type library

I wrote a C++ library to provide extra signed and unsigned integer types that saturate in overflow situations. It's in proof of concept stage and I'd love to get some feedback on it. A short usage de …
Stefan's user avatar
  • 813
2 votes
2 answers
420 views

C++ distributed enumeration alternative

Application: replacing enum type / description tags in modular software, allowing adding new enum values without updating one definition. Say we have a video processing pipeline not unlike gstreamer. …
Stefan's user avatar
  • 813
10 votes
1 answer
654 views

C++ library to compile-time merge sets to a single array

I built this small library to create a compile-time assembled array from several hard-coded sequences (of unequal length) of a type T: mergeable_set.hpp #pragma once template <typename T> class mer …
Stefan's user avatar
  • 813
5 votes
1 answer
121 views

C++ library with tools for (arithmetic) type manipulation and mixing

Broken out from a previous question (C++17 saturating integer (arithmetic) type library) is a small C++17 header-only library to deal with issues that arise working with arithmetic where signed, unsig …
Stefan's user avatar
  • 813
5 votes
3 answers
1k views

C++ choose between runtime and compile time implementation functions

I wrote a small wrapper function to choose between runtime (std) sqrt and a constexpr version, as a continuation of the vector class I published here earlier: C++ mathematical n-dimensional vector te …
Stefan's user avatar
  • 813
5 votes
1 answer
934 views

C++ mathematical n-dimensional vector template using fold expressions

I'm writing a template to unify a few mathematical vector types I was using. The goal is low overhead, constexpr where possible and generic utility functions built-in. Normal usage would be like this …
Stefan's user avatar
  • 813
2 votes
1 answer
1k views

C++ generic, multi-dimensional linear interpolation template

Use-case in a nutshell: Interpolate fixed-sized data (a lookup table) that provides output values for combinations of a (fixed) number of inputs. The appropriate scaling is done externally, each axis …
Stefan's user avatar
  • 813
4 votes
1 answer
516 views

C++ Calculate euclidean distance between tuples, for specified indices

I wrote a small utility function that will take two tuples and returns the Euclidean distance for the given indices only: #include <cmath> #include <tuple> namespace { template <typename T> cons …
Stefan's user avatar
  • 813
2 votes
1 answer
443 views

C++ sum and averaging functions for arrays and argument sets

Here are two sets of variadic C++ functions to do fast summing and averaging of arrays (plain & std::array) or argument sets, (re)written as part of my generic toolbox. The sum functions are pretty g …
Stefan's user avatar
  • 813
10 votes
2 answers
7k views

C++ Bit shift whole array (left)

For an embedded project I want to shift a (byte) array left by a certain amount of bits. I've built this template function to do so: template <typename T> constexpr void shift_array_left(T *arr, cons …
Stefan's user avatar
  • 813
2 votes

C++ choose between runtime and compile time implementation functions

Based on Toby Speight's answer I went ahead and converted this to a generic template / utility function. The added checks provide a fallback to the runtime function if the required features aren't pre …
Stefan's user avatar
  • 813
9 votes
3 answers
2k views

C++ edit distance / string similarity function based on the Jaro-Winkler algorithm

I wrote a short library function, based on an example from Rosetta, to compare two strings and determine similarity, using Jaro-Winkler. A short copy-paste ready example: main.cpp #include <string> …
Stefan's user avatar
  • 813
1 vote
2 answers
460 views

Map a set of types to unique IDs and runtime reinterpret back from ID and pointer in C++17

I wanted to create a relatively universal way of serialising an object, by doing a memcpy and generating a unique type ID. Stored together they can be used, for example, by another thread to restore a …
Stefan's user avatar
  • 813
3 votes
2 answers
250 views

Variadic function to find the first matching (string) argument in a larger array

Playing around with parsing a data buffer I wrote a small search function to find the first complete match out of a set of (string) arguments. The (simplified) buffer class with the find function: / …
Stefan's user avatar
  • 813