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
14 views

Rotate image 90 degree clockwise recursively

Previous question: Rotate image 90 degree clockwise In this code I have used tail recursive, which is bad. Iime complexity is still \$O(N^2)\$, which is worse-case. The only good part is memory ...
3
votes
2answers
79 views

Rotate image 90 degree clockwise

* Time complexity: O(N) * Memory complexity: \$O(1)\$ Is my calculation of complexity correct for this code? ...
4
votes
1answer
57 views

Optimize the Buddhabrot

I am currently working on my own implementation of the Buddhabrot. So far I am using the std::thread-class from C++11 to concurrently work through the following ...
6
votes
0answers
49 views

Mapping a textual method name to a function

My program (a daemon hosting a Minecraft server) exposes a D-Bus interface to allow interaction with the server from other processes. To that end, and to avoid a chain of repetitive conditionals in ...
11
votes
2answers
674 views

Optimize simple C++ function to minimize copying

I've been coding C for almost 20 years and figured I should learn C++. As a starting point I wrote the following trivial code to generate the powerset of a set. I'm hoping that some experienced C++ ...
8
votes
1answer
78 views

Rotating and printing an image

I carefully used smart pointer to avoid memory leaks and dangling pointers, but someone says my code has memory leaks. Is it true? If so, how can I fix it? ...
5
votes
2answers
132 views

Rotate an image (2D array) by 90 degrees recursively with low memory usage

I'm looking for comments on coding style, passing arguments, ...etc. ...
1
vote
0answers
33 views

Counting words in files - follow-up 4

Previous question: Counting words in files - follow-up 2 Continuation of the meta programming template version of counting words. Inspired by example of pirntf ...
8
votes
1answer
215 views

Jarvis's March Convex Hull

I'm more concerned about the coding best practices and how it's written here than the actual algorithm and math. I'm concerned about stack constraints, passing arguments,..etc. If there is anything ...
2
votes
2answers
39 views

Counting words in files - follow-up-3

Previous question: Counting words in files - follow-up 2 For simplifying the code, I have implemented std::regex rather than templates. How can I improve this ...
7
votes
0answers
65 views

Use of Mediator Pattern or Proxy Pattern for a game

When a Wizard casts the Monster Summoning spell, all of the summoned monsters shall follow his command. Should the Wizard interact with his summoned monsters ...
2
votes
0answers
29 views

Counting words in files - follow-up 2

Previous question: Counting words in files - follow-up I have fixed punctuation problems in my previous code by using template, because it is easy to understand and my focus on template mechanism. ...
2
votes
1answer
68 views

Counting words in files - follow-up

I have made a non-threaded version of counting words. The result was unexpected the non-threaded version was faster than threaded-parallel version. Non-threaded version: ...
4
votes
1answer
59 views

UVA 10474 - “Where is the marble?”

I have been solving the problem from UVA 10474. In this problem, there will be marbles with numbers written on them. For example suppose five marbles with numbers 50 , 43, 43, 43, 2, 90, 44. There ...
5
votes
4answers
84 views

Project Euler #3 In C++

The question for reference: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143? answer: 6857 I'm looking for general feedback as to ...
4
votes
1answer
111 views

Counting words in files

I made a simple program for my study that calculates words in a text files and prints every word and its repeated times in the files. How can I improve this code? ...
3
votes
1answer
65 views

Using std::array to implement variadic construction of class with list-of-self as subclass

I have a situation with a base class for whom a container of itself is a subclass. So a Block of Item has various ways in which ...
4
votes
1answer
96 views

Simple mathematic operations (add, sub, mul, div) in C++11 template

I made a simple script to implement basic mathematics operations by using variadic functions. I would like to know if my implementation is correct. The code only works for visual C++ compiler Nov ...
3
votes
0answers
47 views

Message Queue for RTOS for microcontrollers [migrated]

I'm currently writing an RTOS for microcontrollers. The whole thing is written in C++11 - if anyone is interested, and the link to the repository is at the bottom. Currently I'm writing a class that ...
15
votes
2answers
251 views

A header-only linear-time C++11 PEG parser generator supporting left-recursion and grammar ambiguity

I've rewritten my original parser generator to a header-only library which uses templates and functionals for better type safety and clarity. The generated parser creates an abstract syntax tree which ...
8
votes
0answers
116 views

Object storing and retrieving using wildcard identifier

I'm writing an interpreter for a scripting language which allows objects to: Have an alias Be referenced using a wildcard Contain child objects Combination of all three above For example: ...
2
votes
3answers
89 views

Use of macros to aid visual parsing of SFINAE template metaprogramming

I've recently been introduced to SFINAE to solve the problem of unwanted promotion precedence. i.e. I was hoping to catch integer types with Foo::Foo(long) and ...
1
vote
4answers
90 views

Is this the right way to delete a node?

This is how I am deleting a node from a singly linked list. Would this be the most correct way? ...
1
vote
2answers
135 views

Effective way to remove white spaces from string

I have come up with this approach but I'm not convinced about its effectiveness. Is there any effective approach? ...
2
votes
0answers
55 views

Generate a random numbers class - follow-up

Previous question: Generate a random numbers class I have come up with three different ways to define type of mUniformDistribution. All of them work fine in VC++ ...
11
votes
2answers
126 views

