Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

Use when the code in question assumes at least C++17 compliant compiler.

5
votes
0answers
24 views

Endless stream: stream a range and return default value if the range is exhausted

Introduction: Motivation Sometimes there is a need to merge N > 1 ranges, and they don't have equal length, but there is a value which can be used in case the range is already exhausted. It is ...
4
votes
2answers
48 views

Move friendly merge sort - follow-up

This is a follow up to this question. I'm only interested to see if this is implemented correctly for move-only types. ...
0
votes
0answers
25 views

Excercise from PPP Order class

I did the following two excercise from PPP by Stroustrup: Define an Order class with (customer) name, address, data, and ...
2
votes
0answers
20 views

Hunt the Wumpus GUI (FLTK)

I used the code from the text based hunt the wumpus game discussed here: Text based game “Hunt the Wumpus” Version 3 to create a gui Version based on excercises from PPP by Stroustrup. For the GUI i ...
8
votes
2answers
144 views

Modern C++ singly linked list

This is a rather minimal (though fully functional) implementation of a singly linked list. It supports \$\mathcal{O}(1)\$ front insertion and deletions, as well as \$\mathcal{O}(1)\$ random insertions ...
3
votes
0answers
78 views

Travelling salesman problem using genetic algorithm in C++

I have implemented travelling salesman problem using genetic algorithm. Since project is not so small I will give short introduction. GeneticAlgorithmParameters - ...
4
votes
3answers
87 views

Iteration over “zipped” tuples (for_each_in_tuples)

I want to implement for_each_in_tuples that takes a functor and one or more tuples of the same size and applies this functor to <...
3
votes
2answers
72 views

Disassembler for intel 8080 v2

As many suggestions were given for the code I posted here, I decided to show you the new version for review. I Removed the OpenCatalog class, ...
0
votes
0answers
18 views

Runtime Datatype polymorphism [migrated]

I've come up with a solution for runtime polymorphism in C++. ...
10
votes
2answers
127 views

Disassembler for intel 8080

I have written a disassembler for Intel 8080, able to translate binaries into opcodes and parameters. Sorry for posting so much code, but everything posted here is useful for the understanding of the ...
5
votes
2answers
59 views

Iterable object on set of ids

For some of the algorithms that I am implementing it turned out to be useful storing ids in order to iterate on objects, while also avoiding having to think about reallocation and invalidation of ...
3
votes
2answers
82 views

A traits class for (compound) pointers - beyond what std::pointer_traits offers

This is a percolation of ideas which originated this SO question: Compound pointer traits class with method generalizing make_shared and make_unique? The ...
4
votes
2answers
111 views

Thread-safe cache using a linked list

Are the final templated functions allocate and deallocate thread safe? The Cache object is a ...
4
votes
1answer
60 views

Simple event dispatcher

Here is my very first event dispatcher. I would like to get both, style and code review, as well as some ideas to improve this implementation (new features etc.) I tried to write code in C++17 style ...
5
votes
1answer
138 views

Generalized Cartesian Product

Much to my chagrin, neither STL nor Boost has a cartesian product. Namely, given as arguments one or more iterables, create an iterator producing std::tuples of ...
10
votes
3answers
109 views

Compute mean and variance, incrementally

I have previously reviewed code that computes standard deviation using the mathematical formula E(x²) - E(x)², and warned against the use of this formula because floating-point precision is severely ...
3
votes
1answer
62 views

Deep-copyable unique_ptr wrapper with std::visit-like feature

I'm writing a simple wrapper for std::unique_ptr, which copies the pointed object when copied. Unlike this wrapper, it properly copies derived classes if ...
3
votes
1answer
62 views

Pre-baked Hash table with a flat memory layout

A few notes: There is currently no non exception-based way of knowing whether a key is present in the table or not. This is intentional for my use case. Unlike the lookup process, the baking process ...
5
votes
2answers
165 views

Better generic binary search tree in C++

Introduction This is a follow-up to my previous question. This code rocks new ground-up implementation of core functionality, which I made from combining @vnp’s and @JDługosz's answers. The core ...
8
votes
1answer
62 views

Implementing and benchmarking Radix Sort on unsigned integers

Introduction I implemented a restricted version of the sorting algorithm, the one that works only with unsigned integers. I wanted to try using ...
10
votes
1answer
142 views

Consuming a picnic lunch

I have a number of related classes (Burger, Pizza, Cupcake) with a common base class ...
4
votes
2answers
100 views

Format log with a small macro logger

The goal of this code is to format any log to STDOUT and STDERR with the file and the line of where the call is made. I took ...
2
votes
2answers
90 views

Wrapper for a raw array so that it can be passed to templates expecting Standard Library containers

I am working with a code base where unfortunately I cannot replace all raw arrays with std::array. The spec provides no guarantee that the memory layout of a ...
1
vote
1answer
63 views

Configuration Manager

The idea here is to implement a configuration system using INI files for a pathfinding library nammed Kraken. This library is in java and I am helping implementing it in C++. The goal is to make it ...
4
votes
2answers
210 views

