Questions tagged [c++11]

Code that is written to the 2011 version of the C++ standard, sometimes known by its pre-publication name of "C++0x". Use in conjunction with the 'c++' tag.

Filter by
Sorted by
Tagged with
11 votes
3 answers
2k views

Implementation of LRU cache

What do you think of this implementation of an LRU cache? I'm trying to migrate to modern C++, so it would be fantastic if you could give me any tips here. I've heard it's not desired to use raw ...
nullbyte's user avatar
  • 415
7 votes
2 answers
1k views

Small logging project

This is a pet project done as an exercise in C++. The following are currently out of the scope of my project but I am considering them. If you deem it important don't hesitate to comment on it. ...
PrancingCrabulon's user avatar
3 votes
1 answer
783 views

Asynchronous File System Abstraction

As a side-project, I'm trying to implement a distributed object storage. I've decided to use C++ and libuv, two technologies I had never played with, since it gave me a good reason to learn them. ...
Jazzwave06's user avatar
4 votes
1 answer
1k views

Multi-threaded Time Scheduler without polling

This is a quick shot at designing a time scheduler without polling. It is able to handle inputs which are to be executed earlier than already on the schedule. I want to improve it further, especially ...
ark1974's user avatar
  • 257
6 votes
3 answers
2k views

Simple versatile thread pool

Here's a rather hastily made thread pool to suit my requirements and even for my future projects. It is working fine and executing tasks as intended but I want to improve more and I am not sure if it'...
ark1974's user avatar
  • 257
4 votes
3 answers
2k views

CHIP-8 delay timer in C++

I'm writing a CHIP-8 emulator in C++, which has two timers. If these timers are non-zero, they are decremented by 1 at 60Hz. I'm still getting the hang of C++, so I wanted to see if I'm doing this the ...
Shubham's user avatar
  • 105
0 votes
2 answers
272 views

C++ Stack implementation with linked-list

It's proving difficult to find implementations of a Stack with linked list and Im trying to figure out if my implementation is correct/not missing anything obvious. ...
J Livengood's user avatar
3 votes
4 answers
145 views

Solving for <45 degree angles of a multi-vector system

I'm working on a problem from codechef.com. The goals are: Solve for whether or not the driver took a "sharp turn", meaning for some angle θ, θ > 45°. Test each point \$ (x_i, y_i) \$ in the system ...
Denis's user avatar
  • 33
5 votes
2 answers
5k views

Example of adding STL iterator support to custom collection class

I'm trying to create an example of a custom collection with an API meeting the requirements of STL iterator templates, as a learning experience. The collection used here, a ring buffer, is merely a ...
AnotherSmellyGeek's user avatar
3 votes
2 answers
85 views

SharedMutex concept implementation

I was curious to implement something similar to SharedMutex concept. So far only 4 methods implemented. I decided to omit try_lock, ...
triclosan's user avatar
  • 254
4 votes
1 answer
237 views

finding boundary elements in cartesian grid

I have a 2D cartesian grid (see picture below). The colorful cells are filled element. I would like to detect blue cells. Blue cells are bound elements if you scan from bottom to top and left to ...
user2090491's user avatar
6 votes
1 answer
182 views

State logger for optimization problems

I am working on a C++ project for solving a class of optimization problems. The project will be header-only, and for now, I would like to stay with C++11 (so, not fold-expressions). To be able to ...
Arda Aytekin's user avatar
7 votes
1 answer
460 views

Binary test file generator with checksum

In reading this question, it occurred to me that it would be helpful to create test files according to the file format specification. To recap, the file format is as follows: File format Note that ...
Edward's user avatar
  • 66.4k
28 votes
5 answers
5k views

C++ Vector Clone

I'm learning C++, so I decided to make a simpler clone of std::vector. Concerns: I have seen people defining methods outside of the class, and only prototyping ...
internet_user's user avatar
1 vote
2 answers
64 views

Linked lists of templated classes vs function ptr

I am designing a library for a hierarchical problem. At each stage of the hierarchy there are several "tools" at hand. If at a state N one tool succeeds, the solution is passed to the next (N+1) state....
Dima Dorezyuk's user avatar
4 votes
1 answer
1k views

Task Scheduler - LeetCode Challenge

I was attempting to solve this problem Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks.Tasks could be ...
thebenman's user avatar
  • 1,148
25 votes
4 answers
44k views

