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
49 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
378 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
42 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
75 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
52 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
569 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
67 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
72 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
48 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
87 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
82 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
60 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
116 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 ...
3
votes
1answer
69 views

LeetCode 310: Minimum Height Trees

Posting my code for a LeetCode problem, if you'd like to review, please do so. Thank you for your time! Problem For an undirected graph with tree characteristics, we can choose any node as the root. ...
3
votes
1answer
94 views

LZW Compression Library

I wrote a library that implements LZW compression and decompression. A goal of this project was to help me acquaint myself with modern C++ development practices (I primarily come from a Java ...
1
vote
1answer
52 views

LeetCode 1206: Design Skiplist

I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you for your time! Problem Design a Skiplist without using any built-in libraries. A Skiplist is a data ...
5
votes
2answers
140 views

Guess the Number In C++

Mind that this is my first actual program in C++ and I tried to prepare for any possible input. Also the reason I included static_cast<void>(generator(range))...
2
votes
0answers
32 views

Getting around gsl/span's restriction on temporaries

The goal of this code is to allow temporary RHS variables to be used in a span, specifically as an argument to a function, to be deleted later after the function completes, allowing the passing of ...
11
votes
1answer
913 views

Customization of memory class C++

I have implemented a customized memory allocation class template for an assignment. Codes are commented; Hopefully it's clear. I would love to know if there is any way to make the code more optimized. ...
3
votes
0answers
57 views

LeetCode 1263: Minimum Moves to Move a Box to Their Target Location ||

I'm posting a follow-up code on this question, which seems to be a version of Sokoban. If you'd like to review, please do so. Thank you for your time! Problem Storekeeper is a game in which the ...
10
votes
2answers
566 views

Simple parser using Flex and C++

This is an alternative parser based on the specifications from this question. Briefly stated, the input file is a text file which has at least 33 fields separated by semicolons. If the fourth field ...
2
votes
1answer
67 views

LeetCode 1263: Minimum Moves to Move a Box to Their Target Location

I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you for your time! Problem Storekeeper is a game in which the player pushes boxes around in a warehouse trying ...
5
votes
1answer
78 views

LeetCode 928: Minimize Malware Spread II

I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you for your time! Problem (This problem is the same as Minimize Malware Spread, with the differences bolded.) ...
1
vote
1answer
41 views

LeetCode 839: Similar String Groups

I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you for your time! Problem Two strings X and Y are similar if we can swap two letters (in different positions) ...
3
votes
1answer
110 views

LeetCode 483: Smallest Good Base

I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you for your time! Problem For an integer n, we call k>=2 a good base of n, if all digits of n base k are 1....
1
vote
2answers
49 views

LeetCode 124: Binary Tree Maximum Path Sum

I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you for your time! Problem Given a non-empty binary tree, find the maximum path sum. For this problem, a path ...
2
votes
1answer
62 views

LeetCode 1453: Maximum Number of Darts Inside of a Circular Dartboard

I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you for your time! Problem You have a very large square wall and a circular dartboard placed on the wall. You ...
1
vote
1answer
52 views

LeetCode 906: Super Palindromes

I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you for your time! Problem Let's say a positive integer is a superpalindrome if it is a palindrome, and it is ...
6
votes
1answer
598 views

Implementing a very simple memory block for quick allocation and memory alignment. C++

This is programmed in Visual Studio 2019 with the C++17 feature set. The intent with this code is to be able to create memory blocks of the specified alignment and size, so as to have contiguous cache-...
3
votes
2answers
93 views

52-Line Logging System

I wanted to make an extremely light-weight logging system. What are your thoughts on this and what can be done to improve it? First, the usage: ...
4
votes
2answers
41 views

Composable monadic std::function using std::optional

I've implemented a simple Maybe type around std::function that implements function composition where any function in the ...
1
vote
2answers
96 views

LeetCode 913: Cat and Mouse

I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you for your time! Problem A game on an undirected graph is played by two players, Mouse and Cat, who ...
1
vote
1answer
124 views

LeetCode 952: Largest Component Size by Common Factor

I'm posting my code for a LeetCode problem copied here. If you would like to review, please do so. Thank you for your time! Problem Given a non-empty array of unique positive integers A, consider the ...
0
votes
2answers
82 views

LeetCode 126: Word Ladder II

I'm posting my code for a LeetCode problem copied here. If you would like to review, please do so. Thank you for your time! Problem Given two words (begin and <...
1
vote
1answer
44 views

LeetCode 149: Max Points on a Line

I'm posting my code for a LeetCode problem copied here. If you would like to review, please do so. Thank you for your time! Problem Given n points on a 2D plane, ...
2
votes
1answer
66 views

LeetCode 1463: Cherry Pickup II

I'm posting my code for a LeetCode problem copied here. If you would like to review, please do so. Thank you for your time! Problem Given a rows x cols matrix grid ...
3
votes
0answers
62 views

STL compatible Binary Search Tree with unique_ptr (unit test included)

I am trying to create a Binary Search Tree, which has STL support (iterators etc.). This is my first attempt. Everything is unit tested using Catch2. Could you please review what I missed and what I ...
1
vote
1answer
71 views

Internally Safe Filesystem

win_xept.hpp - a basic windows api exception ...
3
votes
1answer
42 views

riff chunk - utility class for working with RIFF chunks

For a personal project (reading media file metadata) I created a small/fast utility class for working with RIFF chunks. Support: defining chunks by 32 bit integral value defining chunks using 4 ASCII ...
4
votes
1answer
116 views

LeetCode 37: Sudoku Solver

I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you for your time! Problem Write a program to solve a Sudoku puzzle by filling the empty cells. A sudoku ...
4
votes
1answer
76 views

LeetCode 924: Minimize Malware Spread

I'm posting my code for a LeetCode problem copied here. If you would like to review, please do so. Thank you for your time! Problem In a network of nodes, each node i is directly connected to another ...
2
votes
1answer
51 views

Find sequence to a target number using restricted set of primitive operations

Given an integer 𝑛, compute the minimum number of operations(+1, x2, x3) needed to obtain the number 𝑛 starting from the number 1. I did this using this code: ...
2
votes
2answers
107 views

LeetCode 273: Integer to English Words

I'm posting my code for a LeetCode problem copied here. If you would like to review, please do so. Thank you for your time! Problem Convert a non-negative integer to its English words representation. ...
2
votes
1answer
55 views

LeetCode 639: Decode Ways II

I'm posting my code for a LeetCode problem copied here. If you would like to review, please do so. Thank you for your time! Problem A message containing letters from A-Z is being encoded to numbers ...
2
votes
2answers
94 views

LeetCode 862: Shortest Subarray with Sum at Least K

I'm posting my code for a LeetCode problem copied here. If you would like to review, please do so. Thank you for your time! Problem Return the length of the shortest, non-empty, contiguous subarray ...
4
votes
1answer
86 views

LeetCode 894: All Possible Full Binary Trees

I'm posting my code for a LeetCode problem copied here. If you would like to review, please do so. Thank you for your time! Problem A full binary tree is a binary tree where each node has exactly 0 ...
1
vote
1answer
57 views

LeetCode 410: Split Array Largest Sum

I'm posting my code for a LeetCode problem copied here. If you would like to review, please do so. Thank you for your time! Problem Given an array which consists of non-negative integers and an ...
5
votes
1answer
86 views

LeetCode 284: Peeking Iterator

I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you for your time! Problem Given an Iterator class interface with methods: ...
1
vote
1answer
78 views

LeetCode 212: Word Search II

I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you for your time! Problem Given a 2D board and a list of words from the dictionary, find all words in the ...

1
2 3 4 5
9