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
1answer
33 views

Iterable enum class in C++11

For a small project I'm working on, I've been looking for an iterable enum-like class in C++, since neither C-style nor scoped ...
3
votes
1answer
37 views

Perfect-forwarding while implementing emplace

I am trying to write a class similar to std::set, and I was wondering if I handled the perfect forwarding right in implementing the ...
5
votes
3answers
86 views

Simplifying logic of overlapping predicates

I have 3 simple predicates and 3 simple actions to be taken based on those predicates. In my actual application they are not based on integer arithmetic, and in fact are rather expensive to compute ...
8
votes
3answers
52 views

Validation/error handling of user input values

This is a tiny learning program that lead to an interesting question: how can I best/most elegantly handle user entered numbers? This method works, fails cleanly, and reads well. It doesn't apply to ...
9
votes
3answers
291 views

Implementation of binary min-heap data structure

What do you think is wrong with this code, and how can it be improved? What corner case have I overlooked, if any? Note: I do not want to use any STL features here, but I'm okay with anything else ...
5
votes
0answers
61 views

Interface-based polymorphic collection

Here is a small C++11 utility collection to store any object that satisfies a given interface. Only the basic concepts are provided, I did not try to create a full collection: ...
4
votes
1answer
48 views

Better way to un-define a set of defines based on version numbers in C++?

In a header I have something like: ...
6
votes
3answers
189 views

Inner product of random floats written to file

My goals are to make this code: faster more idiomatic C++ What the code does: take an integer command-line argument N make a vector of ...
11
votes
2answers
96 views

Encapsulated text-based RPG using a randomized combat system

For my rags-to-riches submission, I've decided to improve this code: Text-based RPG game using classes However, I've decided to start off with something different. The original code is more ...
5
votes
1answer
84 views

Simple parsing for string formatting (version 2)

This is my second attempt (version 1) at writing a string formatting utility which uses parsing. This time I more explicitly designed it as a finite state machine. I have very little experience with ...
3
votes
0answers
47 views

Debug log wrapper

Please review code correctness, best practices, design and code formatting. I will be adding functionality and most likely additional refactoring, however a stringent review would be welcome before I ...
2
votes
0answers
16 views

How can I expand this C++11 event system to handle multiple arguments? [migrated]

I've written a simple subscriber event system taking advantage of std::function. It works great! (and I can do some big enhancements later with thread-pooling for ...
4
votes
1answer
80 views

Simple parsing for string formatting

Recently I submitted some string formatting and printing code (found here) that I wrote as an small exercise. It was implemented naively using string replacement. This time around I wanted to actually ...
7
votes
3answers
116 views

Enterprise FizzBuzz in C++11

I've decided to write a C++ FizzBuzz with the focus on some new C++11 features, ridiculous optimizations and unit-testability. Are there improvement possibilities in those regards? ...
12
votes
1answer
258 views

Yet another FizzBuzz

Since today is apparently a good day for...unlikely FizzBuzz implementations, I decided to contribute another, this one in C++: ...
13
votes
6answers
561 views

Classes for sentence-like readability

If we have a set of classes or structs such as: ...
2
votes
1answer
43 views

Best way of assigning an array of different (but convertible) type to concurrency::array in C++AMP

I am creating a vector class which can be manipulated on the GPU and I am using C++AMP for the GPU accelerated code. I am wondering the most efficient way of assigning elements of a different type ...
1
vote
1answer
51 views

Will this act like a ThreadPool? [closed]

I know that until the n threads will not complete their jobs, the new jobs will not be assigned, but will this code be thread-safe and execute ...
4
votes
1answer
56 views

Builder/named argument/fluent interface pattern with unique_ptr

I'm trying to figure out the cleanest way to implement a fluent interface with unique_ptr and other "modern" C++ language constructs. Here's my first attempt: ...
2
votes
1answer
36 views

PPL and AMP performing worse than sequential transform

I wrote the following short test code to test the performance of C++AMP and the PPL libraries against the sequential STL implementation of std::transform. To my ...
6
votes
2answers
242 views

Binary Search Tree implementation using templates

I wrote this implementation using templates. It works fine and as expected. Just want to know if this can be improved. I have some specific questions too at the end. Please feel free to critique to ...
9
votes
1answer
145 views

Did I implement my string formatting code correctly?

As a small exercise I have written some string formatting and printing functions in C++11. I would like a bit of code review, not so much on the merits of using this over something like ...
6
votes
2answers
78 views

Time Limit Exceeded with Segment Tree data structure

I am trying to solve this problem Chef Ceil has some matchsticks in his kitchen. Detail of matchsticks: There are N matchsticks in total. They are numbered from to 0 to N-1 inclusive. ...
5
votes
3answers
129 views

Linked list with iterators

This is my second linked list implementation for review. I rewritten pretty much all of this and have added iterators, sentinels and The Rule of Five. Please let me know what's wrong with it; I am ...
5
votes
3answers
133 views

Reading and writing binary data in C++

I have written a small container class which groups a 3D position, a normal vector and a texture coordinate into one object. It uses the glm library for the actual data types (vec2 and vec3). This ...
14
votes
2answers
227 views

