As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [c++17]

Code that is written to the 2017 version of the C++ standard. Use in conjunction with the 'c++' tag.

Filter by
Sorted by
Tagged with
2 votes
1 answer
62 views

QuadTree implementation in c++

I'm new on C++ and OOP. I wrote the following QuadTree implementation (I didn't wrote the remove object part yet). please take a look on it and provide feedback, mainly about C++ OOP design, ...
Joseph Hod's user avatar
4 votes
0 answers
40 views

Variadic pack class providing operations over types without constructing objects of those types

Sometimes I find I want to call a function passing each of a set of types as a template parameter, but without needing to construct an object of those types. I also may want to do this in multiple ...
John Ilacqua's user avatar
2 votes
1 answer
49 views

Class for packing two 4 bit unsigned integer in uint8_t

The purpose for this class is to pack two 4 bit unsigned integer into 8 bit unsigned integer, e.g. uint8_t. It is made in a way, so the class to resemble array of ...
Nick's user avatar
  • 1,356
6 votes
2 answers
482 views

C++ Minimal CSV parser cut2

Looking at this questoin, I was inspired by the idea and the approach, so I tried to write a second version of the code, taking most of the comments into considerations. Please note that I am still ...
Libra's user avatar
  • 61
1 vote
1 answer
358 views

Assignment function for Intervals container

I found the two related questions but they, however, do not answer my question: interval map implementation Where exactly does my code not adhere to the specification of the key and value type? The ...
asm's user avatar
  • 111
2 votes
3 answers
83 views

Chain of Responsibility Pattern using std::any

The following code has a Handler class that follows the classic Chain of Responsibility pattern. But we don't want to write a new handler class for every new type ...
prestokeys's user avatar
  • 1,351
3 votes
1 answer
55 views

Wildcard Matching: LeetCode 44 Attempt 2

Original post: Based on feedback from J-H in his answer I have done another attempt. Link to question: Given an input string (s) and a pattern (p), implement wildcard pattern matching with support ...
Martin York's user avatar
  • 93.3k
6 votes
1 answer
345 views

Program that inputs the number of days in January, (C++ beginner) (from 1 to 31) (separ. at tens), and outputs #'s written out

...
TjGoSwiddly's user avatar
5 votes
1 answer
298 views

String literals concatenation with support for dynamic strings

I have implemented a function to concatenate string literals at compile time. Basic requirements: Very simple API. Can be used as a one-liner. Must accept variadic string literals. Highly optimized ...
Sergey Kolesnik's user avatar
4 votes
1 answer
300 views

JSON value with std::variant

For learning purposes, I wanted to implement a class that could hold JSON data with std::variant. Most of the implementations I found online were using incomplete types as template arguments for map, ...
adepierre's user avatar
2 votes
1 answer
102 views

Comparator aware `flat_set` implementation

