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)

3
votes
0answers
28 views

ASCII graphic waveform generator

Working on some documentation lately, I had a need to convert a number of asynchronous serial waveforms into ASCII graphics characters. Rather than draw them by hand, I decided to write a program to ...
1
vote
1answer
35 views

C++11 Thread Pool

I've been using a thread pool that I wrote using Windows threads for a while and I've decided to update it to use std::threads. I'm looking for some feedback on ...
1
vote
0answers
29 views

Select type stringification for ostream output using C++11 template mess

The objective is to select which function is used to represent a type as a string for output on ostreams. The code here allows to explicitly choose a function, or to fallback on a java style ...
0
votes
1answer
51 views

C++ class template for notification management

Recently, I found myself frequently writing notification managing facilities. That is, one can register as a receiver by providing a callback, and another can send a notification to all registrants by ...
5
votes
0answers
56 views

C++ concurrency library

I started a C++11 library of concurrency primitives in order to study and compare their performance; provide high-quality implementation of those to use in my projects. Its main target platform is ...
3
votes
2answers
128 views

Implementing a Yearmonth class

Recently I wrote a program that was required to handle year and month data and so I wrote this class to encapsulate that handling. What I needed was a way to initialize the ...
2
votes
1answer
52 views

XML parsing program in C++

This is my code which works and compiles but I feel it may be non-optimal, especially the tag mapping and use of the if command. It reads two .xml files and finds ...
3
votes
1answer
45 views

C++ port of my Ruby narcotic solitaire simulator

Having undergone a little "rediscovery" of C++, I decided to port my Ruby narcotic solitaire simulator program to it. My goal here is efficiency. This program is already about 5 times faster than the ...
2
votes
1answer
27 views

C++ class for capturing broadcast window messages

In the Windows operating system, some system events are notified via broadcast window messages. DBT_DEVICEARRIVAL and ...
0
votes
1answer
64 views

Unit test failing on case sensitive string comparison [closed]

I'm currently writing some unit tests for my own BinarySearchTree class with Microsoft's unit testing framework in VS2013. The VS solution contains the project for ...
2
votes
1answer
30 views

Different return types with same function

I'm implementing my own time unit class. This class provides a function for fetching a specific time value (milliseconds, seconds etc.). In order to prevent defining several get() functions for each ...
8
votes
4answers
780 views

Simple comparison of sorting algorithms in C++

I know this has been done a million times before, but this is my implementation of bubble-sort, insertion-sort, merge-sort, heap-sort, and quicksort. Any feedback on how to make it better would be ...
1
vote
1answer
47 views

Track execution time using std::chrono facilities and print the execution time in a comprehensible way

The class below will be used to track the execution time of various operations. There is no need to dip into C libraries to get formatted output then. Output would be something like this: 10 ...
3
votes
1answer
96 views

Finding the top k elements from a file

I was writing a program in C++11 to find top k words from a file. I think priority queues will give the optimal solution so I implemented using that. The code works and compiles. Could anyone please ...
1
vote
3answers
71 views

Adjacency matrix on undirected graph

Please review my Adjacency Matrix class. Since I use std::vector to create the matrix, I would like to store as many nodes as possible. Is it OK to use ...
2
votes
1answer
57 views

Fixed size double-ended queue

I require hundreds of equal, small sized buffers in my current project. The bulk of the computation in the program operates on data stored directly in those containers, so high performance is ...
6
votes
1answer
96 views

Simple LZW compression algorithm

It's a simple version of LZW compression algorithm with 12 bit codes. I want to know what's good and what's bad about this code. Be as picky as you like. ...
2
votes
1answer
55 views

Compute weighted average around a point in a matrix quickly

I have a short snippet of code that simply computes a weighted average for surrounding elements in a square matrix. The actual implementation that I'm working on is not an average (more complex ...
3
votes
3answers
61 views

Natural merge sort

Note: the next iteration at Natural merge sort - follow-up I have compiled natural merge sort algorithm from Java to C++. Natural merge sort sacrifices at most \$2N\$ amount of work in order to ...
2
votes
0answers
26 views

Entity Component System in C++11

An Entity Component System works by grouping various components around a central ID, aka Entity. Entities and Components do not have any code, they are simply POD containers. Rather, the code lies in ...
3
votes
3answers
119 views

File IO class in C++

For fun, I've made a practical file IO class in C++ with the purpose of being light and quick, and extendable for custom parsers. Here is the code: parser.h ...
4
votes
2answers
81 views

Counting Colors in Conway's Game of Life

