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
3
votes
1answer
84 views
+150

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
1answer
60 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 ...
14
votes
3answers
4k 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
57 views

Assignment function as alternative to std::tie

What do you think about this assignment "idiom"? ...
-1
votes
1answer
102 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
60 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
85 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
91 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
74 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
45 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
227 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
49 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
74 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
69 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 ...
0
votes
1answer
20 views

Simple runtime profiler for executable files

I'm sure there are several profilers written in C++ on here already, though with this one the goals are quite different. I attempted to make it as robust as possible, or 'fool-proof' if you will so ...
0
votes
0answers
12 views

Simple Parallel Sorting

i had made a simple parallel sorting for my personal games. it did well so far, but i would like to get some advises about how to improve it further or perhaps there are an alternative methods for ...
2
votes
0answers
34 views

Making std::optional a monad via SFINAE

To practice with SFINAE, template meta programming, functional programming and monads in C++, I decided to try writing a skinny version of the two functions (monadic binding and return) that make <...
3
votes
2answers
82 views

Allow one thread to execute section while others wait and resume

I have a requirement that is summarized below. ...
2
votes
1answer
136 views

C++ callback multithreaded, can unregister itself

update: a new version of this code is posted here With this post, i would like to 1) ask for feedback on below code as it stands: do i apply all best practices for c++20? is it safe? is my way to ...
3
votes
1answer
205 views

C and C++ programs which let you lengthen the time it takes to access files

https://github.com/speedrun-program/load-extender It’s a pair of programs for extending load times, one for Windows and one for Linux. The Windows version is written in C++, and the Linux version is ...
4
votes
2answers
50 views

A simple multithreaded openrct2 maze simulator

I found these two videos by Marcel Vos: (1) (2) that show how you can make hedge mazes that are very hard for the simple roller coaster tycoon 2 park guest AI to solve. Long story short, he eventually ...
2
votes
1answer
61 views

C++ implementation of recursive_shared_mutex

I know it's bad to even use recursive_mutex because of its poor performance, let alone a recursive shared mutex. However, I'm doing this just to practice. Any suggestion will be appreciated! ...
6
votes
1answer
51 views

Header-only generic console menu maker

Some time ago, I wrote this answer to a question about creating a command line menu. I referred to it recently and noticed a few things that I wanted to improve. Purpose As with the original version, ...
8
votes
3answers
364 views

Sinclair Spectrum TAP file dumper

The other day, I had occasion to want to look into an ancient piece of Z80 software written for a Sinclair Spectrum computer. Software for this machine was typically saved to audio tape, and today ...
5
votes
1answer
186 views

A-star pathfinding algorithm

I'm working on a school project where I need to implement the pathfinding algorithm. The requirements are that it needs to find the path in at most a few seconds and ideally in less than 1 second. I'...
4
votes
1answer
134 views

Noughts & Crosses (Final Version)

I've made a major update to my Noughts & Crosses program, this ISN'T a duplicate! I know it's not good to use system("pause") and system("cls"), however, I just wanted to make ...
5
votes
1answer
133 views

Noughts and Crosses (Tic Tac Toe) C++ Console Application

I was hoping someone could review my C++ console based noughts and crosses (Tic Tac Toe) application. I have not looked at any other documentation, this is purely programmed from the top of my head. ...
8
votes
0answers
100 views

C++ Event System - Game Engine

Introduction I have just started learning templates and experimenting with function pointers. I wanted to create an event system that met a couple of goals: Event types are PODs, and do not inherit ...
8
votes
1answer
135 views

Generic test case templates

I often find that when I am writing, refactoring, or reviewing code that I want to do some simple testing. There are many existing test frameworks such as gtest and cppunit but my desire was to ...
4
votes
1answer
56 views

Template Metaprogramming and Modular Arithmetic

Story I'm trying to become more familiar with template metaprogramming and practice more of it. I need to use modular arithmetic to solve certain problems and so I decided to write a general purpose ...
13
votes
2answers
544 views

Sudoku solver program written in modern c++

