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
4
votes
2answers
65 views

Python's enumerate for C++

I implemented an enumerate() method for C++ containers similar to Python's enumerate to iterate through a range with an index and the actual value. I have the following questions: Does the usage of ...
1
vote
1answer
47 views

Blocking until one or multiple signals is emitted

I've written this little helper function, that will block the current thread until any of a given list of signals is emitted by an object or until an optional timeout is reached. It can be used to ...
2
votes
1answer
103 views

looping over variables of heterogeneous type

These snippets are nothing special, but they remind us to sometimes loop without a for or a while loop. It is even possible to ...
7
votes
0answers
55 views

A simple Qt + MQTT doorbell application

So I built a house recently and didn't want to rely on "privacy-questionnable" systems like Google Home or Amazon whatever so I decided to build a doorbell system myself. Hardware I use a ...
4
votes
1answer
57 views

Cryptographic hashing class using OpenSSL's EVP interface

I have written a cryptographic hashing class named Ccksum::DigestHasher that allows the caller to select a hashing algorithm by name via OpenSSL's EVP interface. ...
1
vote
2answers
108 views

Chess engine generates moves

I am currently writing a chess engine to improve my C++. I was able to improve my first results in terms of performance. (It is still really weak, but it does not lose a queen in one move) I ended up ...
2
votes
2answers
92 views

Creating a threadsafe, mutable, global configuration struct wrapper with C++17

I'm trying to create a relatively simple class that stores global configuration in some serializable struct, and reads/writes from/to a file. My main goal is to make this class easy to use correctly. ...
2
votes
2answers
62 views

A simple write-once-read-many indexed based database

I started writing a cyrptocoin from scratch, and then got sidetracked writing the database portion which I eventually turned it into its own project. Data is written to the database and then retrieved ...
1
vote
1answer
56 views

Typesafe implicit wrapper for C enums

This is meant to go in a vulkan.hpp-like strongly-typed wrapper for a pure C library. A wrapped enum provides back and forth implicit conversion between itself and ...
0
votes
1answer
54 views

Enter the randomly displayed letter console game

The below code segments compose a simple console game where the user is prompted to enter a randomly generated letter displayed in the console. It also saves and loads user data through a .txt file. ...
4
votes
1answer
257 views

Token class implementation with std::variant

So I've been trying to implement a Token class in C++. At first I wanted to use a simple enum class to store the Kind of the ...
4
votes
2answers
820 views

Custom UUID implementation on C++

The code's gonna be pretty simple and YES, I do know, what a proper UUID4 implementation is and what are possible approaches to implement RFC 4122. But somewhere there exists a small piece of software,...
1
vote
1answer
47 views

A multi key/value type "folded" map class template

I have recently come across a use case where I need to lump many maps into a single container. These maps can have different combinations of key/value types, but they all differ from one another. For ...
1
vote
1answer
68 views

Gather all IP addresses of a host as a vector

I have the following working code to get IPv4/v6 addresses from host names: ...
3
votes
2answers
83 views

Custom Error Handler Library in C++

Is this code clean and optimized? When taking memory snapshots, it seems a bit high. Anything I have done wrong or can do to optimize it? ...
12
votes
1answer
1k views

Simple NAPI wrapper around self written C++ msgpack, horrible performance

I have written a relatively small msgpack implementation in C++, with performance that is not too bad, so I decided to write a NAPI wrapper around it, but the performance is just horrible. I am ...
2
votes
2answers
126 views

Storing a copy of unique_ptr

When one writes c++ code to manipulate LinkedLists, Trees, etc. one creates a tmp pointer that points to the start/root and changes that pointer as one traverses along. What would be the equivalent ...
1
vote
0answers
35 views

Access object initialized within try block afterwards if no exception occured

I have a use case where I try to initialize a Player object within a try block. The relevant excerpt of the current, working ...
4
votes
3answers
917 views

De-/Serialization of structs representing TCP messages

I wrote two template functions to serialize and deserialize structs representing messages to be sent and received via a TCP socket: ...
2
votes
1answer
61 views

Is this thread pool implementation OK?

There are things that I am not 100% sure. Is it possible that dangling references can be create in add_task method? Is it possible that this implementation will deadlock? I had to use shared_ptr in ...
3
votes
1answer
94 views

Image (Const) Iterator using C++17

I am trying to learn how to correctly implement an iterator (and its corresponding const variant) using a single template, so I would appreciate any criticism to the following code. It's an forward ...
2
votes
1answer
79 views

Safe runtime numeric casts

The rationale behind this code is to implement a runtime-safe number conversions in situations when precision loss is possible, but is not expected. Example: passing a ...
3
votes
0answers
66 views

Num++: A numpy implementation written in C++

I've recently found myself in need of several numpy functions in C++. I've decided to write my own header-only implementation of the ...
3
votes
1answer
83 views

Asynchronous dispatch queue

Background: This is supposed to be the sole worker thread to carry out long-lasting jobs in a GUI application. The GUI thread should be able to schedule tasks in a non-blocking manner and the tasks ...
2
votes
1answer
67 views

Getting hard-drive serial number on Windows

The point is to get the serial number of one of the hard drives on Windows. My code is based on an example from MSDN. I tried to make it an exception-safe, self-contained function. It works, to the ...
1
vote
1answer
67 views

OpenGL mesh class and derived primitive class

Introduction After finishing most of the tutorials on https://learnopengl.com/ I started to encapsulate code in their respective classes and started to write a mesh class and a polygon class as my ...
2
votes
2answers
731 views

