C++11 is the successor to the C++03 standard, adding various core language changes and fixes, and an improved and expanded standard library.

learn more… | top users | synonyms (1)

5
votes
2answers
87 views

An optional<T> implementation

This is an implementation of optional<T> from C++17, it is mostly standard conforming. I'm looking for a review on efficiency, correctness and performance. ...
5
votes
0answers
45 views

Variant class that I don't think is missing anything

My goal is to learn a bit more about Generic Programming in C++. So, one of the trickiest things I've heard you can do is creating a Variant class. This took me a while and I needed to read and study ...
0
votes
1answer
54 views

C++ lazy constructor

I'm implementing a lazy constructor in C++. The goal is that for a type T, lazy<T>(args...) returns a callable object ...
0
votes
1answer
64 views

C++ simple event system

I posted an earlier version of this code a couple of days ago, so it's the updated version of the code posted here. ...
3
votes
1answer
74 views

Simple event system

This is a class which provides a simple event system mechanism: ...
0
votes
0answers
29 views

create only one instance with std::weak_ptr and enable_shared_from_this

I need to have a specific instance which is not destroyed (short-lived singleton?) I do not know at which point of my program the class needs to be instantiated nor do I know when it needs to be ...
5
votes
1answer
47 views

Lazy String splitter in C++

I created a string splitter in C++. It splits a string in a lazy fashion and makes use of forward iterators to sequentially supply the next token from the string until it runs out of tokens. ...
3
votes
1answer
54 views

Custom GUI Slider class

I want to improve my slider class as much as possible. Is this acceptable code for a slider? I've tried to comment as much as I can. If you want to find out more about the ...
4
votes
4answers
272 views

Removing duplicate characters from a string

I implemented a function removeDuplicates which takes 1 parameter, a std::string, and returns a ...
4
votes
1answer
76 views

Counting sort using STL

I'm trying to learn to use the C++ Standard Library and some of the modern C++11 features. Can someone review my counting sort algorithm below and critique my style/algorithm/use of the STL? Thank ...
4
votes
1answer
47 views

Wrapping a non-unique handle with additional information

I have a situation where I'd like to wrap up some plain C handles into a class, with a destructor and other niceties, in C++. I would like the wrapper class to have the exact same size as the handle, ...
2
votes
1answer
58 views

Parsing in between of brackets

I do parsing of the string in order to find wrapped sub-string inside brackets of the first level. a+(b+(d-g))+g+d, in this case I will need to separate ...
3
votes
2answers
69 views

Threadpool implementation in C++11

I am implementing a very primitive threadpool with C++11 using mutex and conditional variable. The class ...
2
votes
2answers
47 views

Creating a ticker thread - version 2

In this question, I asked for feedback on a class that provided my program with periodical signals. I have rewritten that class based on the feedback from the accepted answer. As this again uses a ...
2
votes
0answers
50 views

C++ Event Emitter

I needed an event bus in C++ with a few features: Possibility to add/remove both functions and member methods. Ability to remove automatically those listeners that wrap member methods of expired ...
4
votes
0answers
41 views

Delete engine for deeply nested linked structure

The background is the question at http://stackoverflow.com/questions/36634394/nested-shared-ptr-destruction-causes-stack-overflow. To summarize, for a data structure that looks like: ...
1
vote
1answer
43 views

Particle in Cell: efficient data structure handling

I am building a simulation where you have 'Agents' distributed over a rather large landscape. Because the number of Agents is small, compared to the size of the landscape, I use the PIC approach where ...
2
votes
1answer
57 views

String-casting utility functions

I wrote a small header that is supposed to take care of calling the right strtoX or or stoX function for me and doing so at ...
2
votes
1answer
79 views

Creating a ticker thread

A new question about a revised version of the code in this question, based on the advice in the accepted answer can be found here. I need to signal my program to do something every X seconds. So I ...
2
votes
0answers
79 views

Measuring the execution time of C++ code

I've written a small C++ utility that is intended for measuring the execution time of blocks of code, and I'd appreciate your feedback on it. I'm an experienced programmer, but a novice C++ ...
2
votes
2answers
69 views

A linked list with push pop append and destructor

I tried to implement a linked list that can do pop(), push(), append(), printall(), and so on, and also I tried to handle the wraparound features, and de-wrap it when check if the list is cyclic to ...
2
votes
2answers
78 views

Server socket “wrap” functions

This is a small socket library I made to avoid complicated C boilerplate code and several #includes for connecting sockets, bind, listening etc. Please note that ...
4
votes
2answers
41 views

Copy Constructor for a linked list with self-referential pointers

I came across a coding challenge that looked something like this (recreating from memory, sorry) Suppose you have the following interface for a linked list. Implement an efficient and correct ...
1
vote
2answers
42 views

Spawning futures as an alternative to multithreading

I was trying to do a sample threading program, where the spawning of thread is in a while loop. I DO NOT want to generate multiple number of threads. The while loop should keep on running, ...
3
votes
1answer
124 views

Huffman algorithm implementation in C++