I am currently implementing a flat_map like container in C++, and had problems with the comparator used. Thus, I reduced it to the bare minimum which I will present here. (In particular, my code here ...
tommsch's user avatar
  • 243
0 votes
1 answer
109 views

Multiple containers share a single memory resource

In my project, I'm trying to use the std::pmr allocator and monotonic_buffer_resource. I'm using vector in various classes, and ...
goodman's user avatar
  • 103
5 votes
2 answers
299 views

Tiny Network Web Framework / Library in C++

I recently wrote a tiny network library in C++17 called Turtle on Linux and wish to seek some improvement advice on how to further develop it. Any insights would be appreciated. Origin: As a student, ...
I Love Turtle's user avatar
3 votes
1 answer
261 views

High performance 3 Way Quick Sort Implementation

My implementation of 3 way quick sort for strings. It supposed to sort very large set of 800,000,000 objects. This is why I added ...
Nick's user avatar
  • 1,356
3 votes
1 answer
183 views

Yet another sparse set implementation

I got inspired by this blog post and implemented a fixed-size sparse set, removing the need for vectors, because the sparse set's size equals at least ...
Tab's user avatar
  • 33
2 votes
2 answers
78 views

Cache for mesh objects

I'm creating a cache system for an object (Mesh) that is expensive to create. A Mesh can be created using a small amount of ...
Joshua Hyatt's user avatar
4 votes
1 answer
487 views

Template to unpack arguments to a std::function

I am writing some C++ code to interact with an external scripting language. I want to be able to register arbitrary C++ callable code as functions to be called from the script. The scripting library ...
David Woo's user avatar
  • 161
2 votes
1 answer
68 views

Reservoir sampling Algorithm A-ExpJ for C++17

Implementation of the Reservoir sampling algorithm A-ExpJ that allows sampling K random elements from a stream of elements according to their weights when we don't know the size of the stream in ...
GameRaccoon's user avatar
2 votes
1 answer
132 views

Reimplementing Alias method in C++

In the following I reimplement the Walker-Vose Alias method for sampling from nonuniform, discrete probability distributions. I am well aware that there is https://en.cppreference.com/w/cpp/numeric/...
mcocdawc's user avatar
  • 944
0 votes
1 answer
54 views

Using of fold expression to read csv file

I've written a code reading csv file using fold expressions. The only thing that should be defined is columns types and file name: ...
amplifier's user avatar
  • 113
-2 votes
1 answer
179 views

How can I optimize C++ serialization? [closed]

I want to serialize a C++ class Ramdomclass . Below is the serialization function. ...
Sebastian Orteho's user avatar
5 votes
1 answer
104 views

Traverse/transform (xml) tree

I am trying to write a utility for transforming xml trees using single pass and specifying node handlers. I used pugixml prior to this, and the library provides a ...
Sergey Kolesnik's user avatar
4 votes
1 answer
195 views

Multithreaded MVC game engine

This is an attempt at a multithreaded model-view-controller based engine for 2d console games (board games, roguelikes that sort of thing.) The code below will provide a fully working example but is ...
Jaldhar's user avatar
  • 409
0 votes
1 answer
113 views

Flippable atomic boolean

I was trying to implement a boolean that can be atomically flipped. The suggestion on Stack Overflow is to use an integer. This would be my implementation. ...
Antonio's user avatar
  • 133
5 votes
5 answers
910 views

Palindrome Permutation string

I’m starting to learn C++ by doing a lot of exercises, and I need your help so I can improve, Here is how it goes, I will try to solve an exercise and post both the ...
April Morrison's user avatar
4 votes
1 answer
176 views

Bin-packing C++ solution using multi-map

The need (context). Several times a day, we need to migrate a set of digital assets from one system to another. The process uses memory (the assets are held in memory for a short time) and we need to ...
Konchog's user avatar
  • 197
4 votes
1 answer
446 views

A toy application of pub/sub using C++ for self-learning

Firstly, I apologize for the lengthy post. I was not sure which code I should include. In practice of c++, I am writing a toy application for pub/sub using c++17. ...
Sam Hammamy's user avatar
2 votes
3 answers
97 views

How to efficiently build an object from list or array of strings

I am working with an API that delivers some data in a QStringList or basically a list of strings. The data contains keys and values but it is not a ...
DEKKER's user avatar
  • 121
1 vote
0 answers
20 views

Return type-erased object to the caller, use typesafe cast in a subsequent call [closed]

Libraries might need to return "context" objects to the caller, and then require the same object in subsequent calls. In some cases, the user is not required to know what's the concrete type ...
irishaccent's user avatar
2 votes
2 answers
69 views

Virtual method with variations for different types

Each animal type will call reactToOwner() and exhibit its own behaviour. So simply define a reactToOwner() override for each ...
prestokeys's user avatar
  • 1,351
3 votes
1 answer
73 views

Load and execute shared library

This is my attempt to load shared library on linux (and may be mac - did not test yet) I am interested if I am implementing everything correctly and if I can really use my function in a loop like that....
Nick's user avatar
  • 1,356
1 vote
1 answer
4k views

Convert string to date C++

New to C++ here, by combining different pieces of code I've found, i came with this solution below to convert a date in string to a date object. It works as I want but I'm not certain to do the ...
TmSmth's user avatar
  • 219
2 votes
1 answer
143 views

Storing (and retrieving) functions by indexing them by address

I want to implement a "service" of callbacks, where subscribers register or unregister a callback. I was thinking about indexing the callbacks by the function address, so that to unregister ...
Antonio's user avatar
  • 133
5 votes
3 answers
347 views

Templatizing a Timer class

I'm making a timer class in C++. This is the overview: ...
Alex CB's user avatar
  • 75
2 votes
1 answer
135 views

C++17 view over the Ith elements of tuples in containers of tuples

For mainly didactic reasons, I have designed my ElementsView<I, T> class template, which provides a view over the I th ...
joao's user avatar
  • 123
4 votes
1 answer
2k views

Create and view a family tree

I have an assignment due Friday to make a family tree. Started to code in January. My reviews from the teacher for this code was that the use of pointers was horrendous and it wasn't OOP enough. This ...
Shayeza's user avatar
  • 43
4 votes
2 answers
247 views

Multi-threaded Mandelbrot set generator slower than single thread

I am new to parallel programming. I have been playing around with multi-threading and for some reason, multi-threading the Mandelbrot set is slower than running a single thread. I have been trying to ...
Niralana's user avatar
1 vote
1 answer
132 views

Storing different types with common base using atomic-based typeid

I'm trying to develop some kind of in-memory store for my entities. These entities are representations of the devices available on the system. There may be eg. 3 leds, 1 temp sensor, 2 engines etc. ...
bielu000's user avatar
  • 241
0 votes
3 answers
476 views

Find local maxima of a sequence

I'm well versed in Python and Java, am just starting out with C++. Am enjoying the language and would really appreciate feedback on this solution. kata: Return positions and values of the "peaks&...
Richard Vodden's user avatar
0 votes
1 answer
131 views

C++ stack class design

I am trying some hands on recent C++ standards. For the purpose of learning, I have implemented a Stack class as below which can hold any type of data member. I would like everyone to review this ...
unbesiegbar's user avatar
3 votes
1 answer
789 views

visit for std::any

While solving an online excersise I have written some basic implementation for a visit function that works with std::any. The ...
Sergey Kolesnik's user avatar
8 votes
4 answers
2k views

Forward linked list implementation in C++

I wrote a linked list implementation in C++ to learn the concepts about linked lists as well as C++(17). I decided to use std::unique_ptr to help me avoid leaks and ...
Sourav Ganguly's user avatar
2 votes
1 answer
690 views

C++ circular buffer that guarantees contiguous data

For interfacing with C-API that requires data in one contiguous block I came up with the following, which seems to work nicely, but I wanted to see if I didn't miss anything crucial. Drawback is of ...
Jahn's user avatar
  • 23
1 vote
1 answer
192 views

C++ Chess Engine - (Magic)Bitboard-based move generation

I am currently writing a bitboard-based Chess Engine in C++, and I recently finished the move generation. I am using move-lookup-tables that get pre-calculated at application startup for sliding and ...
Tom Gebel's user avatar
  • 390
12 votes
3 answers
1k views

Matrix implementation

I am trying to implement an optimal and fast running matrix in C++. I need some review of the code and ideas on how to improve the code quality if it shall be. ...
Hrant Nurijanyan's user avatar
4 votes
0 answers
38 views

formatting flattened string into JSON-like object in C++, part 2

I have reworked the code from my previous (linked) post. For reference: I have a string which contains JSON-like object flattened (stringify()ed). I need to JSON-...
user3132457's user avatar
2 votes
2 answers
195 views

Event Dispatcher for GLFW/Glad

I've tried to write an event dispatcher for a GLFW/Glad library. However I am not very used to writing efficient code (spent the majority of my life writing in C# and performance was never really the ...
ScrappyHaxor's user avatar
1 vote
2 answers
409 views

Automatically registering a class using header-only templated classes

I'm trying to reduce the boilerplate of a lot of header-only classes I'm using. Each of these classes must go through a registration step. I want this step to be defined in the same file as the class ...
Delgan's user avatar
  • 551
0 votes
1 answer
256 views

Derived class constructor taking rvalue ref to base class

I've got the following classes: BaseWidget, ActiveWidget, and DetachedWidget. Both derived classes use resources provided by BaseWidget: vector and int. The current so-called "state" (...
bielu000's user avatar
  • 241
2 votes
1 answer
190 views

Counting Radix Sort: A C++ version

Follow up to original question: This is Radix Sort, using a counting implementation. For numbers that are N bytes in length, we use an N pass counting approach. Starting with the least significant ...
Martin York's user avatar
  • 93.3k

1
2 3 4 5
12