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
57 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 ...
user avatar
4 votes
1 answer
166 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 ...
user avatar
  • 43
4 votes
2 answers
75 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 ...
user avatar
1 vote
1 answer
80 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. ...
user avatar
  • 241
0 votes
3 answers
133 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&...
user avatar
0 votes
1 answer
86 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 ...
user avatar
3 votes
1 answer
95 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 ...
user avatar
8 votes
4 answers
1k 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 ...
user avatar
2 votes
1 answer
115 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 ...
user avatar
  • 23
1 vote
1 answer
72 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 ...
user avatar
  • 390
11 votes
3 answers
794 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. ...
user avatar
4 votes
0 answers
32 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-...
user avatar
2 votes
2 answers
61 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 ...
user avatar
1 vote
2 answers
103 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 ...
user avatar
  • 541
0 votes
1 answer
41 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" (...
user avatar
  • 241
2 votes
1 answer
75 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 ...
user avatar
  • 91.5k
2 votes
0 answers
90 views

A reuseable reconnecting TCP socket with Asio

I'm using (non-boost) Asio 1.18.1 and C++17. Forgive the boost tag, there wasn't a more specific one. I have a async_connect_with_retry composed asynchronous ...
user avatar
  • 153
2 votes
3 answers
134 views

Fixed-size memory allocator

I've been trying to implement a simple Boost PMR allocator that has a fixed amount of memory. My first implementation (which can be found here) had undefined behavior and did not handle memory ...
user avatar
  • 31
5 votes
2 answers
546 views

C++ Garbage Collector - Simple Automatic Memory Management

I made a general smart pointer which fixes the problems of loops between std::shared_ptr's. While use is simple, I feel that my code is inefficient and clumsy. Here ...
user avatar
6 votes
2 answers
404 views

Writing a C++ Matrix class

I am refreshing my C++ programming skills, and I'm currently reading the book C++ 17 by Ivor Horton. The idea is to code some naive implementations of numerical algorithms (Root finding, solving a ...
user avatar
  • 335
2 votes
1 answer
209 views

Implementation of an entity component system in c++

I tried to write a simple entity component system for my game engine. Each scene will have an EntityManager. It will create entities and add or remove components from them. An entity will be destroyed ...
user avatar
7 votes
5 answers
1k views

Robust program to write an array of certain data type to a binary file and read back from it (C++17)

Problem description As the title indicates, I want to be able to write to and read from a binary file safely, in the sense that I want to have full control of everything that might go wrong. Since I ...
user avatar
3 votes
3 answers
121 views

Convert program arguments to std::wstring

Due to recent need I wrote a simple main function that has the goal to convert the C-style strings and arrays into a more STL-style. Then because I also had a need ...
user avatar
2 votes
1 answer
57 views

C++ allocator for std::wstring_convert

In my application, I'm using std::wstring_convert to convert std::string into std::u32string....
user avatar
9 votes
2 answers
697 views

Yet another minesweeper field calculator

The task is to read in a data file containing a representation of a rectangular array with '*' signifying a mine and '.' signifying the absence of one. Each such array is preceded by a row and column ...
user avatar
  • 64.1k
5 votes
1 answer
128 views

C++ Mine Sweeper Attempt

Saw this question and though I wanted to try. So my version of reading Mine Sweeper: For the Online Judge Some Utilities Classes ...
user avatar
  • 91.5k
4 votes
2 answers
89 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 ...
user avatar
1 vote
1 answer
56 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 ...
user avatar
  • 125
2 votes
1 answer
110 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 ...
user avatar
  • 1,354
8 votes
0 answers
212 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 ...
user avatar
  • 181
4 votes
1 answer
101 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. ...
user avatar
1 vote
2 answers
119 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 ...
user avatar
  • 11
2 votes
2 answers
103 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. ...
user avatar
  • 153
2 votes
2 answers
67 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 ...
user avatar
  • 121
1 vote
1 answer
97 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 ...
user avatar
0 votes
1 answer
56 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. ...
user avatar
4 votes
1 answer
283 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 ...
user avatar
  • 155
4 votes
2 answers
2k 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,...
user avatar
1 vote
1 answer
54 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 ...
user avatar
1 vote
1 answer
116 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: ...
user avatar
3 votes
2 answers
123 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? ...
user avatar
13 votes
1 answer
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 ...
user avatar
  • 233
2 votes
2 answers
353 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 ...
user avatar
1 vote
0 answers
39 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 ...
user avatar
4 votes
3 answers
1k 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: ...
user avatar
2 votes
1 answer
70 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 ...
user avatar
  • 123
3 votes
1 answer
113 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 ...
user avatar
2 votes
1 answer
87 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 ...
user avatar
  • 121
3 votes
0 answers
76 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 ...
user avatar
  • 9,466
3 votes
1 answer
148 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 ...
user avatar

1
2 3 4 5
11