Create a C++ string using printf-style formatting

It's often convenient to use C-style printf format strings when writing C++. I often find the modifiers much simpler to use than C++ I/O manipulators, and if I'm ...
Toby Speight's user avatar
7 votes
2 answers
150 views

Class template for the encapsulation of datasheet specifications using optionals

A couple of years ago I wrote a pair of class templates to encapsulate specifications which have one or more of a minimum, typical, and/or maximum value, e.g. on a datasheet like this one for the 741 ...
Null's user avatar
  • 1,433
9 votes
2 answers
6k views

Fast pool allocator for games in C++

I have implemented the following pool allocator in C++: ...
Peter Lenkefi's user avatar
10 votes
1 answer
5k views

Stopwatch class in C++

I needed to implement a stop watch like class that will be used to measure running time of different functions by others. The final running time needs to be printed in 9h 3min 2s 23s 32ms 87us 78ns ...
alexwest's user avatar
  • 119
3 votes
2 answers
1k views

Image processing parallelization

I'm working in a big project so I decided to take just part of it which you can copy/paste and compile in your machine. You might get weird image at the end but that's fine, that's what I want. I'm ...
Ja_cpp's user avatar
  • 341
12 votes
2 answers
21k views

Progress Bar in C++

I made a simple progress bar with percentage counter for console applications in C++. Below is my code: ...
Xam's user avatar
  • 365
5 votes
1 answer
781 views

Interface for iterating a container which is a class member variable