C++: Event system for game engine

Since writing your own C++ game engine seems to be really popular these days (seriously just look at the amount of people presenting their WIPs on YouTube) I figured I'd try it myself. My mental model ...
2
votes
0answers
103 views

Improving constexpr invoke function C++17, alternative to std::invoke

I've learned that in C++17, std::invoke isn't constexpr. To make a constexpr version, I could copy the implementation provided here: https://en.cppreference.com/w/cpp/utility/functional/invoke , OR I ...
6
votes
1answer
85 views

Writing a thread-safe ring queue in C++17

I tried implementing a thread-safe ring queue in C++. I'm totally new to move semantics and C++11/14/17 in general. ...
4
votes
2answers
321 views

"observer pointer" meant to stay updated when the pointed object is moved in memory

I wasn't sure about how to name it, maybe "follow_ptr", "self_updating_ptr", or "stalking_ptr" or something on those lines. For now it's called Identifier. What I'm ...
1
vote
0answers
77 views

Skyscraper Solver for NxN Size Version 4

This is a follow up of Skyscraper Solver for NxN Size Version 3 I know its getting old... So I still have the same Issue the code is to slow to solve bigger skyscraper puzzles. Since the last Version ...
2
votes
2answers
114 views

Find neighbours of a vector

To find neighbors of a vector and return array of Vectors which are neighbors of a Vector: ...
3
votes
0answers
94 views

Algorithm for auto tiling of tiles in a 2D tile map

Introduction I have implemented an algorithm that applies auto tiling to a 2D tile map for a game, selecting the correct tiles according to their neighborhood. Given a string representation in a ...
1
vote
1answer
66 views

Skyscraper Solver for NxN Size Version 3 (Using Bitmasks)

This is a follow up of Skyscraper Solver for NxN Size Version 2 (Using Backtracking) I followed the advice in the last Codereview and did the following optimizations: Implementation of the class <...
1
vote
1answer
272 views

Skyscraper Solver for NxN Size Version 2 (Using Backtracking)

This is a follow up of Skyscraper Solver for NxN Size I followed the advice in the last question and changed my approach from generating Permutations to use Backtracking to solve the puzzle. ...
8
votes
2answers
152 views

re-implementation of std::vector

I've implemented a simple vector-like structure. I would appreciate all criticism relevant to code. I have also published code under github. Here is the link to source code + unit test for most ...
3
votes
1answer
2k views

Skyscraper Solver for NxN Size

I try to solve a kata on codewars which let you write a skyscraper solver for skyscrapers up to size 11x11. Basic Example what is a skyscraper puzzle (here with 4by4 but the principle stays the same): ...
3
votes
2answers
133 views

Multithreaded logger

I made a multithreaded logger years ago when I was still a total newbie. It "worked" (when it didn't deadlock). Now that I'm slightly less newbie I'd like to get some criticism on this new ...
15
votes
3answers
5k views

C++ Fast Fourier transform

This is a very simple FFT, I am wondering what I can do to make this faster and more memory efficient from the programming side (better data types, and maybe some tricks like unrolling loops or using ...
3
votes
1answer
70 views

Assignment function as alternative to std::tie

What do you think about this assignment "idiom"? ...
-1
votes
1answer
174 views

Generating permutations fast

I run into a performance bottleneck in a program. I have to generate all permutations for a given sequence with size up to n=11. My code: ...
1
vote
1answer
133 views

Snake game in C++17 with SDL2

I implemented a simple snake clone in C++, using SDL2 for the graphics part. Gameplay-wise, its pretty much classic snake: The player is able to control the snake with "WASD", food gets ...
6
votes
2answers
128 views

C++ Implementation of a Python-like memoization decorator

Coming from a Python background, one thing I really miss in C++ is a memoization decorator (like functools.lru_cache. As I sometimes compete on Codeforces, I found ...
-1
votes
2answers
187 views

C++17 multi threaded thread "pauser"

I needed a way to pause multiple threads from a single parent thread, this was my solution for the general case. I would like advice on code quality and enhancements. I'm particularly interested if ...
-1
votes
2answers
87 views

Using a lambda to generically create an arbitrary class wrapper around some object of type T [closed]

While experimenting with some of C++'s language features, I was able to successfully design an invokable nameless function call through the use of a lambda that generically creates an arbitrary class ...
1
vote
1answer
67 views

Advent of Code 2020 - Day 2: validating passwords (C++ version)

Original: Advent of Code 2020 - Day 2: validating passwords Problem statement I decided to translate my Rust solution to Advent of Code 2020 into C++ to increase my familiarity with C++. Here's the ...
6
votes
2answers
545 views

shared_ptr and make_shared implementations (for learning)

Recently, I've been going through Scott Meyer's Effective Modern C++ and found the discussion on shared_ptr really interesting. I also watched Louis Brandy's ...
1
vote
1answer
174 views

C++ shared pointer wrapper for lazy initialization

I have written a very simple wrapper around std::shared_ptr that supports lazy initialization. Do you see any problems? ...
0
votes
1answer
155 views

Generic Meyers Singleton implementation in C++

Is this a correct implementation of a generic Meyers Singleton in C++17? Any tips appreciated. Singleton.h ...
2
votes
1answer
78 views

University Grading System (OOP)

I've been furthering my development and understanding in OOP (Object Oriented Programming) and would appreciate feedback on this new console program I've created. The main aspects I would like to know ...

1
2 3 4 5
11