Questions tagged [c++14]

C++14 is the successor to the C++11 standard, adding incremental improvements and some new language and library features.

Filter by
Sorted by
Tagged with
2
votes
1answer
55 views

Header only HTTP client library that is a wrapper around CURL

For learning purposes, I wanted to create a header-only C++ wrapper library around HTTP CURL functionality. At the moment the library only implements GET and POST, but I will add other HTTP methods ...
4
votes
1answer
62 views

Signal slot mechanism in C++14

Implementing signal slot mechanism again seems quite dumb because there are so many people already done this before but it is for learning and I intended some specific goals. I had some library in ...
3
votes
1answer
102 views

Find positive integer with a minimum number of binary 1's such that its bitwise AND with all array elements is not 0

Task You have an array of positive integers. Your task is to find an integer x such that the following are true: Bitwise AND between ...
3
votes
1answer
72 views

Matrix class with overloaded `operator[]`

I have implemented a Matrix class that allocates memory using unique_ptr. How to make it more diverse and optimized in terms of memory usage and efficiency? ...
2
votes
1answer
63 views

Subset Component Task

I've solved a problem Subset Component Problem You are given an array with n 64-bit integers: d[0],d[1],….,d[n-1]. ...
2
votes
1answer
73 views

Generic Type Trait example

I want to check that a some type has some methods: ...
5
votes
2answers
106 views

BrainF**k interpreter in C++

