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)

8
votes
2answers
69 views

Lexer+Parser code for my “Reedoo” programming language

I've been working on my own programming language, as a hobby for the past couple of months now, called Reedoo. It is implemented in pure C++ 11 and uses only the libraries that come with C++; no ...
-1
votes
2answers
68 views

LinkedVector : a vector of elements with links to other elements

I wanted to have a vector with usual values and with some sort of indexing : an element can have links to other elements (via indices). Something like the following, where ...
6
votes
2answers
98 views

Policy-based, variadic logger class in C++

I've been exploring design based around some of the more advanced C++11 features lately, and some of them are turning out to be rather useful for some projects I'm working on. One is this ...
-1
votes
0answers
21 views

Program for finding the longest common subsequence [on hold]

Here is the code that I wrote to print the LCS: ...
2
votes
0answers
38 views

Variadic template pack, similar to std::tuple, but left-to-right and tightly packed

Preface I am currently writing this pack template to pack all the values (raw / fundamental + arrays of such, especially c-strings) as a helper for my ...
3
votes
1answer
29 views

Test if two nodes in binary search tree are cousins

Cousins are nodes at the same level of the tree, with different parents. They don't have to share the same grandparent. My solution depends on having a binary search tree with unique elements. This ...
5
votes
1answer
65 views

Program that replicates itself

While misreading the beginning of Stage I of this classic paper by Ken Thompson, I decided to create program that replicates itself. Let's say this program is called Replicator.exe. Upon running it ...
3
votes
2answers
52 views

C++ implementation of Java's floatToIntBits() and intBitsToFloat()

I am trying to implement Java's floatToIntBits() and intBitsToFloat() methods in C++. The latter method is the inverse of the former method, and the purpose of the former one is to pack a 32-bit ...
7
votes
2answers
87 views

Is this a modern C++11 implementation of a Level class and static factory?

This is a follow up to my previous question, now that I've read up more about modern C++ (specifically C++11) and the answers in the question. I'm using MSVC/Visual Studio 2012 Update 4. Specific ...
4
votes
2answers
49 views

writeln() and format() with variadic templates

I wanted to get better acquainted with variadic templates, so I decide to try to implement a function like D's writeln(), just for fun. ...
3
votes
2answers
66 views

Multithreading decouple update-logic and render-logic

I want to improve my multithreading competence and tried to build a compact doublebuffered way to separate two threads where one is only displaying the state and the other one updates the state. So I ...
7
votes
2answers
113 views

Sorted vector (aka flat_set) for objects (pointers) with custom embedded key (functor used)

BEFORE YOU READ: this link should be included when you just don't like the format of the question and for those that read this question for the first time, the link may give you the idea what happened ...
6
votes
4answers
96 views

Custom class for a borrowed unique_ptr<T>?

In C++11, I tend to have master objects that maintain sole ownership of a collection of some children objects. Let's assume these children objects are non-copyable (for instance, ...
4
votes
1answer
121 views

Implement a string in reverse using pointers and recursion

I'm trying to reverse a string using pointers and recursion, and I send it a char array. Is this the best way, or is there a better one? ...
5
votes
1answer
116 views

General multithreaded file processing

I'm trying to write a general multithreaded file processing facility. The idea is that some input file consists of a number of discrete records, each record needs to be processed in the same manner, ...
6
votes
2answers
92 views

Summator simulation

This is a reference implementation of a summation unit. The algorithm used is a most straightforward carry-propagation. If necessary, a test driving code could be provided. Few notes for the ...
7
votes
5answers
466 views

Removing the largest values encountered so far in a list

The problem is, in summary: A set of values will be given. Whenever the input is -1, the largest number from the values inputted until then needs to be printed, and is then deleted. Here is the ...
7
votes
1answer
40 views

Homebrew std::string for use with kernel

I've ported some standard library facilities like vector, algorithm, etc. to my kernel so I can code in C++ instead of C. This is one of them. I'm looking for concerns regarding: Performance Safety ...
6
votes
1answer
72 views

A tiny switcher for arbitrary types in C++11

I was about to use the awful enum+map trick to switch on std::strings when I thought to see if I could let some variadic templates do the job for me and I started ...
5
votes
0answers
36 views

Normalize Sparse Matrix along rows in C++ Eigen

I wrote a function to normalize sparse matrix along rows using C++ Eigen; however, I feel that it can be improved, and that I am not using some built in functions of Eigen. ...
6
votes
4answers
534 views

Binary Search Tree C++ Implementation

I've implemented a simple binary search tree for practice purposes: ...
5
votes
2answers
88 views

A tuple unpacking macro that approximates Python elegance

Motivation Although I love coding in C++, I sometimes yearn for the syntactic sugar of Python. C++11 has somewhat eased the pain by such beautiful analogies like this: ...
7
votes
3answers
179 views

Function to convert from const char * to char**

I made an adapter function to convert a const char * to char ** splitting the words in the initial string at each white space ...
4
votes
2answers
81 views

begin() vs rbegin(): how can I avoid duplication?

Can the display function be re-written to avoid duplication of the std::for_each loop? ...
-1
votes
1answer
46 views

Multithreading - program with lots of parallel routines (C++) [closed]

