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)

0
votes
3answers
55 views

Extend number of arguments in std::hypot

I would like to call std::hypot with many arguments (not just 2 or 3). Mandatory requirements: fast run at compile time when possible Non-mandatory ...
1
vote
1answer
81 views

A different way to execute a hangman game

Most hangman implementations I have seen keep a list of characters the player has already guessed and compares them to the players current guess each time to see if they have already made the same ...
3
votes
2answers
82 views

Building a simple singly-linked list in C++11

The implementation below works, but I'm wondering if there's a modern C++ alternative. For example: Should I replace the raw new with a braced initializer? ...
4
votes
1answer
39 views

Monitor and video mode querying

I am working on a large project that requires information about the monitor(s). Please don't be confused by the organization of the following structs. The design intent is to be cross-platform, so ...
1
vote
2answers
41 views

Crawling SPOJ through cURL and C++

I am trying to write industry standard code. https://www.quora.com/How-do-I-follow-a-user-on-Spoj-for-solving-problems-Refer-Details Someone gave me this A2A. And I wrote this code for it ...
1
vote
3answers
67 views

C++11 Blocking Queue learning exercise

As part of my own C++11 learning exercise I have implemented this Blocking Queue using the new C++11 thread API. One of the aspects I would like to improve is efficiency i.e. in the ...
3
votes
3answers
84 views

Counting the number of primes in C and C++11

I found this old piece of code that I wrote while I was learning C a while back: ...
2
votes
1answer
83 views

Find shortest paths in a matrix using Dijkstra's algorithm

The problem is as follows: I have a matrix with impassable fields those are marked by the input. There is also a castle which reaches up the right side of the matrix. I have to find how many paths can ...
2
votes
1answer
52 views

Maxflow for baseball elimination game

I have a problem similar to the baseball elimination. Given some teams, the number of wins they have and the number of games they have left between each other I have to find for which team it is still ...
1
vote
2answers
35 views

SPOJ “TESSER” - Getting TLE using KMP algorithm

The TESSER - Finding the Tesserect problem is tagged as a problem to be solved by Knuth-Morris-Pratt (KMP) algorithm. I'm using KMP, but am still getting time-limit-exceeded. Task Each of T test ...
4
votes
0answers
35 views

No-copy cache line aligned function storage object with small object optimization

I have implemented a std::function-like class, that is optimized for storing lambdas, that never copies the stored function, that has a small buffer to store ...
1
vote
0answers
39 views

Performance of critical function (STL transform)

I have finished the first part of my project, i.e., getting a full working program. However, the performance is not too impressive. The function ...
2
votes
1answer
63 views

Dynamic multidimensional arrays

My application needs Field objects, which encapsulate 1D, 2D or 3D gridded data. The number of dimensions and their size are known only at run time. Furthermore, I ...
1
vote
2answers
44 views

Storing and loading functions

The class Functions can store/load any functions. It does this by assigning a unique name to every function that gets added. You can then call the function by ...
5
votes
2answers
115 views

An optional<T> implementation

This is an implementation of optional<T> from C++17, it is mostly standard conforming. I'm looking for a review on efficiency, correctness and performance. ...
9
votes
1answer
185 views

Variant class using generic programming

My goal is to learn a bit more about generic programming in C++. So, one of the trickiest things I've heard you can do is creating a Variant class. This took me a while and I needed to read and study ...
0
votes
1answer
61 views

C++ lazy constructor

I'm implementing a lazy constructor in C++. The goal is that for a type T, lazy<T>(args...) returns a callable object ...
0
votes
1answer
79 views

C++ simple event system

I posted an earlier version of this code a couple of days ago, so it's the updated version of the code posted here. ...
3
votes
1answer
80 views

Simple event system

This is a class which provides a simple event system mechanism: ...
0
votes
0answers
33 views

create only one instance with std::weak_ptr and enable_shared_from_this

I need to have a specific instance which is not destroyed (short-lived singleton?) I do not know at which point of my program the class needs to be instantiated nor do I know when it needs to be ...
5
votes
1answer
51 views

Lazy String splitter in C++

I created a string splitter in C++. It splits a string in a lazy fashion and makes use of forward iterators to sequentially supply the next token from the string until it runs out of tokens. ...
3
votes
1answer
57 views

Custom GUI Slider class

I want to improve my slider class as much as possible. Is this acceptable code for a slider? I've tried to comment as much as I can. If you want to find out more about the ...
4
votes
4answers
292 views

Removing duplicate characters from a string

I implemented a function removeDuplicates which takes 1 parameter, a std::string, and returns a ...
5
votes
2answers
118 views

Counting sort using STL

I'm trying to learn to use the C++ Standard Library and some of the modern C++11 features. Can someone review my counting sort algorithm below and critique my style/algorithm/use of the STL? Thank ...
4
votes
1answer
49 views

Wrapping a non-unique handle with additional information

I have a situation where I'd like to wrap up some plain C handles into a class, with a destructor and other niceties, in C++. I would like the wrapper class to have the exact same size as the handle, ...
2
votes
1answer
62 views

