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
47 views

ReadDirectoryChangesW Improvements

I'm currently using the ReadDirectoryChangesW Function from the Windows API to build a Directory Watcher. The Watcher should monitor a folder for newly added files. ...
Kevin's user avatar
  • 145
2 votes
1 answer
117 views

OrderBook Implementation - Follow up

This is a follow up to my previous implementation: The input is of the format ...
Avengerx9's user avatar
2 votes
2 answers
159 views

Design decisions for an efficient OrderBook

I am designing code for OrderBook based in C++, based on STL library. Note that there is a related question here, however it is more simple - it does not support deletion of orders, and I intend to ...
Avengerx9's user avatar
4 votes
3 answers
310 views

C++ custom string class implementation

I recently had an interview where I was tasked with implementing a custom C++ string class without using the STL. The interviewer provided the function signatures and variable declarations, specifying ...
Jacob's user avatar
  • 111
-3 votes
1 answer
219 views

Design a set to classes to report battery/power status of different Alexa devices

I was asked below quesion in Amazon sde2 low level design interview recently and I have shown below my solution during the interview. I was rejected in this round. ...
sachin's user avatar
  • 45
5 votes
2 answers
531 views

std::chrono compatible clock using CLOCK_MONOTONIC_RAW

We're using std::chrono::steady_clock for most of our internal queues and relative timings. However, we're on a POSIX platform and ...
Ted Lyngmo's user avatar
5 votes
2 answers
178 views

C++ UniquePtr Implementation

Took a shot at implementing std::unique_ptr. Code: ...
jdav22's user avatar
  • 319
1 vote
1 answer
108 views

HTTP routing with Mongoose

I'm trying to extend the Mongoose RESTful server example with URL routing. This code relies on the Mongoose library available here. This is heavily inspired by the routes class from this question but ...
S Meredith's user avatar
2 votes
1 answer
83 views

Better JVM Bytecode Struct with Serialiser & Parser Without #MACROS

Preamble I was inspired by this review request to create my own quasi JVM Byte Code Struct, Parser and to top it a bit I also wrote two a quasi executors. Currently, they just print the instructions ...
Ajinkya Kamat's user avatar
8 votes
2 answers
949 views

JVM bytecode instruction struct with serializer & parser

I am writing a java class file parsing & serialization library. As part of that i needed to implement a structure for the JVM bytecode instructions as well as come up with a way to parse & ...
p0sa's user avatar
  • 81
4 votes
2 answers
816 views

Fast OrderBook Implementation

I'm creating a simple yet fast OrderBook, that only adds orders and matches them (no cancelling or modifications, etc.). I'm using partial template specialization to reduce branching in the hotpath, ...
jpf's user avatar
  • 63
4 votes
2 answers
149 views

Create classes for matrices, including inheritance

I've been learning C++ on and off, and recently learnt about overloading and templates. I wanted to used these concepts to create classes about matrices using ...
eccentricOrange's user avatar
5 votes
1 answer
81 views

leetcode 530. In-order traversal of a binary search tree (C++17)

Given a binary search tree, the problem requires calculating the minimum absolute difference between any two keys in the tree. Given the binary search property, the minimum difference must be between ...
loonatick's user avatar
  • 153
2 votes
1 answer
94 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
48 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
84 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,480
6 votes
2 answers
541 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
  • 71
1 vote
1 answer
1k 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
96 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
66 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
  • 94.3k
6 votes
1 answer
371 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
1k 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
674 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
113 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
133 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
334 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
306 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,480
3 votes
1 answer
308 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
93 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
978 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
100 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
188 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
57 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
355 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
164 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
222 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
223 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
933 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
269 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
  • 187
4 votes
1 answer
808 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
153 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
21 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
72 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
178 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,480
1 vote
1 answer
7k 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
  • 239
2 votes
1 answer
265 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
410 views

Templatizing a Timer class

I'm making a timer class in C++. This is the overview: ...
Alex CB's user avatar
  • 175
2 votes
1 answer
166 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
325 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
2 3 4 5
12