I frequently design classes which model an object that has multiple submodules of the same type. For example, I have a class for a Printed Circuit Board (PCB) which has multiple subcircuits (I will ...
Null's user avatar
  • 1,433
3 votes
0 answers
318 views

C++ object pool using C memory pool as base

I started out with this question on Stack Overflow. I have since then gotten an official answer from the mbed developers that the MemoryPool that I was asking about only issued raw C malloc/free type ...
paulluap's user avatar
7 votes
1 answer
411 views

Performance of C++ Union-Find solution is strangely poor

Problem Summary (USACO Gold 3 February 2016) Given a rectangular coordinate plane of dimensions (A,B), there are N vertical ...
Evan Weissburg's user avatar
1 vote
1 answer
2k views

Returning containers from function - C++ [closed]

I've been trying to implement a few interfaces for processing data. And most of the time I do new of container and return a smart pointer to this container. ...
Shivendra Mishra's user avatar
1 vote
1 answer
282 views

shared_instance implementation using C++ and RAII

I created a little singleton-like class that gets deleted when there is no reference to it anymore (so its lifetime shall be somewhat predictable). I aimed to make ...
cubber's user avatar
  • 13
4 votes
1 answer
1k views

Recursive grid traveling algorithm

I'm trying to come up with a solution to a coding challenge on Kattis, where there is a 2D grid filled with x's and o's, and the goal is to figure out whether or not a given starting coordinate can ...
Archie Gertsman's user avatar
3 votes
0 answers
83 views

Determining if two packs are permutations of each other during compile-time

Often we need to find out if two tuples, or two packs in general, are the same as each other up to permutation. If there are no repeat types, then implementing ...
prestokeys's user avatar
  • 1,371
2 votes
1 answer
303 views

C++11 merge sort implementation

I've tried implementing merge sort in C++ just by looking at this Wikipedia graphic. Comparing my code to other merge sort code implementations, it doesn't look quite the same at first glance. Have I ...
Archie Gertsman's user avatar
4 votes
2 answers
966 views

Tic Tac Toe game in C++ 11

It's time for my second simple game - Tic Tac Toc. I checked it on my Linux and it's working. For compiling it I used g++ with -std=c++11. I will be glad for any advice for the future. ...
included's user avatar
  • 125
2 votes
1 answer
150 views

Competition - Qualifications - E - Matrix distance

2 types of query: add value to x y output the sum of \$value*(|a - x|+|b-y|)\$ for every pair(a, b, v). In the start you are given \$n\$ (number of querys), \$m\$ (maximal dimension for square ...
Justin Somper's user avatar
3 votes
0 answers
573 views

String conversion and stream insertion of std::ratio and std::chrono::duration

I've developed a set of functions to convert a std::ratio or std::chrono::duration to a ...
Null's user avatar
  • 1,433
3 votes
2 answers
104 views

Safe, simultaneous string replacement

I've written a function which takes as an input: a string to be modified a vector of regular expressions on which to match a vector of replacements option to ignore case in the match statements The ...
Mark's user avatar
  • 141
4 votes
3 answers
1k views

Inline visitor implementation for C++11

I've been looking at getting back into C++11 after a few years and came across the idea of implementing the 'inline' visitor pattern. The idea is that you can specify your visitor class locally in the ...
the4thamigo_uk's user avatar
4 votes
1 answer
3k views

A "zero copy" concurrent queue in C++ that supports exactly two threads; one for pushing and one for popping

One thread is limited to one action (i.e. there is a push-thread and a pop-thread and the push-thread can't pop and vice versa). By "zero copy" I mean no copying of data (mostly C++ structures) will ...
Chani's user avatar
  • 273
10 votes
3 answers
1k views

A concurrent queue that supports exactly two threads and not more. One thread is allowed to push, the other to pop

My header file implementation: ...
Chani's user avatar
  • 273
2 votes
1 answer
104 views

Segment road map data with heuristics

Backstory A little while ago I was assigned with the task of clustering some road segments using open street map data. After parsing a huge XML (maybe that should be another review) I ended up with ...
Konstantinoscs's user avatar
3 votes
2 answers
353 views

Customizing output in accordance to the input

I wanted to know if I overdid it and maybe could have kept this code simpler and cleaner. I need to execute this assignment: Write a program called multi_input.cpp that prompts the user to enter ...
C.H.'s user avatar
  • 75
2 votes
1 answer
258 views

Parse a search condition into an expression tree

I had to implement a parser according to a given grammar as part of a school project. However, only the program execution was graded and I want to know if my code adheres to best practices. I would ...
Abhilash's user avatar
  • 123
1 vote
0 answers
1k views

C++11 CLH Lock Implementation

As a hobbyist programmer I have been reading "The Art of Multiprocessor Programming" (Herlihy, Maurice; Shavit, Nir) and converting the Java spin locks into C++ - I have enjoyed this and learned a lot....
headwedge's user avatar
4 votes
1 answer
1k views

A Simple Console Based Keno/Lottery Game in C++

Earlier this week I provided this answer to the Original Poster of the question. Since I've already shown that I am not a C++ Guru, I have made the changes I suggested and I'm posting them for review. ...
pacmaninbw's user avatar
  • 23.8k
5 votes
0 answers
164 views

Delegated condition_variable against spurious wakeup

This is my attempt at dealing with spurious wakeups: A new class which replaced std::condition_variable in my code. Some questions which came to my mind are (and I ...
PhilLab's user avatar
  • 193
2 votes
3 answers
60 views

Bare bones SinglyLinkedList in C++11

I have done a bare bones implementation of a singly linked list in C++, which works: Node class ...
Melissa Stewart's user avatar
8 votes
1 answer
3k views

Observer pattern implementation in C++11

Can this observer pattern implementation be improved? Problem: User will drive a car if pressed l --> car move left c--> move middle ,r--> move right ...
rim's user avatar
  • 227
6 votes
1 answer
305 views

Find total of non-attacked positions in a Chess board - UVA 10284

The input is until EOF, give in the FEN notation. The output should be the count of non-attacked positions. My code passes in all test cases in uDebug, but it doesn't pass on the hidden cases. All ...
Emanuel Huber's user avatar
1 vote
2 answers
116 views

C++ limiting a method for an rvalue caller, an expression evaluator example

There are many ways to implement a math expressions evaluator (I focus here just on the evaluator part, without any parsing). I want to explore a certain implementation to support the following main: ...
Amir Kirsh's user avatar
4 votes
1 answer
1k views

Type-safe flag sets (bit fields) that make sense

All solutions to flag sets that I've come across are sets of integers representing individual bits (often preprocessor constants or enums). What has always bothered ...
Cris Luengo's user avatar
  • 5,573
6 votes
1 answer
270 views

Move-aware noexcept stack in C++

I'm learning C++, and move semantics and exception safety seem to be a top priority when using the language. I implemented the simplest data structure I could think of. ...
Shubham's user avatar
  • 105
6 votes
2 answers
544 views

Password Generator with random variable length with a certain range and strong random generation

I've designed a Password Generator for review. It takes the minimum length and adds 25% to produce a minimum and maximum length. My thought is to introduce a slight random variance in the length. ...
user avatar

1
6 7
8
9 10
35