Questions tagged [c++17]

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

Filter by
Sorted by
Tagged with
5
votes
1answer
44 views

Iterating over a tuple

I tried to write a small header-only library that provides a type similar to iterators for std::tuple as well as some STL-like algorithms. I would be grateful for ...
2
votes
4answers
69 views

Storing function metadata

In a project, we have a file that contains something like a script which we need to parse. At the moment the validation is tough since we have an array of functions returing ...
2
votes
1answer
55 views

Header only HTTP client library that is a wrapper around CURL

For learning purposes, I wanted to create a header-only C++ wrapper library around HTTP CURL functionality. At the moment the library only implements GET and POST, but I will add other HTTP methods ...
-1
votes
1answer
100 views

Fast efficient C++ Singleton template with proper constructor and destruction order

I wrote a Singleton template, with examples, google tests and README https://github.com/erez-strauss/init_singleton/blob/master/singleton.h The usage can be as simple as: ...
5
votes
2answers
107 views

More ergonomic / convenient STL algorithm calls — sort order & member field extraction using std::invoke

While we patiently wait for ranges in C++20, it can still get somewhat frustrating to write begin(), ...
5
votes
3answers
137 views

Pythagorean Triple finder

Would like some feedback on a code style exercise motivated by this PythagTriple algorihtm. I started with the Rosetta Code - "efficient C" solution (not the naive one) and refactored it heavily into ...
2
votes
1answer
71 views

Wrap that uses filesystem in C++

This is a wrap that queries the number of files and folder from a given directory, also list the folders and files into a vector. I have posted another wrap in this discussion that do the same things ...
7
votes
3answers
509 views

C++/Opengl voxel renderer

I have tried going back to C++ after long time of mainly doing C#. I realize that the code is far from perfect, however I would really appreciate if someone could point of what exactly is wrong and ...
0
votes
1answer
32 views

Parsing HTML knock-off for answering queries for values

I wrote a code to parse an HTML knock-off from HackerRank, and I would like a review. Mostly I hope to get better at STL and code style. But any tips would be very welcome. Sample input that I would ...
-2
votes
0answers
36 views

Iterating through map keys in C++ 17 [migrated]

I am looking for a way to iterate through the keys of a map in C++ 17. The way that I have in mind right now is based on the answer of this question, the way is presented below. ...
1
vote
1answer
62 views

Car Milage and Cost Calculating System based off menu selections (using a class)

I was wondering if anyone would be kind enough to review my basic c++ program. I'm a beginner programmer so was hoping to get feedback on how well I've used object oriented programming i.e. using a ...
7
votes
3answers
503 views

Coalescing lvalue references to std-optionals

I want to coalesce (lvalue references to) optionals of the same type, in C++17: ...
5
votes
1answer
63 views

Pointers to polymorphic classes saved in vector that reference data in a list as source

I have a list called data with strings in it. I have a class String that derives from class Item. A class ...
2
votes
1answer
63 views

Subset Component Task

I've solved a problem Subset Component Problem You are given an array with n 64-bit integers: d[0],d[1],….,d[n-1]. ...
1
vote
1answer
38 views

Custom bounded memory pool allocator

Recently I put together a custom fixed size (bounded) memory pool for my job system implementation to support its internal memory management. Since it will be accessed by different threads I want to ...
5
votes
2answers
141 views

Running out of fuel near Saturn

Optimizing/parsing files into semi-complex data-structures more efficiently To preface, I'd like to say that this code is part of the Advent of Code 2019 solutions I have been working on. ...
2
votes
3answers
100 views

Check if there's exactly one match in a vector

The challenge is to iterate over the vector only once and return the value within the range of the zero. However, if there are no matches or more than 1 match, deliver an error. The vector is unsorted ...
6
votes
1answer
85 views

LZ77 compression algorithm (general code efficiency)

I'm implementing LZ77 compression algorithm. To compress any file type, I use its binary representation and then read it as chars (because 1 ...
2
votes
1answer
51 views

Processing all files in directory

DO NOT RUN THIS EXAMPLE BLINDLY, IT REMOVES ALL FILES UNDER argv[1] Hello, This little programm should read all files from a given directory and do some work with them. New files are constantly ...
21
votes
4answers
5k views

Rock, Paper, Scissors in C++

I have a fair few years experience with programming, and am currently working in a software development role, writing internal web applications in C#. This is the first C++ code I have ever written, ...
7
votes
2answers
106 views

Hunt the Wumpus Game (C++ with QT)

I reworked the Game I did in FLTK some while ago: Hunt the Wumpus GUI (FLTK) This time I used C++ with the Qt Framework. The result looks like this: If you want to try out the game. The full code ...
5
votes
1answer
81 views

Wrapper class template for std::map + std::list to provide a SequencedMap which retains insertion order

Review on this draft please: clang-8 -std=c++17 Simple wrapper class template for std::map & std::list (or alternatively std:unordered_map & std::vector) for the purpose of "retaining ...
0
votes
0answers
47 views

Scheduling threads to run at a particular time

I was wondering if you could please comment on code quality, correct usage of c++17 constructs, stl/c++ compliant api, performance, or anything else that you might find relevant. Also do you think ...
3
votes
0answers
107 views

