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
0
votes
1answer
32 views

Internally Safe Filesystem

win_xept.hpp - a basic windows api exception ...
2
votes
0answers
21 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 ...
3
votes
0answers
42 views

LeetCode 37: Sudoku Solver

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 Write a program to solve a Sudoku puzzle by filling the empty cells....
4
votes
1answer
43 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
43 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
79 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. ...
1
vote
1answer
45 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
53 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 ...
3
votes
1answer
45 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
35 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 ...
1
vote
0answers
30 views

LeetCode 284: Peeking Iterator

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 Iterator class interface with methods: ...
0
votes
0answers
36 views

LeetCode 212: Word Search 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 2D board and a list of words from the dictionary, find all ...
2
votes
1answer
74 views

Constexpr circular queue - follow-up #1

Follow up to my question here: Constexpr circular queue . I've taken the time to fix the many problems pointed out there and am asking for any tips/corrections for the new version below. The queue ...
0
votes
1answer
31 views

LeetCode 652: Find Duplicate Subtrees

I'm posting my code for a LeetCode problem copied here. If you have time and would like to review, please do so. Thank you! Problem Given a binary tree, return all duplicate subtrees. For each kind ...
4
votes
2answers
96 views

LeetCode 1032: Stream of Characters

I'm posting my code for a LeetCode problem copied here. If you have time and would like to review, please do so. Thank you! Problem Implement the StreamChecker ...
8
votes
2answers
348 views

C++, sort integers using knowledge of entire vector

I am solving the "Sort" problem on Kattis. Mirko is a great code breaker. He knows any cipher in the world can be broken by frequency analysis. He has completely the wrong idea what ...
2
votes
1answer
53 views

LeetCode 753: Cracking the Safe

I'm posting my code for a LeetCode problem copied here. If you have time and would like to review, please do so. Thank you! Problem There is a box protected by a password. The password is a sequence ...
1
vote
2answers
80 views

LeetCode 1293: Shortest Path in a Grid with Obstacles Elimination

I'm posting my code for a LeetCode problem copied here. If you have time and would like to review, please do so. Problem Given a m * n grid, where each cell is either 0 (empty) or 1 (obstacle). In ...
1
vote
1answer
51 views

LeetCode 552: Student Attendance Record II

I'm posting my code for a LeetCode problem copied here. If you have time and would like to review, please do so. Thank you! Problem Given a positive integer n, return the number of all possible ...
1
vote
1answer
53 views

LeetCode 1320: Minimum Distance to Type a Word Using Two Fingers I

I'm posting my C++ code for LeetCode's 1320. If you have time and would like to review, please do so. Thank you! Problem You have a keyboard layout as shown above in the XY plane, where each English ...
-1
votes
1answer
53 views

LeetCode 375: Guess Number Higher or Lower II

I'm posting my C++ code for LeetCode's Guess Number Higher or Lower II. If you have time and would like to review, please do so. Problem We are playing the Guess Game. The game is as follows: I pick ...
1
vote
0answers
47 views

LeetCode 200: Number of Islands

I'm posting my C++ code for LeetCode's Number of Islands (which is a famous problem). If you have time and would like to review, please do so. Thank you! Problem Given a 2d grid map of '1's (land) ...
5
votes
1answer
82 views

LeetCode 146: LRU Cache I

I'm posting my C++ code for LeetCode's LRU Cache. If you have time and would like to review, please do so. Thank you! Problem Design and implement a data structure for Least Recently Used (LRU) cache....
4
votes
2answers
91 views

C++ multithreading logger class

I have designed a logger class to log messages to a file. It uses an independent thread to log the messages save to a queue previously using the main thread. I want to receive reviews about it. ...
1
vote
2answers
116 views

LeetCode 1044: Longest Duplicate Substring

