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
1
vote
2answers
85 views

Get pixel color from screen in C++ on Linux

For a long period of time I worked on this code, mostly trying to understand it. That is the main reason for needed review. Second reason is simply that I would like to optimize it in any way you can ...
2
votes
1answer
25 views

Group built in types to category

I've created the following program to assist me in some template stuff I'm working on. The function get_type returns 0, 1, 2, 3 or ...
5
votes
1answer
51 views

`zip` operator to iterate on multiple container in a sign

I worked out a zip operator similar to Python's, because I didn't find one in std. It allows to use range-based ...
3
votes
1answer
45 views

C++ Optional Reference

Here is a good article on an optional reference type in C++. They discuss std::optional<T&>, but as that doesn't compile I have made my own. One purpose ...
4
votes
2answers
84 views

Improving function that replaces all instances of x with y in string

I have the following: ...
0
votes
1answer
46 views

bad GNU libc argp code [closed]

In helpcovid git commit e27dd3b123c18300665 we have a stupid bug related to Linux GNU glibc argp program argument parsing. <...
2
votes
1answer
86 views

“Structure of arrays” wrapper

I was looking into SOA to better utilize SIMD instructions. I implemented a generic wrapper object that lets you chose the amount of individual vectors each structure consists of. I am using xsimd and ...
2
votes
1answer
41 views

template iterable numeric range class with multiple min/max inclusion modes

Problem my code solves: Lack of lightweight numeric range classes which can tell if arbitrary values lie inside them, supporting more than just simple exclusive max modes and integers, and that ...
1
vote
1answer
25 views

Class ISBN - checks for valid ISBN 13

I am at the moment trying to grasp multi-file programming instead of one big main.cpp. The class I wrote is about ISBN 13. Can you point out what could be done to improve my code? Also is there a ...
3
votes
1answer
45 views

C++ My implementation of a simple sum type (variant)

Here is a simple variant type I have made. For simplicity, it only can handle two different values. I am planning on using this to create a variadic variant template, using inheritance and recursion. ...
3
votes
1answer
65 views

Exercise: Reading doubles from a file and printing mean, max and min (from Programming Principles and Practice using C++)

Read a sequence of double values into a vector. Think of each value as the distance between two cities along a given route. Compute and print the total distance (the sum of all distances). Find and ...
5
votes
2answers
59 views

Concisely, robustly, temporarily stashing c++ iostream formats

I got tired of the boilerplate and tedium restoring formatting context, so I made an RAII stasher that relies on the destroy-at-end-of-full-statement temporary semantics. With C++17 I can get it down ...
2
votes
0answers
51 views

Implementation of Doubly Linked List with sentinel in C++ trying to replicate the stl std::list [closed]

I am currently trying to replicate the STL std::list interface with my own list implementation (doubly linked list with sentinel) to learn about all the advanced ...
6
votes
1answer
44 views

Custom manipulator for changing at what characters a std::istream split words

Introduction By default, input streams (e.g., std::cin or a std::istringstream) split words at space when using the ...
1
vote
1answer
55 views

Minimal Property system in c++17

So I needed to represent by objects in terms in ini format and change their values from the ini as well, so I thought why don't implement a property system for this. I want it to be bit fast so I ...
8
votes
3answers
1k views

Reverse each word in the string. All spaces in the string should be retained

This was part of a code challenge. I use them to help me learn c++/c# along with tutorials and guides. Basically I was taking a string... The quick brown fox jumps over the lazy dog. ...and ...
1
vote
1answer
52 views

My second hangman game (Hangman in C++), how to avoid nested while-loops? How to stick to the SRP?

Here I already asked for tips, and I wrote another hangman game with the tips I got. My questions are: is int game() doing too many things that I should split ...
12
votes
4answers
2k views

BigInt class in C++

I made a BigInt class that supports almost all functions an int would. The code seems too bulky and there might be a few bugs lurking here and there. I would like ...
1
vote
1answer
54 views

Better to use string concatenation using std::string::operator+() or std::string::reserve() and std::string::append()? [closed]

I'm doing some code review and I saw something like the following: ...
0
votes
0answers
46 views

Making a parameter struct that preserves const

Given a group of functions that all take similar arguments, eg. ...
-2
votes
1answer
60 views

C++ generic task interface for delayed execution

I want to rework my current game-server engine to use some global queue of tasks which will be distributed through all the working threads. I started with task interface. I want it to be able to ...
5
votes
2answers
258 views

Message Broadcaster

I've written a basic event messenger broadcasting service. This is meant to allow for broadcasting events between loosely coupled areas of code where you may not have or care about a direct reference ...
1
vote
1answer
67 views

Scoped thread using modern C++

I wrote this simple scoped thread to use it as a class member to ensure the the thread running on a class method doesn't continue running after the class has been destructed. Also to spawn threads ...
2
votes
2answers
65 views

Shared memory class

I wrote a class that opens a shared memory communication to use in my project, and would like a review. mylib_com.hpp ...
2
votes
1answer
54 views

C++ Fixed-size general-purpose thread pool

I've been reading about thread pools in C++ for a few days now and decided to roll out my own. I mainly intend to use it to learn how to implement parallel algorithms at some point in the future but ...
5
votes
1answer
82 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
76 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
59 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
109 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
124 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
142 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
78 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
535 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
38 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 ...
1
vote
1answer
73 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
554 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
71 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
66 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
55 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
145 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
102 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
134 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
53 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
125 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
111 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
126 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
130 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
41 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 ...

1
2 3 4 5
7