I have a basic version of CGoL running with pdCurses. My goal was to have each newly spawned cell take on the dominant color of their neighbors (if a spawned cell is mostly surrounded by red, make it ...
2
votes
1answer
58 views

Game engine ObjectFactory class

I've developed as part of a game engine a template class for a factory which manages objects of one specific type. The factory handles initialization, destruction, and accessing previously created ...
2
votes
2answers
89 views

Find non duplicate Triangle Triplets from a list of given numbers- version 3

It is a continuation of my previous question: Find non duplicateTriangle Triplets from a list of given numbers After I realized triplet structure using less space than ...
2
votes
1answer
90 views

Find non duplicateTriangle Triplets from a list of given numbers

I implemented an O(N^2) algorithmic solution but not sure it is better than my previous implementation Find Triangle Triplets from a list of given numbers in case of performance. I adapted almost ...
4
votes
1answer
111 views

Find Triangle Triplets from a list of given numbers

If a triplet of segments A, B and C are triangle triplets if and only if A + B > C A + C > B B + C > A Is there a better implementation for this problem? ...
7
votes
1answer
161 views

Is this implementation of Quicksort good?

For fun, I decided to implement the quickest Quicksort I could. This is what I came up with. How can I make it better? I know that it's slower for sorted and already reversed lists (through testing), ...
7
votes
1answer
99 views

Finding Pattern score

You are given 3 strings: text, pre_text and post_text. Let L be a substring of text. For each substring L of text, we define pattern_score as follows: ...
5
votes
3answers
219 views

Find common characters

Given two strings, find the common characters. Is there better implementation for this problem? ...
3
votes
0answers
66 views

Applying the copy-swap idiom to humans and employees

I came across this post which explains the copy and swap idiom. However I could not find this idiom applied to classes that have base classes. Following is my attempt of a copy-swap idiom applied to ...
4
votes
1answer
64 views

Flexible generic event system that binds to objects

I have been trying to create an event queue system using SDL. I've been trying to use this for Pong. The game is not even finished yet, but I stopped work to examine how my event system is organized. ...
4
votes
1answer
112 views

C++ custom memory allocator

I'm working on a C++ custom memory allocator, that would be kind of a replacement for the C flexible array syntax, you know, the stuff like that: ...
7
votes
1answer
75 views

Implementation of a new kind of smart pointer in C++

I'm tempted to write a new kind of smart pointer which, I believe, is less intrusive than boost::intrusive_ptr and has the same memory footprint. The code for the ...
9
votes
1answer
78 views

Compile-time printf-style format checking

Inspired by this open ticket on Boost, this seeks to complete the work there. Given a printf-style format string and associated arguments, a static_assert is ...
1
vote
2answers
57 views

Strongly-typed angle measures in radians and degrees

I often work with angles when writing code for 3D rendering and such. Personally, I prefer to measure angles in degrees, but many APIs (including the Standard Library) measure angles in radians. So ...
10
votes
1answer
169 views

union based approach to implement variant

This implementation of discriminated union based on C++ inherent unions and inspired by this and this articles. ...
3
votes
0answers
16 views

AdjacentElementsIteratorAdaptor for Random Access Iterators

Inspired by this comment I decided to implement an iterator adaptor that takes another iterator and returns each element and a given number of its neighbors. The final solution should be applicable ...
4
votes
3answers
956 views

Array Sorting in C++

I have this simple implementation for array sorting: ...
1
vote
0answers
48 views

Dynamic Programming with large arrays

Last week we have finished our program which applies a local search. At this moment the program needs more than three hours for the largest instances. The three hours are too long and we try to ...
0
votes
1answer
83 views

Real time head segmentation using OpenCV

I am using OpenCV 2.410 to implement a project. My project allows to segment head from video sequence which get from camera. First, I detect the head region and then apply segmentation method for that ...
4
votes
1answer
100 views

Compile-time printf format checking

Compile time checking of printf-like format strings Inspired by this open ticket on boost, this seeks to complete the work there Given a printf-style format string and associated arguments, a ...
1
vote
0answers
70 views

Create pairs from a set of numbers

Problem here is to list all pairs from a set of integers. We need 2 versions. In the first program, the order matters — pairs (a,b) and (b,a) are considered distinct. In the second program, (a,b) and ...
3
votes
0answers
69 views

Lock-free ringbuffer with multiple readers in C++11

Basic Info I needed a lock-free ringbuffer with multiple readers (but one writer). However, I did not want the writer to check all readers every time in order to prevent an overrun. Thus, I decided ...
3
votes
0answers
76 views

Timeout watchdog using a standby thread

The simple but generic timeout class to be used watching for network connections, user input, filesystem events, and is intended to have a very simple interface specific to only our use cases (i.e. no ...
5
votes
2answers
126 views

Minimal webserver in C++, second revision

First revision: Minimal webserver in C++ Here's my test question for C++ programmer job: Servers only static content, no cgi Single process, multithreaded 1000 concurrent request at least Valid ...
3
votes
1answer
58 views

Graph Adjacency List

Spent some time implementing a graph as an adjacency list. Looking for suggestions on how to improve this implementation. ...
3
votes
1answer
54 views

Searching for a substring in a ring queue

I am implementing a function which searches through a ring queue for a given substring. The function returns true if the substring is found, otherwise false. There is a cell containing null between ...
15
votes
3answers
2k views

Brainfuck on-the-fly interpreter in C++

I was bored yesterday morning, so I wrote a brainfuck interpreter. I know there are a lot, but this one is different. Why? Because it evaluates brainfuck code on the fly, reading from the input file, ...
7
votes
2answers
146 views

Spinlock for C++ kernel (with x86 ASM)

This is some prototype code for a spin-lock for my toy operating system. Bear in mind this means there are no standard library routines to fall back on. It's also for C++11 compilation and will only ...
5
votes
2answers
511 views

A multi-threaded Producer Consumer with C++11

I am trying to learn concurrent programming in C++11. I tried to write code for a classic producer consumer concurrency problem. Would you please review and make any comments about it? ...