I'm posting my C++ code for LeetCode's Longest Duplicate Substring. If you have time and would like to review, please do so. Thank you! Problem Given a string S, consider all duplicated substrings: (...
0
votes
1answer
46 views

LeetCode 1146: Snapshot Array

I'm posting my C++ code for LeetCode's Snapshot Array. If you have time and would like to review, please do so. Thank you! Problem Implement a SnapshotArray that supports the following interface: ...
0
votes
1answer
57 views

LeetCode 399: Evaluate Division

I'm posting my C++ code for LeetCode's Evaluate Division. If you have time and would like to review, please do so. Thank you! Problem Equations are given in the format A / B = k, where A and B are ...
3
votes
1answer
78 views

Constexpr circular queue

Below is a constexpr circular queue whose size is fixed. From what I tested the code seems to work exactly as expected of a queue. One advantage is how there's no dynamic allocations, so ignoring the ...
1
vote
1answer
38 views

Using vswprintf( … ) to create wchar_t* with variable argument list

I am using c++17 and wide characters. I have created a function to create a wchar_t* using a variable number of parameters ... #include <stdarg.h> // the ...
5
votes
0answers
128 views

C++17 ECS Implementation

I am (relatively) new to game programming and have been exploring creating an entity component system for my simple 2d game engine. Here is what i have so far: Entity.h #pragma once using Entity = ...
2
votes
1answer
68 views

C++: k-Nearest Neighbours with Lambdas and Priority Queues

I implemented getting the \$k\$-nearest neighbours of an origin point to a set of points in C++17. I tried to use some more modern C++ lambda techniques and was looking for feedback on use of lambdas, ...
4
votes
1answer
68 views

C++ - Logistic Regression Backpropagation with Gradient Descent

I implemented binary logistic regression for a single datapoint trained with the backpropagation algorithm to calculate derivatives for a gradient descent optimizer. I am primarily looking for ...
2
votes
1answer
55 views

C++17 enum macro with to_string operator

I created a simple enum macro that creates a to_string method for the enum. This has been done before, but my version is designed to compile quickly. From what I ...
2
votes
1answer
64 views

The intersection of two polygons in C++

I implemented the intersection of two (convex) polygons in C++. It finds the polygon in the intersection like in this image. Looking for any and all feedback. I left the logic for line intersection ...
3
votes
0answers
72 views

Generic named functions arguments in C++17

It stretches a bit the scope of C++, but hey, they gave us the 17 standard, so why not? Some snippet were found all over the internet, but the whole implementation is original. Here is an example main:...
6
votes
2answers
103 views

JSON reader based on a pushdown automata

I haven't used C++ in over a decade, so to learn modern C++ (17) I built a JSON reader based on a pushdown automata (PDA). The general idea is this: A stream is passed to ...
6
votes
1answer
126 views

Checking if a value is in a container

I quite often find myself checking whether a given value is present in a given, possibly nested, container. For example, is int val present in the nested container <...
4
votes
0answers
65 views

Integrator 2.0: A Simple Integrator in C++17

This is a follow up of A simple definite integrator class of a single variable in C++ I took most of the advice from the user: emma-x and some from user: sudo-rm-rf-slash Here is my fully revised ...
8
votes
2answers
139 views

N-Body Optimization

I've created a serial C++ code for gravitational N-Body calculation. Because I expect to have upwards of 8-71 sparse bodies (ie, where Barnes-Hut is not necessarily practical) and running for long ...
2
votes
1answer
66 views

JSON Input validator and Parser

There are probably a lot better ways to do it, but take it as a learning exercise. Basically below is the JSON InputValidation and parsing using nlohmann::json ...
0
votes
1answer
67 views

Translating Dijkstra's Algorithm from Python to C++

I'm going through the book Grokking Algorithms which is in Python but wanted to write everything in C++. Up to this point everything's been pretty straightforward translation but the code for Dijkstra'...
3
votes
2answers
120 views

A simple definite integrator class of a single variable in C++

I have written a simple Integrator class in C++17 that can perform either a definite single integration of a single variable or a definite double integration of a ...
0
votes
2answers
110 views

Union find using unordered map and templates in C++

I tried to implement union find (disjoint set data structure) algorithm in C++. There I used unordered_map data structure. Is there a better way of doing this using any other data structure. While ...
0
votes
1answer
46 views

C++ Random Tree Node

I've been trying to kind of teach myself "Modern C++" the last couple of months and I just finished this interview type problem and thought it would be a good one to get some feedback on. I not ...
1
vote
1answer
56 views

Is there a better solution to get RTTI info about a polymorphic type?

I made some code to get RTTI information of a polymorphic object, it works both if you pass it directly or a pointer to it(the pointer will get dereferenced until null or the object is found), it's ...
1
vote
0answers
15 views

Remap input matrix into matrix with narrower range

When writing image processing/computer vision algorithms, I usually use double in computations and then I have to remap the values back into ...
6
votes
3answers
674 views

Conversion into hexadecimal using C++

I want to read a vector of eight bytes, convert them into hexadecimal, store them in a std::string and finally write them into a binary file. I am looking for ...
-1
votes
1answer
25 views

A singleton class to store global parameters [closed]

Here is a class to store global parameters of any type with static methods Set() and Get() What do you like and don't like about the implementation? How would you make it to work from multiple ...
1
vote
1answer
62 views

Bubble Sort Implementation | C-ish and Modern C++

For practice purpose, I wrote bubble sort in C++ two styles: C-ish and modern C++ compliant. I would like to have your comments on any point on these implementations. ...
4
votes
1answer
79 views

Implementation of Huffman Coding

This is an implementation of Huffman Coding that works on ASCII values. I simplified main to show an example of user input to the program. I only removed handling ...

1
2 3 4 5
8