This is a simple program that solves a given Sudoku puzzle recursively. The input is provided as a file that contains the cells, 0 if empty, delimited by a , ...
9
votes
2answers
316 views

Huffman encoding bitcodes display

So, the concept of the code is simple. Take any file, read the binary character counts and construct a Huffman tree, and then output the bit code of each character (displayed as its 8-bit value). This ...
5
votes
1answer
123 views

Template Metaprogramming - Multidimensional Vector Declaration

[EDIT] The question has been edited. Please make sure to read the summary at the end of the post. If you'd like me to make a new post with a cleaner explanation and better examples, tell me to do so ...
2
votes
1answer
47 views

LeetCode 665: Non-decreasing Array

I'm posting a solution for LeetCode's "Non-decreasing Array". If you'd like to review, please do. Thank you! Problem Given an array nums with ...
6
votes
2answers
93 views

C++17 static templated ini file reader

I've written a modern C++17 INI file reader to get access parameters values from an INI configuration file anywhere in a source file by simply included ...
9
votes
1answer
139 views

Radix Tree Implementation in c

I tried implementing a radix tree using C language in order to get the auto complete suggestions of a dictionary. What are the improvements that I can do here? Also, is there any better way of doing ...
3
votes
1answer
72 views

Simple Boolean “Latch” with state

Sometimes you need to do things when a condition changes, here is a simple class to keep track of the state of the last call and execute callbacks when the state changes. ...
3
votes
3answers
446 views

LeetCode 535: Encode and Decode TinyURL

I'm posting a solution for LeetCode's "Encode and Decode TinyURL". If you'd like to review, please do. Thank you! Problem TinyURL is a URL shortening service where you enter a URL such as <...
5
votes
1answer
57 views

Templated Fraction Class and programming design

Story I was trying to solve a hard problem from Project Euler earlier today (continued from yesterday) and I wanted to graph some things up and play a little bit with fractions. To work with fractions,...
5
votes
3answers
113 views

A FIR filter using Modern C++ features

I'm diving into "modern CPP", with wide usage of templates and containers, So I started with FIR filter. In signal processing, a finite impulse response (FIR) filter is a filter whose ...
2
votes
1answer
143 views

A custom memory allocator in c++

Recently I became interested in implementing a FORTH language interpreter. That led me to read about memory models etc. which led me to write this custom memory allocator in c++. It's very dumb as ...
5
votes
3answers
649 views

LeetCode 641: Design Circular Deque

I'm posting a solution for LeetCode's "Design Circular Deque". If you'd like to review, please do so. Thank you! Problem Design your implementation of the circular double-ended queue (deque)....
5
votes
1answer
81 views

Aho-Corasick C++17 implementation

Recently I implemented the algorithm, that can find all the patterns which may contain "?" as "any character". For example, if the text is "abracadabra" and the pattern ...
5
votes
2answers
75 views

Ray implementation

Problem Statement/Context: Represent a ray, given a origin and direction. Besides this a min_t and max_t value are defined. ...
2
votes
1answer
55 views

Concurrent dependant routines in a gui application

The idea is that, in my application I have 5 routines named long_process_1, long_process_2, ...
3
votes
1answer
91 views

Bubble Sort In C++

I'm learning modern C++ and also algorithms, and am doing some practice by coding up some simple algorithms. Also trying to use templates whenever possible as I'm quite unfamiliar with generic ...
2
votes
1answer
113 views

constexpr hash function

Here's a constexpr hash function, that will pack a string into the largest unsigned integral type available. So, what do you think? ...
3
votes
0answers
64 views

Early Stages of floating point class template in C++

I'm currently designing a class template to represent scientific notation or a floating-point number system. There are currently 4 distinct types: BIN, ...
9
votes
2answers
120 views

Abstract Memoizer

I was inspired by this answer to make this. ex[0] = 1; ex[n_] := ex[n] = ex[n - 1] + 0.5^n/n!; The double assignment in the second line is very important. This ...

1
2 3 4 5
10