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
2answers
44 views

Tic Tac Toe in C++

Here is my two-player Tic Tac Toe game. How can I improve it? ...
1
vote
0answers
10 views

(nearly) lock-free job queue of dynamic size (multiple read/write)

After, analysing what went wrong in lock-free job queue without size restriction (multiple read/write) I've come up with another solution, here's what it does: ...
8
votes
1answer
106 views

Is my C++11 generic container a good design?

After refactors and refactors and the discovery of very common patterns on many of the classes of the software I wrote, I decided that it would be fine to have something like an arbitrary-keyed map, ...
4
votes
3answers
74 views

Parsing httpline

I have an HTTP server class (.hpp & cpp). I am trying to improve reserve data from the socket class because I have s.getline() to get HTTP call. My ...
1
vote
0answers
27 views

Follow-up: Timer utilizing std::future

The previous code (as displayed in Timer utilizing std::future) is now: ...
3
votes
0answers
54 views
+100

Sprite drawing class

I have written a very XNA spritebatch like interface for drawing sprites in OpenGL. When begin is called the vertex data buffer is mapped to a float*. The index buffer and vertex buffer are bound in ...
4
votes
3answers
292 views

Project Euler 18/67: Maximum Sum from Top to Bottom of the Triangle

This is my attempt at Project 18/67 of Project Euler. You can see the problem information, and obtain the needed txt file from here. I had some help with the split function, and help on how to use an ...
7
votes
1answer
70 views
+50

AnySetValue - a set of with multiple types of values

I would like a review for this code which is used apparently successfully in my current project. More info are available in this gist but I'm pasting here the main info: The project use C++11/14 ...
3
votes
2answers
61 views

Delegate and Observer pattern implementation for an embedded system

I'm writing a set of simple widgets for a microcontroller application. I'd like to use the observer pattern to pass around events: when a button is clicked, when a timeout occurs - there are many uses ...
8
votes
2answers
424 views

Compile time decorator pattern in C++ with templates

I'm doing some high energy physics modelling in C++. I have written code that implements class that score interactions of particles with detector material. Here is a base class: ...
4
votes
2answers
79 views

Project Euler 14: Longest Collatz Sequence

I've brute forced solve Project Euler 14. This is my first attempt at trying to solve it, by caching already solved answers, and skipping them as I run it, I am finding the program take's almost twice ...
7
votes
3answers
123 views

Parallel sieve of Eratosthenes, version 2

This question is a revision of Parallel sieve of Eratosthenes. The goal is to implement a sieve of Eratosthenes with parallel strikes out from the boolean array. I tried to fix the data races and all ...
19
votes
5answers
980 views

Parallel sieve of Eratosthenes

For the first time, I tried to use threads by myself in order to implement a parallel sieve of Eratosthenes. The trick is that each time a prime is found, a thread is spawned to eliminate all the ...
6
votes
1answer
69 views

Timer utilizing std::future

I have a Timer class executing a function in a specified interval: ...
8
votes
2answers
78 views

Container for list of ranges