This question is the adaptation of this question in C++. (I'm the author of that code as well). The code: ...
3
votes
1answer
89 views

Cave Setup for Hunting the Wumpus

I am a hobbyist programmer trying to learn modern C++. My son had an assignment in his C++ class to fill in some functions that populate draw the cave in the "hunt for the wumpus" game. When I viewed ...
17
votes
5answers
5k views

Banking system in C++

I've created a program for Banking System in C++14. You are given 9 options: Open Account Close Account Show All Accounts Deposit in Account Withdraw from Account Transfer to an Account Show Balance ...
4
votes
0answers
59 views

Tic Tac Toe with different level AI

I've already created a code in python here with almost the same logic: Tic-Tac-Toe with changeable board size (Part 1) Tic-Tac-Toe with changeable board size (Part 2) Here's the code in C++. As I'm ...
2
votes
1answer
84 views

Prim's Algorithm - Minimum Spanning Tree

I have implemented Prim's Algorithm from Introduction to Algorithms. I have observed that the code is similar to Dijkstra's Algorithm, so I have used my Dijkstra's Algorithm implementation. Please ...
2
votes
0answers
28 views

A lightweight version of std::shared_ptr<T> V2

This is a lightweight version of std::shared_ptr<T> called res_ptr<T> This post is a continuation of: A lightweight ...
7
votes
2answers
291 views

A lightweight version of std::shared_ptr<T>

I wrote a simple lighter version of std::shared_ptr<T> called res_ptr<T>. ...
7
votes
1answer
80 views

An explicit cast for narrowing numeric conversions

Inspired by gsl::narrow_cast, I created my own implementation with the addition of a couple of features: a static assert on the types to ensure the cast is actually narrowing (if future changes to ...
8
votes
2answers
2k views

Implementation of A* algorithm in C++

I have implemented the A-Star path finding algorithm for a 2D grid. The function returns a list of positions of an acceptable path. main.cpp : ...
6
votes
3answers
107 views

constexpr SmallVector - std::vector like container on the stack

2 years ago I did this: SmallVector - std::vector like container on the stack now, 2 years later, I am reinventing the wheel again, this time with fully constexpr SmallVector. This time, because I ...
8
votes
3answers
926 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 ...
4
votes
1answer
101 views

Function composition in C++

My aim was to create a function which behaves like the operator . in Haskell. Here is what I made: ...
3
votes
1answer
66 views

Multithreading Ticket class to wait for parallel task completion

I've implemented a "Ticket" class which is shared as a shared_ptr between multiple threads. The program flow is like this: parallelQuery() is called to start a new query job. A shared instance of ...
4
votes
0answers
57 views

C++14 AtomicRoundRobinPool for sharing a pool of keys

The idea here is that we have some resource that is relatively very expensive to generate, but once we have a bunch of them in a pool, we can keep reusing them instead of generating new ones. "HTTP ...
8
votes
1answer
327 views

Detecting existence of a class member

I wanted to detect if I have a member in a simple POD struct and after some searching and merging some methods I found on the web I've come up with this solution: ...
2
votes
2answers
82 views

“When to take medicine” CodeChef Challenge MEDIC

I just submitted this code to solve the "When to take medicine" challenge on CodeChef: ...
6
votes
2answers
130 views

String manipulation with std::adjacent_find

For the given strings (not containing numbers), print their shortened versions, where each adjacent sequence of the same characters longer than 2, change to an expression consisting of a sign and ...
3
votes
2answers
81 views

c++14 move constructor and assignment in simple list

I’m moving from c98 to c++14 and I’m trying to figure out how to write move correctly. I just wrote the simplest list with no functionality, just testing the construction and copy behavior. I would ...
33
votes
8answers
7k views

Thread Pool C++ Implementation

I have been working on this thread pool for awhile to make it as simple to use as possible. I need some tips on improving performance, and some good ways to test its performance. I was wondering if ...
-1
votes
1answer
60 views

Determine if matrix exists or not [closed]

any help with optimizing following code to make it run faster. Tried making function inline, tried cin.TIE(NULL), tried ios_base::sync_with_stdio(false); ...
1
vote
1answer
118 views

AVL tree implementation using shared_ptr/unique_ptr

I have implemented an AVL tree using shared_ptr. I know that there is an overhead regarding using shared_ptr and instead a unique_ptr could be used. But the thing is that my node contains also a ...
13
votes
1answer
1k views

128-bit unsigned integer

This implements 128-bit unsigned integer using C++14. It works on MSVC and 32-bit architectures being complementary to the unsigned __int128 type provided by GCC ...
4
votes
0answers
46 views

Safe pointer casting : static_cast or dynamic_cast

Context: I'm using the clone pattern for creating copies of polymorphic classes which may use virtual inheritance (I hope to get rid of the latter). So when calling ...
2
votes
0answers
399 views

C++ Producer / Consumer multi threads pattern with maximum container size

I've just written a Producer / Consumer pattern templatized that should work in multi threads environment (IE producer(s) and consumer(s) in separate threads). The original use case is one producer ...
2
votes
1answer
227 views

`std::optional` under C++14 v1

This is a first version of an implementation of std::optional it is supposed to compile under C++14. The public interface of the class is complete, but there are ...
3
votes
1answer
59 views

(Follow-up) Project Euler #11 Largest Product in a Grid | Cache-optimized + sliding window (C++14)

Original code review: Project Euler #11 Largest Product in a Grid | Cache-optimized + sliding window (C++14) Source: HackerRank & ProjectEuler.net Problem: Largest Product in a Grid In the 20×...
2
votes
2answers
63 views

Project Euler #11 Largest Product in a Grid | Cache-optimized + sliding window (C++14)

Source: HackerRank & ProjectEuler.net Problem: Largest Product in a Grid In the 20×20 grid below, four numbers along a diagonal line have been marked in red. ...
4
votes
2answers
115 views

Code to find the sums of building heights

Remains You've recently stumbled upon the remains of a ruined ancient city. Luckily, you've studied enough ancient architecture to know how the buildings were laid out. The city had \$n\$ ...
0
votes
0answers
111 views

Create a simple job system using a mutex-locked task queue

Although an experienced gameplay programmer, I'm relatively new to multithreading. I've attempted an implementation of a job system that my WIP 2D engine uses: it provides "engine" and "game" workers, ...
4
votes
1answer
91 views

Builder pattern that forces all members to be initialized at compile-time [closed]

This java answer made me wonder whether it would be possible to implement the builder pattern in C++ in a way that checks at compile-time whether all necessary members of the constructed object are ...
7
votes
0answers
121 views

Quicksort template (for sorting corresponding arrays)

I needed a function for sorting two corresponding arrays. So I wrote this code to sort N corresponding arrays! The really "metaprogrammy" way to do it would be to use ...
5
votes
1answer
96 views

SplitSort — An adaptive algorithm to handle collections with few inversions

SplitSort SplitSort is a rather simple Inv-adaptive and Rem-adaptive sorting algorithm described in Splitsort — an adaptive sorting algorithm by Christos Levcopoulos and Ola Petersson. The paper ...
5
votes
2answers
105 views

Automatic RAII wrapper for concurrent access

Probably many people had to work with multithreaded applications with C++ and can understand how messy can be fine-grained locking of objects. So once in a while I came to idea of implementing some ...
3
votes
5answers
1k views

Largest binary gap

I took a task from Codility to find longest sequence of zeros in binary representation of an integer. For example, number 9 has binary representation 1001 and contains a binary gap of length 2. ...
3
votes
1answer
87 views

C++ template-based dimension-tagged type

I'm writing a small C++14 library for myself that allows me to decorate a type with dimensionality information, so that I can leverage the template/type system to avoid mistakes such as adding ...
3
votes
2answers
169 views

Simple Matrix Template Class

I wanted to make a matrix template class to see if I can learn how to use templates, work on figuring out the indexing in loops, and making an interface so the user can know if an operation will work. ...
12
votes
2answers
208 views

C++ data type to store and manipulate individual bits

The use cases I’m facing require me to have a C++ data type that can store and manipulate the state of somewhere between 400 and 500 bits. In addition it is necessary to be able to store that state ...
3
votes
1answer
2k views

HackerRank: Fraudulent activity notification

I wanted to get some constructive feedback on my solution to the Fraudulent Activity Notification problem from HackerRank: HackerLand National Bank has a simple policy for warning clients about ...
4
votes
3answers
155 views

Stable-sorting all even numbers before odd numbers in a linked list

Given a Linked List of integers, write a function to modify the linked list such that all even numbers appear before all the odd numbers in the modified linked list. Also, keep the order of even ...
3
votes
1answer
105 views

Advent of Code 2018 Day 13 - Detect mine cart collisions

This is a solution to Advent of Code Day 13 (problem specification, test input), for which I was asked to read a layout of tracks and mine carts and detect 1) where the first crash would occur and 2) ...
9
votes
2answers
7k views

Ring Buffer Implementation in C++14

A ring buffer or circular buffer is a fixed sized queue that advances head and tail pointers in a modulo manner rather than moving the data. Ring buffers are often used in embedded computer design. ...
3
votes
0answers
181 views

Designing a configurable Discrete Event Simulation class

A bit of context: I've had a fair share of programming in Java but want to refine my C++ skills with a college task. I've wanted to focus on C++11 and C++14, as they are recent but not latest, and C++...
3
votes
1answer
65 views

Bist-o-yek: a card game similar to Blackjack

Bist-o-yek (21) is a Persian card game very similar to blackjack, except it doesn't have things like double down and split. I did, though, change it a little. For example, added dealer dealing to 17. ...
3
votes
2answers
693 views

A game called Bocce played on a Cartesian grid

You may know Bocce, so you should know that I've tweaked the rules a little. Three types of balls are thrown: a red type, a blue type, and single black ball called the jack. These are all on the ...