Sorting Algorithms in C++ - Insertion Sort and some variants

I'm learning C++, data structures and algorithms and decided to implement some sorting algorithms using generic iterators instead of array indices. This post contains code for insertion sort and ...
5
votes
0answers
126 views

Implementation of container searchable by any element

Writing game engine as a hobby, I've come across many situations where I need a container like a map, but searchable by different keys: a block allocator where a block needs to be searched by either ...
2
votes
0answers
36 views

Fibonacci and Lucas sequence generator using Boost and GMP

I implemented this console application that generates Fibonacci and Lucas sequence numbers using boost and GMP for multiprecision. There is an iterator-like class which can do any sequence based on ...
2
votes
1answer
105 views

C++ ring buffer using some C++ 17 and coming C++ 20 std::span

When I heard about the new Linux I/O interface io_uring I searched about the ring buffer. I then thought I may replace my safe queue which is base on C++ 11 ...
-1
votes
1answer
29 views

Provide one file where all error messages are defined in c++ [closed]

I would like to store all error messages in one file and call them for example with ...
9
votes
1answer
253 views

Simplified Linked List Implementation in C++

I'm learning C++, data structures and algorithms and I have implemented a (Doubly) Linked List class for practice. Some STL functionalities are deliberately missing for now (e.g. some functions ...
5
votes
1answer
96 views

Finding the 5 youngest users who have valid US telephone numbers - follow-up

Continuing from: Part 1 I was not convinced this was true (see comment): ...
3
votes
2answers
130 views

Finding the 5 youngest users who have valid US telephone numbers

Update: see also version 2 The Service This code uses two API's. List ...
6
votes
2answers
145 views

Minefield - A Cross Platform Minesweeper clone

I just finished a full minesweeper clone which is based on Minesweeper for Windows 95. I used C++ and Qt to realize it. The full source code can be find in my git hub. Since this is too much code ...
1
vote
0answers
50 views

Daubechies wavelet and scaling filters: Is there a better way?

I have computed the Daubechies wavelet and scaling filters in float, double, long double, ...
5
votes
2answers
217 views

C++17 zip iterator compatible with std::sort

Here are ~100 lines of code implementing three classes (ZipRef, ZipIter, Zip) which should ...
3
votes
1answer
64 views

Container that holds objects of various types, and can be searched for an object convertible to a given type

I built a container that can hold objects of various types, and look up an object convertible to a given type. I wrote something about my intended use-case here: https://stackoverflow.com/questions/...
6
votes
1answer
147 views

Simplified Vector Implementation in C++

I have implemented a class Vector to learn about data structures and algorithms and how to implement them using C++. I have yet to implement some std::vector functionalities e.g. custom allocator ...
2
votes
2answers
86 views

Permutation generator with OR operator

Problem: Given a vector of strings, I want to print out all possible permutations where the strings may contain an OR operator (the | character, as in regular ...
2
votes
1answer
108 views

filesystem create a folder

I got a mixture of two languages ​​C and C ++ The code finds the folder my documents and creates additional folders in it when the program starts, I found no other way to implement this better. I ...
10
votes
2answers
692 views

Iterator for traversing a tree [v2]

this is an update of the implementation after I followed the feedback from Iterator for traversing a tree. After that I did changed quite a bit on the design and decided to ask for another round of ...
3
votes
1answer
65 views

Iterator for traversing a tree

What I want to achieve is the following: ...
9
votes
2answers
2k views

Print-based debugging

...
3
votes
1answer
30 views

Implement Fibonacci range

I am implementing a Fibonacci range in C++17 such that it supports ...
5
votes
3answers
230 views

C++ logging class

I've created a simple C++ logging class. It outputs various loglevels, and adjusts output color accordingly. I'm interested in any tips to improve my coding style. I am especially concerned with my ...
2
votes
1answer
33 views

Merge adjacent occurrences of identical elements in data collection

There is a small programming exercise to merge adjacent identical elements in a collection. Here are two solutions (passing the tests from the exercise). I am asking for review of the first version ...
6
votes
1answer
60 views

Convert a Hex value string to an ASCII Text String

We had a little bit of fun in the 2nd Monitor this morning, one user greeted another with a hex string. It turned out that the user being greeted deals with Hex Dumps enough that they were able to ...
4
votes
1answer
62 views

Implement HTTP server using libevent

...
7
votes
1answer
140 views

Lazy Resource Loading class in C++

Recently I was studying about the benefits and uses of std::optional in C++17 (Bartek's Blog) and there I saw a line that said "...
1
vote
2answers
94 views

Optimizing the Sieve of Eratosthenes for prime generation

I've been on a Project Euler spree and I've been solving problems and as you might know, many of them require you to use prime numbers. I've been using the following code to generate and store primes ...
5
votes
2answers
113 views

Tokenizer Class for handling .csv files in c++17

I am a hobbyist computer programmer trying to learn modern C++ (in this case C++17). I thought it might be an interesting challenge to write a tokenizer class for ...
3
votes
2answers
142 views

C++ Building Parse Tree with Boost and Modern C++

I am writing a parser. To build up the tree, I need to find the correct type for my node based on text from my language input file. Right now, I have a map from a string (the node name) to a factory ...