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)

1
vote
0answers
18 views

GOF Composite Design Pattern Implementation Using Modern C++

After reading about the composite pattern from the GOF design pattern book, I thought to re-implement the code mentioned in the motivation section using the modern C++ concept/idioms. Below is the ...
0
votes
0answers
17 views

Rendering speed in SDL2 [on hold]

I have a large rendering class using SDL2: video.cpp (github mirror) It all works fine, except it's a bit slow (starts lagging at larger resolutions). The reason for this is obvious - it basically ...
6
votes
3answers
703 views

String case reverse function in C++

This reverses the case of a character in a string (a string being an array of characters). How does it look? Anything I can improve on? Let's get critical here. ...
11
votes
2answers
114 views

Fast (faster than std::) ostringstream

I tried to implement a faster ostringstream which initially uses the stack (up to 256 bytes before using the heap). Also, unlke the standard, it provides a way to ...
8
votes
0answers
42 views

Function composition using std::bind

Given a number of functions f1, f2, f3, ..., fn I ...
5
votes
1answer
39 views

Formatting database like table

The goal of my program is take some headers and fields and display a nicely formatted table like this: ...
6
votes
1answer
68 views

Is this a correct implementation/use of move semantics?

I'm trying to account for the fact that my program will contain calculations such as: v(t) = w ∗ v(t−1)+ c1∗r1∗( pBest − x(t −1)) + c2∗r2∗(gBest − x(t−1)) where ...
4
votes
3answers
88 views

Basic Encoding Rules (BER) class for embedded system

I'm implementing a communications protocol in an embedded system and the protocol uses a subset of the ASN.1 BER (Basic Encoding Rules). In a nutshell, this class simply represents a TLV triplet ...
1
vote
0answers
39 views

Writing a universal “call” function: call(f, args…) where “f” might be a member function/data pointer

I need a function call(f, args...) which calls the "function" f with the arguments args.... ...
9
votes
5answers
656 views

Find primes using “naive” algorithm

I know I can use Sieves to make this faster, but I wondered if there's anything I'm missing with this implementation of the "naive" algorithm. On my PC running the command (first million primes): ...
2
votes
2answers
111 views

Max path sum algorithm

