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

Questions tagged [c++17]

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

3
votes
3answers
89 views

A collection of vector functionals

I would like some feedback for a collection of what I call "vector functionals", by which I mean maps \$\ell\colon \mathbb{K}^{n} \to \mathbb{K}\$, where the field \$\mathbb{K} = \mathbb{R}\$ or \$\...
2
votes
1answer
45 views

Managing different types of morphism and their compositions

Here's some code I wrote to manage the different types of morphism and their compositions in C++17. Let me know if you had any suggestions for substantial simplifications or improvements, or if I ...
1
vote
0answers
28 views

Qsort in C++ using vector

I tried to make a simple qsort() function in a functional way, it takes a vector and a bool pred() Suggestions as to make it more functional, optimize it, and/or ...
2
votes
1answer
49 views

Class representing digital PLC address

I have a project where I work with digital addresses for a Programmable Logic Controller (PLC). The requirement is that the user gives a start address e.g. 1000.0 and then for example the next 20 ...
7
votes
1answer
184 views

Generating maze for complicated Hunt the Wumpus game

In my previous post I made rather dull (and, as it turns out, bluntly wrong) attempt at solving the problem: Generate a maze with \$N\$ nodes, \$K<N\$ of which are border nodes. Each border must ...
5
votes
2answers
101 views

C++ wrapper class to mimic a C array's brace initialization

I have an inheritance class that mimics the behavior of C style array's brace initialization by using a class template that has a variadic constructor but the template itself is not a variadic ...
8
votes
2answers
200 views

std::array implementation

I'm creating my own implementation of the STL, compliant with the C++17 standard. The only purposeful differences are that the namespace is hsl (homebrew standard ...
3
votes
1answer
70 views

Small fast pseudorandom number generator in C++

I've been away from C++ for some time and I'd like to get back up to speed with modern practices, so I implemented a small random number generator described here. Any advice on this piece of code? <...
1
vote
6answers
1k views

Elegantly exclude part of an operation for the last iteration in a loop [closed]

I'm afraid just about everybody who read this question has misunderstood it. I'm not trying to find the best way of printing a vector. I'm trying to find the best way of excluding part of an operation ...
0
votes
0answers
66 views

Yet another hash tuple in C++17

Is there something terribly wrong with this implementation? ...
2
votes
1answer
113 views

Boilerplate free registry/factory class for C++

I've made registry/factory class for C++ so I can instantiate different classes at runtime based on some kind of key. My design is partially based on this blog post: http://www.nirfriedman.com/2018/04/...
2
votes
1answer
50 views

C++ multiple container synchronization in Entity-Component-System compatible with STL

I implemented an Entity and ComponentManager< T > for my new Entity-Component-System (ECS) architecture in my game engine. ...
1
vote
0answers
53 views

A basic multi-dimensional array

I have been lurking on the C++ side of stack-overflow only long enough to know there are a lot of beginners and intermediate programmers baffled by multi-dimensional arrays. I've seen a lot of ...
4
votes
1answer
70 views

back_inserter for several container arguments

Recently I wrote a back_inserter with the same interface as the std::back_inserter just for supporting several containers in the constructor and doing push_back for each. The solution needs C++17. ...
1
vote
2answers
49 views

Generic (Multi)SkipList adapter class

Today I have written my first implementation of a SkipList (on top of a std::vector), because I was tired in using ...
2
votes
0answers
44 views

Creating an array of distinct objects with an identical method that can be evaluated (mapped) at compile-time (constexpr)

In a ray tracing project that I'm trying to make compile-time (constexpr) for fun and challenge, I've run into a bit of an issue: I have an object (intersection) that needs to refer to one of a group ...
4
votes
1answer
82 views

Generate multi dimensional maze with borders and fixed degree on each node type

IMPORTANT: giving too big combination of node count and edge/neighbor count can overflow your RAM and swap file very quickly, thus I recommend staying below 500 on node count and below 50 on neighbor ...
4
votes
0answers
33 views

Modular graph searcher

some words in forehand: Unfortunately this post is very long, thus I decided to put the whole and compilable code into an online compiler. The link is at the end of this post. In the last few days I ...
3
votes
0answers
68 views

Console based Vocabulary Trainer Version 2

After a long break I took the suggestions from Console based Vocabulary Trainer and reworked the Trainer. It contains of the following parts Vocabulary.h/cpp: Save and read vocabulary from/to text ...
3
votes
1answer
46 views

Generic pixel class to seamlessly alpha-blend and convert between different pixel structure layouts

Does what it says in the title. I just finished this and wanted to share with someone. Looking for possible optimizations, bugs (most of it is tested to work) or any constructive criticism. ...
10
votes
1answer
187 views

Displaying programming languages on a timeline

I did the following two exercises in Programming: Principles and Practice Using C++ (2nd Edition), by Stroustrup, which build upon each other: From Chapter 22 (Ideals and History), Write a ...
3
votes
1answer
93 views

Cleaning a file / Word Query GUI (FLTK)

This is a follow up of Cleaning a file / Word Query I incorporated the suggestions from the anwers there and turned the Word Query Programm into a GUI. For that I used the Support code of the Book ...
7
votes
3answers
199 views

The perfect function alias

For many years, I have waited for function aliases in C++. They still aren't here. I've been using macros to generate wrapper functions. This is my best attempt at the perfect function alias: ...
7
votes
1answer
109 views

Peter Norvigs' lis.py in c++17

I wanted to try convert Peter Norvigs' Python Scheme interpreter to C++. I had tried this a few years before and failed abysmally but I saw that the latest C++ standard includes several features ...
7
votes
2answers
126 views

Cleaning a file / Word Query

In a followup this application was turned into a GUI using FLTK: Cleaning a file / Word Query GUI (FLTK) I did the following two exercises in Programming: Principles and Practice Using C++ (2nd ...
5
votes
1answer
126 views

C++ thread pool class

I have addressed the critique for this post and resubmitted it for iterative review; C++ multithread pool class. Class for creating thread pools with the latest C++ standard. Currently C++17 and C++...
4
votes
2answers
107 views

C++ for_each_adjacent

I was watching a C++ Talk and he showed some code for a basic for_each_adjacent. I took the base concept and improved it a little bit, I am wondering if i could have any feedback. It automatically ...
5
votes
2answers
90 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. ...
1
vote
0answers
38 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 ...
6
votes
0answers
147 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 ...
9
votes
2answers
236 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 ...
4
votes
1answer
534 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
104 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
88 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, ...
10
votes
2answers
157 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
66 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
107 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
165 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
131 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
311 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
125 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
84 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
70 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
212 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 ...
7
votes
1answer
68 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
149 views

Consuming a picnic lunch

I have a number of related classes (Burger, Pizza, Cupcake) with a common base class ...
4
votes
2answers
362 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
141 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
97 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
314 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 ...