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)

4
votes
0answers
29 views

Compile-time printf-style 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
2answers
27 views

Strongly Typed angle measures

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 ...
5
votes
0answers
56 views

union based approach to implement variant

This implementation of discriminated union based on C++ inherent unions and inspired by this article. ...
2
votes
0answers
7 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
882 views

Array Sorting in C++

I have this simple implementation for array sorting: ...
1
vote
0answers
40 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
0answers
21 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
81 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
59 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
46 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
49 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 ...
4
votes
2answers
104 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
44 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
50 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
107 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
429 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? ...
3
votes
1answer
53 views

SICP streams in C++

To brush up on my C++ chops, I've implemented a toy version of "SICP Streams", which behave like lists with one twist: the first element of the list is always available, the rest of the list is stored ...
6
votes
2answers
551 views

Random class in C++

I've very new to C++ and have been working through a tutorial and got as far as std::rand(). I was immediately horrified and rushed out to see if I could implement ...
5
votes
3answers
105 views

Shuffle a sorted array so that left portions contains even indices and right portion contains odd indices numbers

I have been solving the following problem: Input array: \$[7,4,2,5,1,9,6]\$ Output array: \$[1,4,6,9,7,5,2]\$ I tried to do it in the following way: Sort the array. So, Input array becomes ...
6
votes
2answers
155 views

Basic C++ tone generator

I'm trying to learn C++ (with experience in C and Java, inter alia). I wrote a program to output a waveform of multiple (superimposed) tones, each varying in pitch. To execute: Compilation: ...
3
votes
1answer
55 views

An intrusive chained Hash Table

I was interested in experimenting with some intrusive versions of common data structures, so I've written this simple chained hash-table using the approach: ...
3
votes
0answers
31 views

Generic container assignment

For setters that set a member collection, I write template functions so as to accept any collection type as input: ...
5
votes
1answer
96 views

Project Euler 8 - Redux

Spurred by this question: Project Euler #8 I decided to try to solve it with as clean code as possible. Here is the problem formulation: The four adjacent digits in the 1000-digit number that ...
12
votes
1answer
135 views

Chack miy spellang pleez

For my CS2 project, I am supposed to implement a spell-checker. It is supposed to follow the following: Prompt the user for the name of the file containing the dictionary of correctly ...
1
vote
1answer
50 views

Asynchronous connect() with one function call, using C++11 lambdas and Boost.Asio

I've wanted to write a C++11 class for making IPv4 TCP connections and figured that it probably could be done with just one static function using some shared_ptr and lambda "magic". The following code ...
2
votes
0answers
35 views

Asynchronously load and unload a queue

This code is supposed to asynchronously load a queue from a generating function. ...
2
votes
0answers
59 views

SImple wrapper for OpenGL [on hold]

I am writing a simple wrapper for OpenGL for personal use. Currently I have a gl::Buffer (for VBO, EBO etc...) and it can have several types (...
11
votes
2answers
154 views

Toy virtual machine

I am a web developer, trying to have fun with C++11, so any positive/negative feedback is very welcome. This is a toy virtual machine with 3 registers and 3 commands: vm/vm.h ...
8
votes
2answers
89 views

Type-safe cartesian co-ordinates

I've recently been fiddling around with a type safe implementation of cartesian co-ordinates (and a few operations on those co-ordinates). Often it's easy to get units mixed up: is something in ...
4
votes
4answers
114 views

Extremely simple character manipulation

Given a string, this code Multiplies odd numbers Subtracts even numbers, do nothing if only one even number is found Turns uppercase letters to lowercase and vice versa I think this code is too ...
5
votes
3answers
186 views

“Set” your expectations low for this ADT

For my third assignment in CS2, I was given the following: A set is a special bag that does not allow duplicates. Specify each operation for a set of objects by stating its purpose, by ...
2
votes
0answers
62 views

Efficient compile-time directed graph

During my research in Rigid Body Dynamics, (where Contact Graphs are used to solve the contact problem) I came across the question if it is possible to define at compile time a directed graph (class) ...
4
votes
2answers
88 views

String Token Generator for ExpressGenGen

StringTokenGenerator is an interface (or abstract class) I've created to the specific task of generating a string token of a given character set. It allows ...
5
votes
1answer
149 views

Minimum number of coins - (dynamic programming solution - topdown approach)

This is a problem from topcoder tutorials Given a list of N coins, their values (V1, V2, ... , VN), and the total sum S. Find the minimum number of coins the sum of which is S (we can use as many ...
3
votes
1answer
74 views

Reading from a CSV file in C++

I wrote this code to read from a CSV text file (containing data such as 12,3,568,48,3,8 with no more than 3 digits to each number). It stores the numbers as char arrays in the vector ...
3
votes
1answer
41 views

Serialization: Step 2 YAML Parser

After this question, the next part. Coding to the same interface as the previous question: Note: Since not every system has libyaml installed, the config script tries to detect its existance and ...
14
votes
4answers
1k views

Smart as a bag of rocks

For my second project in CS2, I was given the following assignment: Implement a new ADT called a bag with receipts. The specification for the class of bag with receipts differs from a ...
2
votes
2answers
99 views

Project Euler - Smallest multiple

Here's Problem 5 - Smallest multiple 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly ...
2
votes
0answers
50 views

Directed Acyclic Graph with topological sort

I have here a class which represents a directed acyclic graph (Graph) and a vertex in the graph (Vertex). The vertices are ...
3
votes
1answer
54 views

Generalized Suffix Tree implementation

I've started to write a Generalized Suffix Tree implementation. The overall code is still in an experimental state, though I think it's mature enough to ask for a little review. I'd like to know how ...
5
votes
3answers
194 views

A partition algorithm for positive integers

I have encountered the following problem that I found very interesting to solve: Given an array of positive integers {a1, a2, ..., an} you are required to partition the array into 3 ...
3
votes
0answers
52 views

Generating all permutations of a template pack

AllPermutedPacks<Pack<Types...>>::type is to be the pack of packs consisting of all permutations of Types.... For ...
2
votes
0answers
58 views

Linked list order reverse program efficiency

Here is my function which convert linked list in the following order: Example: Inputs: 1->2->3->4->5->6->7->8->NULL and k = 3 Output: 3->2->1->6->5->4->8->7->NULL. Code: ...
2
votes
1answer
96 views

Iterator requirements for a fake container supporting C++11 range-based for

Around a year ago, I wrote this Stack Overflow answer where I suggested an idea to replace deeply nested loops with a single iterable virtual-container object that "contains" all the indices. The ...
3
votes
1answer
78 views

Generating a zoo of animals

The pattern I've come up here is for the AnimalGenerator itself, outside of the (abstract) Factory Pattern used within it. The factory classes themselves are not ...
2
votes
0answers
88 views

Simple Win32 console library (mimicking almighty SFML) - follow-up

I'm trying to mimic the SFML library to be suitable for text-based games. The library called MSLIB in GitHub here. Here is a sample of the library implementation. It prints gray square onto the ...
5
votes
1answer
335 views

C-ifying a capturing lambda

What do you think of this code: ...
6
votes
3answers
179 views

Code Generator Generator

I've created a code generator generator, which is hosted here. I need its parser portion reviewed for OOP, OOD, and C++ best practices. gengenparser.h ...
5
votes
2answers
181 views

Constructing a class from a line in a parameter file

I've got a problem where I need to parse a line in a parameter file of the form PotentialName [... variable number of parameters] I've got code which works ...