I'm coding a networking software, which has lots of functions (modules) which can be run in parallel. They share some resouces, like libnet_contexts of every type, ...
2
votes
2answers
109 views

STL List Implementation

I've implemented a simple C++ STL like list. It's pretty simple, all the constructors and methods haven't been implemented here, but majors are. ...
6
votes
3answers
346 views

Clean Code attempt of HOLES problem on codechef.com

The problem asks you to take read an integer (number of words to read) and then process words entered counting the number of "HOLES" exist. Letters with HOLES are ...
4
votes
2answers
46 views

Value Iteration Implementation for MDPs

I've been working for a while on a decision theory library, and since I've never really had any formal training in code best practices I'd love to hear your feedback. This particular class is one of ...
3
votes
2answers
71 views

Emulating __uint128_t

I developed a lot of code locally with __uint128_t only to find out that it is not available on the target platform. I am now trying to write my own struct that ...
7
votes
3answers
590 views

STL Queue Implementation

I've implemented a simple C++ STL like queue. (I've tried to follow @LokiAstari stack implementation code fashion) ...
1
vote
2answers
110 views

Binary search as a generic algorithm

I am upgrading my C++11 knowledge and repeating some essential algorithm. Here is binary search only in terms of iterators. ...
10
votes
2answers
101 views

Parsing of a (Linux) netlink hotplug uevent packet

The netlink service is used, among other things, to notify userspace about hotplug events (e.g. "a device has been connected"). These events come in the form of packets, which follow the following ...
10
votes
3answers
607 views

Clean code attempt at ATM problem on codechef.com

The problem asks you to take an integer (debit amount) and a double (credit or initial balance amount) and process the requested debit verifying that 1 it's a multiple of the minimum denomimation ...
13
votes
2answers
158 views

Thread pool worker implementation

As an exercise in using C++11 features I decided to make a thread pool class. I would like to have a review on the code with focus on: Standards compliance / Portability issues / Best practices ...
5
votes
3answers
177 views

Determine whether one vector is a prefix of the other

Exercise 5.17: Given two vectors of ints, write a program to determine whether one vector is a prefix of the other. For vectors of unequal length, ...
2
votes
0answers
54 views

CRTP object counter to track accidental singleton instantiation

I have used CRTP to implement an object counter for singleton classes. This way I can keep track of accidental attempts to instantiate more than one object. It is a header only class: ...
4
votes
2answers
138 views

Game framework using C++

I'm writing my own game framework and would like to get feedback on the API while I'm writing it. At the moment it's very simple, but I would like some guidance about where to take it. This is a ...
19
votes
5answers
2k views

Aliens at the train

I solved this problem on SPOJ: The aliens have arrived to Earth and everything is in harmony, the two races can live together. However, one specific Female Alien does not want to see humans ...
3
votes
2answers
207 views

Checking whether a given timestamp is more than two weeks old

I am trying to see whether a given timestamp is more than two weeks old or not. If it is two weeks old, then print out "Hello" and if it is not more than two weeks old then print out "World". I have ...
12
votes
2answers
401 views

Efficiency/design of trim() library code

I am working on some library code and I am trying to optimize my trim() functions. To that effect I am trying to figure out how best to deal with each kind of ...
6
votes
2answers
126 views

Layer Stack class to practice std::shared_ptr

The following three source files is to define and test a class StackLayer. While it was written in a need for scalable layer-based architecture design, it was also ...
2
votes
1answer
42 views

Parallel Reduction method with C++AMP

I am writing a C++AMP library, and as one of my utility methods I am implementing a parallel reduction algorithm based on the cascade method documented on this blog post with slight improvements by ...
4
votes
3answers
119 views

Another permutator

This is a solution to this problem. The problem statement: write a program to display all possible permutations of a given input string--if the string contains duplicate characters, you may have ...
11
votes
2answers
206 views

Function wrapper like std::function that uses “small buffer” allocation

My Function class is similar to std::function with the small-buffer optimization. However, it always uses a small buffer and ...
4
votes
0answers
112 views

Testing a lock-free job queue

I've created a lock-free job queue and with the tests I've written, which is also very fast. That makes me doubt my benchmark procedure, so I'm hoping the collective knowledge will shed some light on ...
12
votes
6answers
880 views

Using a static variable inside a lambda

Is using a static variable in a lambda function ok, or considered a bad practice? The code below works as intended (fills a vector with consecutive numbers). ...
10
votes
2answers
159 views

String concatenation utility in C++11

I published a concatenation utility lastly and I feel it could be very good help for many people, but before I promote it, I would like to polish the details as much as I can. So I'll like to ask you ...
5
votes
2answers
122 views

Singleton Typed Memory Manager

For my resources management, I wanted the objects allocated on the heap to be in a contiguous block of memory. Obviously, each data type then has to have their own chunk of memory. I could have used a ...
3
votes
1answer
55 views

Wrapping std::bind call in a function returning std::function

Is this code correct? It appears to work in g++ 4.8.3 and clang (bcc64), however appearing to work is no guarantee of correctness :) The aim is to be able to replace a call to a member function: ...
11
votes
5answers
458 views

Stopwatch template

It's often useful to be able to time code, for instance, to evaluate alternative approaches to the same problem. Because this is a thing I use frequently, I have created this Stopwatch templated ...