Lately, I have been working on this Huffman algorithm and it is finally done, though I think it is improvable due to the fact that people say you have got to use two priority queues but I ended up ...
6
votes
1answer
121 views

Generic and accurate floating point “equality”

Like those who have come before me, I foolishly have sought to implement a generic, efficient, idiomatic, and most importantly correct method of comparing floating point numbers for equality. Like ...
1
vote
1answer
46 views

Custom C++ STL-like doubly linked-list(C++11)

This is the link list I just created. It works fine for now, but would want to know if I could make it better. list.hpp ...
3
votes
2answers
38 views

Simple Octree implementation

I've implemented a rather straightforward octree, but I don't feel that good about the coding style or some of the implementation. In particular, I use some nasty ...
3
votes
1answer
37 views

Ticket sale income calculator

I am looking for some useful feedback on my programming. I'm only three days in and trying to improve. Here is the code: ...
1
vote
1answer
61 views

Operator Oveloading: “+” and “==” for two classes

I have one class Number (base class) and two child class Fraction and ...
0
votes
1answer
58 views

NetBuffer - buffer specialized for socket read / write

This class is for fast and small footprint buffering made specially for network I/O. It is similar to so-called circular buffers, but is not circular. ...
2
votes
2answers
71 views

Checking if a single linked list is a palindrome in C++

The following is my first try at this classical interview question. It is quiet different from the solutions Gayle Laakmann provides in her book, and in another question on stackoverflow, someone ...
3
votes
0answers
38 views

C++ time types and format conversions

I wrote a small header-only C++11 header for converting between various C++ time formats. Here's the code in question: ...
2
votes
1answer
51 views

Compile-time string hash

A while back this question proposed a constexpr compile-time Sieve of Eratosthenes. It also linked to another SO question about compile-time computation of CRCs. ...
2
votes
0answers
83 views

C++ UDP server for a game

I broke my server into two classes, a general server class and a client session class. I know the code isn't documented in the header, but I am more interested in the design of the server/session ...
0
votes
1answer
81 views

Add two fractions or two integers using template class and overloading

Question: Need to create three classes. Number Fraction Integer Requirements The first class should support “display”, “==”, and “+”. "Display" : This operation displays the Number itself in ...
0
votes
1answer
88 views

Polynomial class C++11

Initial stage of implementation of the polynomial class. Essentially I need to implement the basic mathematical operations. Right now I have implemented just addition. Was wondering if this is a good ...
3
votes
1answer
50 views

Class for Value + Error Code

This is a class similar to std::pair and std::tuple inspired by Alexandresku's ...
6
votes
2answers
109 views

Weaving an array

In preparing this answer, one of the components was an algorithm to rearrange a sorted array in a particular way. To put it succinctly, here's the problem description: Given an array \$A\$ with ...
6
votes
1answer
149 views

Custom card game

I had a task to create a program to simulate a simple card game. Given an input file with number of players, the players and finally a list of cards played, I had to change the game state accordingly ...
1
vote
1answer
114 views

Dependency injection class in C++

In a recent project I started passing dependencies to classes as constructor arguments, instead of using local instances. This makes unit testing straightforward (with mock objects), but manual ...
4
votes
1answer
97 views

Recursive Breadth First Search for Knights Tour

This was written as an experiment in performance, based on another question here on CodeReview. Input into the algorithm is the number of squares on one edge of the chess board, the point of origin, ...
10
votes
3answers
265 views

C++ Vector The basics

Following on from my two previous posts. An alternative vector An Alternative Vector (Copy Assignment Operator) I have written a detailed blog about how to write a minimal vector like class. This ...
7
votes
1answer
133 views

Lock-free multi-producer multi-consumer queue

I'm looking for some feedback on my lock-free queue, based on Disruptor, mainly for any potential concurrency issues, such as where I need additional fences. It looks correct to me, and I can't seem ...
5
votes
2answers
239 views

Yet another event dispatcher in c++11

I've written an event dispatcher for a private project which task is to collect events from different threads and dispatch them in a single thread: ...
3
votes
0answers
64 views

Producer-consumer with a twist (consumer is a reader) in C++

Executive summary The twist is that the consumers do not consume, they just read. The producer makes items continuously in one of two alternating slots. Readers read from the other slot. When ...
0
votes
0answers
39 views

gGgGgG translator

This is basically a program that takes the first line of a file and makes a map using ggGgg h gGgGg s makes ggGgg equals h and gGgGg equals s. Now the rest of the file makes sentences with these. Idea ...
4
votes
2answers
60 views

Standard deviation from iterators

I want this to be similar to the STL algorithms but I don't find it elegant nor concise at all: ...
4
votes
2answers
306 views

Getting all possible letter combinations of a word

I wrote a simple algorithm for finding all possible letter combinations of a single word. I want to know if my code can be improved in any way, although I'm mostly interested in efficiency. You can ...
4
votes
1answer
68 views

Flatmap implementation

I have an implementation of flatmap for std::vector. However, I find the repetition of the inferred return type to be ugly. And, in general, I suspect that the ...