Parsing in between of brackets

I do parsing of the string in order to find wrapped sub-string inside brackets of the first level. a+(b+(d-g))+g+d, in this case I will need to separate ...
3
votes
2answers
97 views

Threadpool implementation in C++11

I am implementing a very primitive threadpool with C++11 using mutex and conditional variable. The class ...
2
votes
2answers
52 views

Creating a ticker thread - version 2

In this question, I asked for feedback on a class that provided my program with periodical signals. I have rewritten that class based on the feedback from the accepted answer. As this again uses a ...
2
votes
0answers
53 views

C++ Event Emitter

I needed an event bus in C++ with a few features: Possibility to add/remove both functions and member methods. Ability to remove automatically those listeners that wrap member methods of expired ...
4
votes
0answers
43 views

Delete engine for deeply nested linked structure

The background is the question at http://stackoverflow.com/questions/36634394/nested-shared-ptr-destruction-causes-stack-overflow. To summarize, for a data structure that looks like: ...
1
vote
1answer
49 views

Particle in Cell: efficient data structure handling

I am building a simulation where you have 'Agents' distributed over a rather large landscape. Because the number of Agents is small, compared to the size of the landscape, I use the PIC approach where ...
2
votes
1answer
59 views

String-casting utility functions

I wrote a small header that is supposed to take care of calling the right strtoX or or stoX function for me and doing so at ...
2
votes
1answer
86 views

Creating a ticker thread

A new question about a revised version of the code in this question, based on the advice in the accepted answer can be found here. I need to signal my program to do something every X seconds. So I ...
2
votes
0answers
83 views

Measuring the execution time of C++ code

I've written a small C++ utility that is intended for measuring the execution time of blocks of code, and I'd appreciate your feedback on it. I'm an experienced programmer, but a novice C++ ...
2
votes
2answers
73 views

A linked list with push pop append and destructor

I tried to implement a linked list that can do pop(), push(), append(), printall(), and so on, and also I tried to handle the wraparound features, and de-wrap it when check if the list is cyclic to ...
2
votes
2answers
82 views

Server socket “wrap” functions

This is a small socket library I made to avoid complicated C boilerplate code and several #includes for connecting sockets, bind, listening etc. Please note that ...
4
votes
2answers
42 views

Copy Constructor for a linked list with self-referential pointers

I came across a coding challenge that looked something like this (recreating from memory, sorry) Suppose you have the following interface for a linked list. Implement an efficient and correct ...
1
vote
2answers
48 views

Spawning futures as an alternative to multithreading

I was trying to do a sample threading program, where the spawning of thread is in a while loop. I DO NOT want to generate multiple number of threads. The while loop should keep on running, ...
3
votes
1answer
126 views

Huffman algorithm implementation in C++

Lately, I have been working on this Huffman algorithm and it is finally done, though I think it is improvable due to the fact that people say you have got to use two priority queues but I ended up ...
6
votes
1answer
122 views

Generic and accurate floating point “equality”

Like those who have come before me, I foolishly have sought to implement a generic, efficient, idiomatic, and most importantly correct method of comparing floating point numbers for equality. Like ...
1
vote
1answer
48 views

Custom C++ STL-like doubly linked-list(C++11)

This is the link list I just created. It works fine for now, but would want to know if I could make it better. list.hpp ...
3
votes
2answers
43 views

Simple Octree implementation

I've implemented a rather straightforward octree, but I don't feel that good about the coding style or some of the implementation. In particular, I use some nasty ...
3
votes
1answer
38 views

Ticket sale income calculator

I am looking for some useful feedback on my programming. I'm only three days in and trying to improve. Here is the code: ...
1
vote
1answer
63 views

Operator Oveloading: “+” and “==” for two classes

I have one class Number (base class) and two child class Fraction and ...
0
votes
1answer
60 views

NetBuffer - buffer specialized for socket read / write

This class is for fast and small footprint buffering made specially for network I/O. It is similar to so-called circular buffers, but is not circular. ...
2
votes
2answers
72 views

Checking if a single linked list is a palindrome in C++

The following is my first try at this classical interview question. It is quiet different from the solutions Gayle Laakmann provides in her book, and in another question on stackoverflow, someone ...
3
votes
0answers
48 views

C++ time types and format conversions

I wrote a small header-only C++11 header for converting between various C++ time formats. Here's the code in question: ...
2
votes
1answer
53 views

Compile-time string hash

A while back this question proposed a constexpr compile-time Sieve of Eratosthenes. It also linked to another SO question about compile-time computation of CRCs. ...
2
votes
0answers
95 views

C++ UDP server for a game

I broke my server into two classes, a general server class and a client session class. I know the code isn't documented in the header, but I am more interested in the design of the server/session ...
0
votes
1answer
103 views

Add two fractions or two integers using template class and overloading

Question: Need to create three classes. Number Fraction Integer Requirements The first class should support “display”, “==”, and “+”. "Display" : This operation displays the Number itself in ...