Sudoku solver in C++

Some time ago, this question was posed, asking for help in optimizing a Sudoku solver implemented in C++. I decided to reimplement the code using C++11, but without guessing. That is, this Sudoku ...
11
votes
3answers
545 views

Linked list implementation correctness

I've started learning C++ and I wanted to ask you to take a look at my linked list implementation and give comments what's wrong with. It compiles and runs fine, but I am curious about const ...
4
votes
0answers
95 views

Is this pass-by-reference of a shared_ptr correct?

I'm writing a scene graph library in C++ and I'm currently designing the parent-child relations. I decided to use shared pointers for parent-to-child-relations and weak pointers for child-to-parent ...
5
votes
1answer
53 views

Generic Graph Library Part 2 : Algorithms

(This is a follow on to this question). Having given an implementation for some of the graph structures, here is a portion of the algorithms that are defined to work over them: graph_degree.hpp ...
9
votes
1answer
83 views

Generic Graph Library

I've been working on a generic graph library for a while now, in a bit of an off and on fashion. I realise that boost::graph exists, but it is a complex library ...
4
votes
2answers
240 views

Creating a cache manager

I am purely new to C++ memory management. Am I on the right path, or should I employ a different design strategy or a different memory manager policy (such as ...
5
votes
0answers
92 views

String matching algorithm

I have been going through algorithms and data structures and recently came across string matching algorithms. I have not yet wrapped my head around the significance KMP algorithm so I came up with ...
8
votes
2answers
165 views

C++(11/14) intercalate implementation

I wrote a simple generic intercalate function (that should be semantically equivalent to the Haskell intercalate). ...
3
votes
2answers
208 views

Function for splitting an integer into smaller values

This is the function I've implemented in an answer to this question. I've tried to make this as simple and idiomatic as possible, using C++11. Could this still be improved in any way? ...
10
votes
3answers
136 views

Code for sums in a vector

I posted this code in an answer earlier today, but thought it was worth seeing if somebody could suggest further improvements: ...
8
votes
2answers
56 views

Using inputted data from vector to create two outputs

I'm trying to figure out a way to do the exercise 3.20 in the C++ primer book I have to create a program that reads input into a vector then use that data to create 2 outputs: one is the sum of ...
3
votes
2answers
88 views

Memoization helper

Please review: ...
5
votes
1answer
187 views

Polymorphic (owned) reference wrapper for class hierarchies

Rationale: I often have the requirement to own object instances, while preserving polymorphic behavior (i.e. own the object and hold it by pointer, or reference). This is usually expressed as a ...
3
votes
2answers
374 views

Prevent re-entrant function call in C++

The purpose of this is to prevent a re-entrant function call in a single thread, e.g. prevent the situation where func() calls ...
5
votes
2answers
78 views

Using includes() vs. hash function to check if an unordered_set is a subset of another unordered_set

I did two methods to determine if an unordered_set is a subset of another unordered_set, using hashing, and the built-in ...
2
votes
1answer
72 views

Is this a meaningful Intrusive Pointer Class?

Is this intrusive pointer implementation correct? I tried to use the CRTP Pattern to avoid a virtual destructor in my class ReferenceCounting which provides the ...
7
votes
1answer
125 views

Sequentially remove members “repelled” by previous members

I was working on a project that need to remove extra data such that the remains are not "too close" to each other, and the algorithm should be as generalize as possible. To have more general usage, I ...
1
vote
1answer
111 views

Thread-safe callback registration and invocation in C++11

I need your help in reviewing the following code. My main concern is dead-lock, but there might also be other issues. The EventGenerator object is owned by a ...
10
votes
3answers
436 views

Searching for pseudo-palindromes (“semordnilaps”)

I was interested to know which words of the English language, when spelled backwards, are still valid words (e.g. "drawer", which when spelled backwards is "reward"), so I wrote a small program to go ...
4
votes
1answer
90 views

Container which iterates a range or a list

I have made some composited container Range which accepts either a min/max range as a std::pair or a set of integers as a ...
4
votes
2answers
100 views

Exercising in copy constructors and assignment operators

I've just created an implementation of array to train myself in copy constructors, assignment operators, and exception safety. Please look at this code and tell me what is wrong here. ...
4
votes
2answers
111 views

Multiple dispatch with variant and multi visitation in C++

The following program is a demonstration of variant and double visitation used to obtain double dispatch between the elements of two inhomogeneous containers. Most of the work is done at compile time. ...
3
votes
1answer
86 views

Auto-recycling C++11 polymorphic smart pointers

I've recently read an interesting blog post by Philipp Zschoche: it explains how it's possible to avoid unnecessary allocations/deallocations by keeping track of previously allocated memory in a ...
4
votes
1answer
74 views

Standard-layout tuple implementation

I have written a simple (read: incomplete) tuple implementation that, AFAICT, does not violate the standard layout requirements. It's largely based on Nish's implementation, but I use a recursive ...
8
votes
4answers
481 views

std::vector composition with self populating super-powers

I have written a deliberately pretty simple class that wraps a std::vector to basically make it capable of self-populate itself with random generated numbers, ...