Questions tagged [c++17]

Use when the code in question assumes at least C++17 compliant compiler.

Filter by
Sorted by
Tagged with
4
votes
0answers
63 views

Tokenizer Class for handling .csv files in c++17

I am a hobbyist computer programmer trying to learn modern C++ (in this case C++17). I thought it might be an interesting challenge to write a tokenizer class for ...
3
votes
2answers
107 views

C++ Building Parse Tree with Boost and Modern C++

I am writing a parser. To build up the tree, I need to find the correct type for my node based on text from my language input file. Right now, I have a map from a string (the node name) to a factory ...
0
votes
1answer
72 views

c++ python like range function to use in for loops

It's a simple range function that works like python range and it is only a syntactic sugar for the usual for loop if we want to operate on numbers in the range from 1 to 10 (1 ... 9) we use this code ...
3
votes
4answers
116 views

static_vector: a vector with stack storage

In many cases, we want a variable-size array like std::vector, but we know an upper limit on the size. In such cases, the vector can be allocated on the stack. We ...
2
votes
1answer
49 views

A Simplistic Finite State Machine Generator

I have designed a compile time Finite State Machine generator. I have chosen to use some of the features of C++17 such as parameter pack expansion, fold expressions and lambdas to keep the complexity ...
8
votes
3answers
896 views

Count the frequency of integers in an array

I recently reviewed a question here on Code Review. The problem statement is Write a program that prompts the user to input ten values between 80 and 85 and stores them in an array. Your program ...
5
votes
1answer
116 views

A standard-conforming C++17 std::optional implementation

I took quite some time to implement a fully standard-conforming std::optional in C++17. It turns out more sophisticated than I initially thought. My code is just ...
10
votes
1answer
138 views

Static block memory allocator

I've found a little task to create a block memory pool allocator. This allocator is required to allocate memory in single fixed-sized blocks from the pool in static memory. Sizes of block and pool are ...
4
votes
1answer
121 views

C++ beginner wrote Conway's game of life using SFML

I'm an intermediate Java programmer trying to learn the basics of C++. Thus, I decided to write "Conway's game of life" as my second C++ program (I already wrote a Mandelbrot image generator). It was ...
25
votes
5answers
6k views

Japanese reading of an integer

Inspired by CtCI 16.8: Integer to English phrase in C++, I wrote a program to show the Japanese reading of an integer (positive, negative, or zero). The Japanese is written in Hepburn romanization to ...
5
votes
0answers
93 views

General algorithm to calculate sums of all subsets of a given sequence of numbers

Background A recent question Print sums of all subsets made its way to the Hot Network Questions list. The problem is easy: Print sums of all subsets of a given set Given an array of ...
3
votes
1answer
90 views

Performance improvements in C++ channel transformer code

The simple program reads in some channel data and parameters from text files and should be able to generically transform the data using natural math syntax. I am primarily concerned about performance....
4
votes
1answer
45 views

Single-thread Task Scheduler with type erasure and allocator-aware

I made a task scheduler to practice allocators and type erasure. With my project, you can delay execution of any callable (functions (using std::ref), lambdas...) ...
4
votes
0answers
70 views

Type & Thread-safe Logger Implementation

So I had previously posted this question and asked for some feedback regarding my (now) header-only logging system and figured it would be a good time to go back to the changes I made it and see if it ...
3
votes
1answer
54 views

Prime number sieve using ranges::view::ints

I wrote a simple prime number generator in C++17. The function generate_primes(max) generates all prime numbers up to max. I ...
3
votes
2answers
58 views

A polymorphic union in C++

Sometimes I use std::unique_ptr<BaseClass> when all I really want is polymorphism. For fun, I made this container that skips the heap allocation. The ...
3
votes
1answer
64 views

std::function alternative with no dependencies

An alternative to std::function for when compile time is more important than runtime performance. Doesn't pull in any headers. (...
2
votes
0answers
48 views

A tiny library implementing the Elm Architecture in C++

Elm is a pure functional language for the front-end. It enforces an architecture that allows programs to stay pure in an event-based setting. This simple header-only library implements a variant of ...
3
votes
3answers
114 views

String Zigzag Conversion

Overview The string 0123456789 is written in a zigzag pattern (following the path going all the way down, then diagonally moving towards the top right) using a ...
6
votes
2answers
139 views

115 line brainfuck interpreter written in C++

This is a simple brainfuck interpreter I've written in C++. It takes a path to a brainfuck source file as a command line argument. The program uses a tape size of 30000 and cell size of one byte. ...
4
votes
1answer
65 views

A Versatile Algebraic Variable Class Template with full operator support

I've been working on this concept for the past few days where a variable_t is of any type T; assuming that it is at least ...
5
votes
1answer
89 views

Sodoku solver with arrays of bitsets

I wrote a quick sodoku solver as an exercise and am curious how to make it faster. Parsing and printing is largely irrelevant only there for readability. How can I make the code cleaner and faster? <...
6
votes
0answers
39 views

Concurrent Queue Adapter

There's lots of code out there for basic adapters of std::deque to provide a thread-safe queue. I've adopted that, but wanted to provide a relatively full analog to ...
9
votes
1answer
39 views

Mixed-width operations for std::bitset

When I was looking to use std::bitset instead of GCC's __uint128 in my RDS error-corrector, I found that it was hard to use, ...
27
votes
5answers
4k views