Object pool for allocating generic objects in aligned memory

I made a single header object pool for use in personal projects. It's supposed to be easy to use, cross-platform and thread safe. It uses a free list for allocations and a hashmap for dereferencing ...
5
votes
2answers
78 views

Generic in order traversal iterator for binary trees

This actually started off as member type for the binary_search_tree, but after realizing that it doesn't compare to values or use the value objects inside of it, I ...
7
votes
2answers
404 views

Generic binary search tree in C++

Introduction This is yet another data structure I'm going over again for the algorithms course. This time it is binary search tree. Implemented operations: Insert Exists Remove Clear Move ...
7
votes
2answers
55 views

Acts like an iterator, but counts

I’m making a “counting iterator” which emulates a constant container of consecutive values of some integral type. It is mostly boilerplate, going through the list of requirements for different ...
8
votes
1answer
269 views

Bitmask adapter

Today I had some time and tried to improve my own Bitmask adapter class. It's common practice to eliminate sets of boolean variables with something like a flag system. The old fashioned way was to ...
3
votes
1answer
127 views

Variadic strcat for c++17

On some video from CPPcon, some one said that there should be variadic overload for operator+ as it can solve allocation when there are multiple ...
2
votes
1answer
109 views

Simple C++ allocator for POD types

Edit 1 after first review: I changed to use malloc / free since apparently it's also easier to optimize than ...
2
votes
1answer
62 views

Template function for splitting strings in C++

I'd like to write a function to split strings in C++ to check my template learning. I've also read some relavent questions in this site but most of them don't use templates or ...
3
votes
2answers
64 views

Operations on a heap

Introduction I started going through some basic algorithms as I'll have algorithms course next semester. The last time I've written any heap operations is around 5 years ago. This time around it took ...
4
votes
0answers
135 views

Using multiple console windows for output

In my current project I found the need to concurrently track the progress of multiple concurrent components, and having all of them output their (debug) information into a single console window made ...
3
votes
2answers
94 views

Math matrix, mainly for graphics

I wrote a matrix library to replace my old matrix library. I was using my old matrix library to do basic operations for 3D rendering but that library grew old and now I'm seeking to replace it. I'm ...
3
votes
1answer
117 views

2D rendering abstraction

This is a simple 2D rendering abstraction that I've been using for my game. It's basically a vector of quads. It has functions for defining quads (position, rotation, texture coordinates) and a ...
4
votes
1answer
85 views

ASCII to uint16 using fallthrough

Introduction Watching this talk, I thought may be I could apply it on parsing smaller numbers, like std::uint16_t. I augmented it though, by using a fallthrough ...
10
votes
1answer
305 views

C++ Inventory System

I have recently been working a lot on a project for a system that represents an inventory and item usage in a game, with one of the important features is that it should be reusable in multiple ...
4
votes
0answers
59 views

Chained Factories by Expression Template

I want to make factories that can chained together to create a pile of layers. One of the advantage of chained factories is that later factories can pass specifications to earlier factories. For ...
1
vote
0answers
32 views

Type conversion between Node, Const_node, and their views

Each node is a location within a layer. A Location may be a pointer or an index. A Layer is a container. There are 4 types of ...
1
vote
0answers
53 views

Type System for Layers and Nodes

Overview The following is a type system of layers (A, B, C, ...
7
votes
3answers
2k views

Doubly linked list class in C++

I would like some feedback regarding my doubly linked list implementation in C++. I have been programming in C++ for about a year and a half and consider myself fairly proficient in the language. I ...
4
votes
3answers
305 views

Thread-safe LRU cache

Please review my code. I am trying to implement a thread-safe LRU cache using std::list and std::unordered_map. This is a header-...
1
vote
1answer
132 views

Over-Engineered FizzBuzz, ’17-style

In my first question I tried to show “real” coding concerns while still keeping the implementation brute simple; using a loop over data rather than a string of separate testing statements, isolating ...
8
votes
2answers
154 views

C++ std::array wrapper

I implemented a std::array wrapper which primarily adds various constructors, since std::array has no explicit constructors ...
6
votes
1answer
93 views

Wrap pattern “using std::begin; return begin(c);” into a function

I posted a C++17 version of wrapping functions for the “two-step”, on this Answer on StackOverflow. It’s more than just handy to have a wrapper, as I was searching for good solutions on how to use <...
8
votes
1answer
81 views

Portability in using up-and-coming library features

Currently, some library features are not in std that comes with the compiler, but may be in std::experimental or may not be ...
3
votes
0answers
93 views

C++17: Boost.Hana based compile-time plugin registration

My aim with the following is to have a way of registering a list of classes, which represent plugins. In the end, I want a boost::hana::set that contains type objects for all plugins' classes. I want ...
10
votes
1answer
94 views

Composable by-member comparison

Motivation Quite often, I find myself creating types that must be compared memberwise. For example, consider this simple Person: ...
6
votes
0answers
130 views

C++17. A blockchain implementation in 207 lines of code

There is a blockchain class with minimal functionality inspired by naivechain. It has template data and hash function parameters: ...