Simon Says / Four tiles game, with C++ and SDL

My take on the Prebash Challenge, "Simon Says" game, in less than 300 lines of C++ (plus the header file), using SDL for window management and drawing. simon_says.hpp: ...
4
votes
1answer
59 views

Container adaptors

How to improve the functionality, exception safeness and other aspects of the following container adaptors? Allows to write more generic code (not working for, say, ...
2
votes
1answer
33 views

Simplifying linked list insert_after

Is there a better way to insert after a node in a linked list? Currently I go through the node from the head of the list and find the node that has the value pos. ...
5
votes
1answer
133 views

Tic-Tac-Toe in C++11 - follow-up 5 - final

Previous question: Tic-Tac-Toe in C++11 - follow-up 4 How to improve this code further? ...
3
votes
2answers
291 views

Better way to find the maximum value in a Binary Tree

I have to find the maximum value in a binary tree. This is how I did it iteratively: ...
7
votes
1answer
102 views

Generate a random numbers class

I have made class to setup a random number bases on <random>. It works fine, but I have doubt in ...
1
vote
1answer
76 views

Do I need a destructor in a derived class that only uses base class private members?

I'm not a programmer and this code is probably not a nice one (suggestions are well accepted!), I'm trying to write a tool for my analyis and its the first time I'm using templates and polymorphism ...
10
votes
4answers
678 views

Morse code emitter

As the first step for writing a Morse code practice program, I thought I'd start with the very simplest step of a text-based Morse code translator. This simple program reads lines from ...
3
votes
1answer
93 views

Minimum Scalar Product

Here's the problem statement for Minimum Scalar Product You are given two vectors v1=(x1,x2,...,xn) and v2=(y1,y2,...,yn). The scalar product of these vectors is a single number, calculated as ...
3
votes
2answers
95 views

Count of Maximum - CodeChef

I'm doing an easy problem in codechef. Here's the problem statement for maxcount: Given an array A of length N, your task is to find the element which repeats in A maximum number of times as ...
2
votes
1answer
122 views

Tic-Tac-Toe in C++11 - follow-up 4

Previous question: Tic-Tac-Toe in C++11 - follow-up 3 I've been told to use <random>. However, it seems a bit more complicated than it looks to generate ...
11
votes
0answers
104 views

Virtual Texturing - Page Indirection Table

I'm working on a Virtual Texturing library for mobile devices based on OpenGL-ES. This is the PageIndirectionTable, one of the library components I would like to ...
3
votes
2answers
77 views

Typetokens in C++11

I have written a typetoken library in C++11 and I want to know if it is indeed typesafe, threadsafe and complete. The purpose of this library is to give an unique ID to every requested typename ...
3
votes
1answer
80 views

Tic-Tac-Toe in C++11 - follow-up 3

Previous question: Tic-Tac-Toe in C++11 - follow-up 2 Here, AI is being implemented. ...
2
votes
2answers
99 views

Tic-Tac-Toe in C++11 - follow-up 2

Previous question: Tic-Tac-Toe in C++11 - follow-up Is there any way to improve this code? ...
2
votes
2answers
77 views

C++ Prime Factorization

I just picked up C++ today and I wonder if this is c++-like. I have a bit of experience with Java. This is a program that takes a number as input and outputs its prime factorization in no particular ...
9
votes
1answer
76 views

Snippets Manager

This basically manages a set of snippets, saving and loading it. snippets.cpp ...
3
votes
2answers
109 views

Binary Search Tree in C++

I'm writing C++ for the first time and wanted to implement a BST. I come from writing C, so I tend to write code in that way. I'm trying to wrap my head around smart pointers, but can't seem to get ...
3
votes
3answers
126 views

AVL tree for inserting and searching

I have made an AVL tree. It works and does what it needs to do. I only need it to insert and search. I am comparing how long it takes to load and search a dictionary file in relation to other various ...
6
votes
3answers
114 views

Append a string to each line in a file

I wrote (several months ago) a program that will take an input file, with a provided std::string, and append that to each individual line in the file. Looking at ...
3
votes
1answer
78 views

Prim algorithm implementation for adjacency list represented graph

Please review the implementation of Prim algorithm. Points on which I have doubt: My Graph doesn't have any ID for nodes. Nodes are accessed based on their data. ...
1
vote
0answers
69 views

Kruskal algorithm implementation for adjacency list represented graph

Please review the implementation of Kruskal algorithm. Points on which I have doubt: My Graph doesn't have any ID for nodes. Nodes are accessed based on their ...
3
votes
0answers
52 views

Djkistra shortest path implementation for adjacency list represented graph

Please review the implementation of Djkistra algorithms. Points on which I have doubt: My Graph doesn't have any ID for nodes. Nodes are accessed based on their ...
4
votes
5answers
318 views

Creating vector of primes using Sieve of Eratosthenes

Please review my Sieve of Eratosthenes implementation. ...
4
votes
4answers
167 views

Tic-Tac-Toe in C++11 - follow-up

This is based on my first Tic-Tac-Toe game: Tic-Tac-Toe in C++11 I have come up with different game logic for my game. I would like to know which one is more reliable and effective and how I can ...