C++ logging library

I am creating a logging library in C++, and I wanted your opinion on code quality and performance within some methods. You may ask why yet another logger - the answer is simple. This logging library ...
7
votes
1answer
120 views

A C++17 std::function implementation

Some time ago I implemented dynamic_array and posted it on Code Review. It used std::function internally for type erasure. This ...
5
votes
0answers
234 views

Yet another multi-producer single consumer queue in C++17

Here's an implementation of a multi-producer single consumer queue that I wanted to use with tasks such as logging from multiple points in a program to a single sink. The implementation is inspired ...
4
votes
0answers
64 views

C++17 implementation of std::invoke

C++17 introduces std::invoke which calls the exposition-only INVOKE. Here is an implementation. This isn't a large amount of ...
3
votes
0answers
91 views

A fixed-size dynamic array

Background I implemented the historic std::dynarray according to the specification under the name dynamic_array in C++17. ...
8
votes
2answers
526 views

C++17 thread pool

I've implemented a thread pool in C++17. This is not backwards compatible with C++14, due to the usage of std::invoke_result, which is new to C++17. The focus of ...
3
votes
0answers
48 views

Graph Search in C++17

Overview I am constructing a Graph with randomly generated nodes called Positions. The Graph has a width and a height and is represented using an adjacency list <...
6
votes
1answer
144 views

OOP demonstration in C++17 using a Pokémon

I want to showcase with as minimal code as possible the basic Object-oriented programming (OOP) principles of Polymorphism, Inheritance, and Encapsulation. I know there are many more principles than ...
5
votes
1answer
277 views

C++ Implementation of Linked List

I have been trying to teach myself C++ recently and would like to have some general feedback and comments on how to improve my code so far. Furthermore, since I am more experienced with other (garbage-...
4
votes
0answers
100 views

Simple ring/circular buffer c++ class V4

As the title states, this is my 4th revision of this class. Here is the previous post if needed. I'm hoping someone experienced with things such as noexcept, ...
9
votes
3answers
1k views

Binary Search in C++17

Question Any way I can optimize this further with C++11 or C++17 features? Would also like feedback on my variable naming, memory management, edge case handling (in this someone calling my function ...
4
votes
1answer
110 views

Simple ring/circular buffer c++ class V3

The Original Post (v2) As stated in the previous post, i'm looking for feedback on the updated version of the code posted. A few things specifically I'm looking for feedback on, are: I switched to ...
2
votes
2answers
81 views

Simple ring/circular buffer c++ class V2

The Original Post (v1) I'm looking for feedback on the updated version of the code posted at the link above. ...
9
votes
2answers
254 views

Arkanoid Console Game

After doing the Snake Game I decided to go more crazy and made an Arkanoid Clone: Currently this only runs on Windows. I tested it under MSVC2017 with Windows 7. If you want to get it to run on Linux ...
2
votes
0answers
54 views

SQL (ODBC) bind to C++ classes row-wise

I created it to map buffers returned by ODBC driver to my objects. It works quite nice but, I have some questions marked (B), (C)...
3
votes
1answer
72 views

Multi-dimensional dimension type

Introduction When implementing a one-dimensional array, you need to keep track of the size. Such quantities are best represented by std::size_t: ...
5
votes
1answer
49 views

Emulating Virtual Registers Part 3

Forward This is a continuation of my work in progress and the last iteration that I posted can be found here. I have designed a compact class template that uses SFINAE with constructor delegation to ...
6
votes
1answer
121 views

C++17 Either implementation for error handling [closed]

This is a C++17 Either implementation for error handling. First intent is I want to improve myself. Second intent is I want to create a more expressive solution than variant for exception free error ...
8
votes
2answers
244 views

C++ Snake game using Qt-framework

I made a QT version of "Snake console game in C++" using Qt Creator 4.9.0 on Windows 7: I would like to know what can be improved, focused on the QT stuff since im new to it. I seperated the program ...
4
votes
1answer
78 views

C++17 allocator_traits implementation

Inspired by my earlier question C++17 pointer_traits implementation, I re-implemented allocator_traits under the name ...
7
votes
0answers
52 views

C++17 pointer_traits implementation

pointer_traits is a lightweight trait that provides a uniform interface to builtin pointers and user-defined fancy pointers. That said, things like ...
3
votes
1answer
111 views

Creating a cache-friendly component system

I am fairly new to c++ and am attempting to write a simple 2D game engine. I am currently working on my object model: a pure component system, similar to that described in the Data Locality chapter in ...
6
votes
1answer
175 views

Snake console game in C++

I reviewed this question to a snake game console implementation: My first C++ game (snake console game) I enjoyed refactoring this code and presenting a solution using more C++ features/classes. I ...
8
votes
3answers
351 views

C++ lock free, single producer, single consumer queue

Assumptions for use: push() will only ever be called by a single thread. pop() will only ever be called by a single thread. Requirements: push() needs to be as fast as possible. Requirements are ...
4
votes
2answers
415 views

How to set an interval to std::map [closed]

This code belongs to a contest. I tried to apply the range of data to a std::map. The contest system however warns me that the implementation of the assign function ...
3
votes
2answers
131 views

Merge Sort C++11 C++17

Question Any way I can optimize this further using new C++11 or C++17 features? Would also like feedback on my variable naming, memory management, and style (notice my placement of ...