I made a C++ container of an ordered list of integers, that, in order to save space, I save as ranges: For example, the list \$ \{1,2,3,5,6,7,8,9,20\} \$ is saved in memory as \$ \{(1,3), (5,9), ...
5
votes
1answer
103 views

lock-free job queue without size restriction (multiple read/write)

I've since come up with an improved version, which isn't technically lock-free, but might be as close as you can get (nearly) lock-free job queue of dynamic size (multiple read/write) code below is ...
3
votes
1answer
55 views

Lockfree ThreadPool implementation

How could this template class ThreadPool be improved? I use Boost queue to keep std::function's numbers from ...
5
votes
1answer
84 views

C++11 Logging Architecture

To create a Logging system for a larger application, I came up with the following draft. The log sinks aren't detailed yet, but the factory method for logger creation and a rough draft of the logger ...
6
votes
2answers
65 views

Generic Multiway Merge

Recently I had a problem (not in C++) that required merging a number of sorted lists of values. This is effectively the generalised case of merging together two sorted lists. However, instead of ...
5
votes
2answers
177 views

Pong game written in C++ and using SDL 2.0 (part 2)

I have previously asked here for a review of my Pong game. Since then I have implemented most of the recommendations but I'm not sure I did so correctly, the result can be found on my github. Would ...
8
votes
4answers
114 views

n-dimensional Euclidean space calculation templates

I have been working with C++11 code that uses std::vector[] to store coordinates. Most often this code uses 2D or 3D but it occurred to me that it may be generally ...
4
votes
2answers
212 views

Bit packing and unpacking

I needed a variadic function to pack and unpack bits into integer types. This is my first attempt: ...
5
votes
1answer
44 views

Infix-to-postfix parser using Dijkstra's shunting yard algorithm

I've been trying to expand my programming horizons, and have entered the world of grammars and parsing, which I'm brand new to. I have been improving a little implementation of Dijkstra's shunting ...
7
votes
1answer
96 views

Linked List reversal

Recursive version. The only interesting function: The original version: ...
5
votes
3answers
295 views

Singly-linked grocery list

For my own linked list implementation, I've decided to try something different: a linked list of groceries. The main differences between this implementation and a standard list are: more data ...
3
votes
1answer
25 views

Trigger custom implicit conversion on “copy”

Is there anything horribly wrong with creating different representation of data behind the scenes when constructing a std::vector<T> from a ...
6
votes
2answers
84 views

Container for Sets of Integers

I implemented an unordered_set like container for storing small sets of unsigned integers. It uses a trivial hash table for lookups and an unordered array for quickly iterating over small sets. I'm ...
2
votes
1answer
53 views

LRU Cache with a static variable for garbage value

I have tried to implement a Least Recently Used cache with only C++ STL containers. The main thing that I keep asking my self the static variable called ...
4
votes
2answers
66 views

Checking endianness at compile-time

I've tried to make a portable way of ensuring endian-specific code gets generated at compile time using C++11, however I only have a computer with Windows on it to test at the moment. Because of this, ...
11
votes
1answer
160 views

First program with threads

This is my very first program that using threads. I use C++11 standard threads and I run it on Linux. The program create two threads that sums all the elements in a vector together. The first created ...
7
votes
1answer
74 views

C++ template Range

From a previous question I got an answer that included some template magic (that to be blunt was mind boggling (as I could not understand it)). So I have been trying to achieve the same results ...
5
votes
2answers
786 views

Project Euler #22 - Name scores

I have written code in C++ 11 and check output with Project Euler site, and it is correct. I am not showing output, just to keep it secret, at least from my end. Please review my C++ 11 code. ...
16
votes
2answers
299 views

Dynamically call lambda based on stream input

Some context: I have code that looks like this (minor issue noted here): ...
6
votes
3answers
845 views

Project Euler #4 - Largest Palindrome Product

Problem Statement: A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made ...
3
votes
0answers
57 views

Smart pointer memory pool

Using a third-party library which utilize boost::shared_ptr for memory management. Problem is that I need to allocate very many objects and I have detected that the ...
4
votes
0answers
66 views

D3D9 leaks if any?

I am writing a D3D9 hook plugin to give back to a community that helped me learn programming. It is a community based on programming and scripting for games. The plugin is supposed to hook d3d9.dll ...
5
votes
2answers
104 views

Proposed solution to dangling pointers: a non-owning smart pointer

The lifetimes of various objects referring to each other are sometimes only known at runtime. For example, in a side scrolling shooter game, a HomingMissile ...
5
votes
2answers
176 views

Unique type ID in C++

I need to have an unique ID for any type in C++ for a variant type. Is this code reliable for getting the ID? I don't care to have same ID for same type between multiple runs. Sorry for ...
6
votes
2answers
174 views

Image processing algorithm

This is code I need to maintain. I'm trying to make this as an example for code gone bad, for C programmers going to C++. Please provide any comment you can. The original code is about 40 pages ...
7
votes
1answer
81 views

Lockless Queue Multiple-Reader Singler-Writer in C++

I wrote a lockless queue for sending small objects from a single thread to a random worker thread. Assumptions: x86/x86_64 compiled with GCC one thread may Write(), multiple threads may Read() ...
0
votes
0answers
31 views

How can I solve SICP 2.4 in C++11 [migrated]

This exercise ask for implement cons, car and cdr functions using only lambda functions. ...
7
votes
1answer
52 views

Model of Arithmetic concept for usage as Opaque typedef

I have a type that models the Arithmetic concept and use it as an opaque typedef (aka strong typedef, see Note below) in some projects. I've put the code into its own repository along some tests and ...
11
votes
3answers
123 views

Expression template to compute the Euclidean distance

I was writing some geometry-related code again and had a closer look at my function supposed to compute the Euclidean distance between two points (N-dimensional points by the way, hence the ...
11
votes
2answers
128 views

Very basic tuple implementation

I've been messing with metaprogramming and variadic templates in C++, and I came up with this very primitive implementation of a tuple: ...
12
votes
3answers
197 views

Type-safe Date class with total encapsulation

I want to teach about "encapsulation" and chose Date with Year, Month and ...
3
votes
1answer
163 views

Simple framework for Google Code Jam problems

My main concern is code style. Could you review this? ...
2
votes
2answers
99 views

Handling C-like strings in C++11

We have two C-strings and for their concatenation we need to know the size of resulting string. And we want to calculate it at compilation stage. How can I improve this solution? ...
6
votes
1answer
69 views

WinAPI code for DNS queries

This is just some test code I'm doing to learn C++11. It compiles and runs consistently. But is anything wrong that will eventually (or under slightly different circumstances) fail? Besides ...
10
votes
2answers
118 views

3D mathematical vector class

I've been working on a 3D mathematical vector class which should be as streamlined as possible for use in numerical simulations. It will be used to model 3D-physical vectors. Here, 3D-vector should ...
3
votes
1answer
61 views

Converting data when output std container via ostream_iterator

I have a strongly typed enum and std::vector of this type. ...