This is for Project Euler question 18 and I'm looking for feedback on whether my algorithm is incorrect or whether I've just implemented it wrong (which I don't think is the case after some testing). ...
3
votes
2answers
253 views

Squaring numbers in an array

I want to know if there is a better way to square numbers in an array. This is what I wrote: ...
5
votes
2answers
73 views

Writing out a tree of Tnodes with words as values in alphabetical order

I'm doing this: Consider: struct Tnode { string word; int count; Tnode* left; Tnode* right; }; Write a function for entering new words ...
6
votes
4answers
88 views

Efficient prime factorization for large numbers

I've been working on a little problem where I need to compute 18-digit numbers into their respective prime factorization. Everything compiles and it runs just fine, considering that it actually works, ...
5
votes
1answer
122 views

Iterative Fibonacci sequence using standard library functions

We're all aware of Fibonacci sequence calculators but they look like C-style code. I want to avoid that and take advantage of the standard library. This code is very short, so I'm focusing on ...
5
votes
3answers
153 views
2
votes
1answer
55 views

Lockless, blocking, non synchronized multiple producers and consumers ring buffer

My program is structured like this: there are M producer threads, each of which computes a section of an object O with index ...
8
votes
0answers
53 views

Chrono-like clock with different epoch (from 1.1. 2000)

The following will by my simple helper, that should behave just like std::chrono::system_clock but with the epoch being 1.1. 2000, that I can easily cast durations ...
4
votes
0answers
54 views

Eliminating duplication in Python native code function call dispatchers

I attempting to merge 3 functions into one, as they contain for the most part the same code. Here are the original functions: ...
8
votes
5answers
556 views

Probabilistic matchmaking simulation

The following is a problem I found on this wiki. What can I do to optimize my algorithm, and make this code more C++11? Write a program to discover the answer to this puzzle:"Let's say men and ...
6
votes
2answers
237 views

Templated Doubly-linked-list

I've been wanting to revise what I knew on templated classes so thought I'd write a doubly linked list to practice. It works fine, so all is well and good on that front, but is there something I've ...
7
votes
1answer
67 views

Sorting algorithms with utility functions and iterators

My implementation of insertion, merge, and quick sort, with some utility testing functions. I just wanted to know how I can improve the efficiency and general cleanliness of my code. (note: I know ...
5
votes
2answers
107 views

Graph vertex class implementation with adjacency lists

I wrote an implementation of a graph with each vertex storing a std::vector of vertices it's adjacent to. Please critique this. ...
4
votes
2answers
233 views

Project Euler #48 in C++

This question is similar to Project Euler #48 but constraints are different: $$N < 2000000$$ Just in case the link is unavailable, here is the problem statement: We've to print $$\left( ...
5
votes
3answers
345 views

Project Euler #8 - “largest product in a series”

This code works when compiled on gcc 4.8.2. I would appreciate any comments on my style and the readability of my code, and any improvements that I could make to make the code more readable and/or ...
4
votes
2answers
71 views

Wrapper template functions for memset()

I have these three helper functions that I've used on some projects as a slightly better alternative to the C memset function. The objective is to simplify and ...
17
votes
4answers
952 views

The Term-inator: Pi edition

The fourth project, continuing my C++ saga with terrible post names. :P An approximate value of pi can be calculated using the series given below: $$ \pi ...
2
votes
1answer
66 views

Still an observer pattern?

Usually when I see tutorials about Observer Pattern I see an unique method called notify, but I'm wondering. What if I have different methods that can be called in ...
3
votes
1answer
62 views

Program that handles program options

I'm using boost::program_options to parse input from the user. However, while the standard library makes this an easy task to do, it's causing an (in my opinion) ...
1
vote
2answers
69 views

Speeding up and shortening a loop [closed]

I'm still relatively new to C++ and I've written a program that could do with being a bit shorter and faster. I use this same set of for loops many times to cycle through the whole tree of values. ...
3
votes
2answers
170 views

Read binary file by blocks

I wrote a function that allow me to read a binary file using 3 blocks what ever the length of file. I've decided to divide the length of my file into 3: block 1: ______________ block 2: ...
16
votes
4answers
4k views

If she floats then she is not a witch like we thought

Continuing my C++ saga, this is the third project for my CS1 class: Buoyancy is the ability of an object to float. Archimedes' principle states that the buoyant force is equal to the weight of ...
2
votes
1answer
104 views

ComponentManager - Entity-Component-System architecture in C++

Lately I've been working on a small C++ Entity-Component-System framework. Like most other ECS frameworks the internal data is presented as a table where an entity is a simple row index and each ...
5
votes
1answer
79 views
5
votes
2answers
143 views

One-to-many multiplicity pattern

The following working C++11 code demonstrates working code for a pattern for representing one-to-many relationships between objects. GitHub (A variant of that code is also copied inline at the ...
3
votes
2answers
466 views

Convert number into words

I am trying to implement a program which can convert number into words. My code can convert numbers between 0 - 999. It uses recursive function calls and simple arithmetic operations. Can you please ...
5
votes
4answers
185 views

Implementing Conway's Game of Life

Here is an implementation of Conway's Game of Life. My code is working fine but I want you to review and give me your suggestions of how to improve it. These are the steps of my code: Initialize ...
15
votes
2answers
486 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
87 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
139 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 ...
2
votes
1answer
97 views

Variadic template data pack strucuture designed for debug/trace log (variable-sized records)

I am currently writing this pack template to pack all the values (raw / fundamental + arrays of such, especially c-strings and ...
3
votes
1answer
42 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 ...
6
votes
1answer
74 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
3answers
94 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
99 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 ...
5
votes
2answers
62 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
140 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
141 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
111 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
218 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? ...