Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [c++11]

C++11 is the successor to the C++03 standard, adding various core language changes and fixes, and an improved and expanded standard library.

-1
votes
0answers
15 views

UVa Problem 10300(Getting Runtime Error SIGKILL) [closed]

I am solving UVa problem no 10300. But I am getting runtime error SIGKILL for the follwing code. ...
-2
votes
0answers
23 views

UVa Problem no. 10038.(Can't get correct output for some cases) [closed]

I am currently solving the UVa Problem no. 10038. So, to debug my code I went to uDebug. And found that my code was almost complete but with some exceptions. I want the following code to reviewed. ...
2
votes
0answers
90 views

Event management system in C++

I have this question asked as home assignment for an interview. I submitted my solution and did not get selected. Wanted to know your feedback for the solution. Question: Write a very simple ...
7
votes
1answer
64 views

Parallel Ramanujan's formula for 1/π calculation

I finished my university project for calculating \$1/\pi\$ and I would love to get some feedback. Before you guys jump into this code please keep in mind newcomer to C++ just decided to use it for ...
9
votes
2answers
1k views

Implement Own Vector Class in C++

I am preparing for an interview and came to know about this question: implement a vector class in C++. I thought of how I would write it an interview and included the code below. The things I know I ...
-1
votes
1answer
58 views

Determine if matrix exists or not [closed]

any help with optimizing following code to make it run faster. Tried making function inline, tried cin.TIE(NULL), tried ios_base::sync_with_stdio(false); ...
9
votes
3answers
82 views

Console Blackjack game, without split or betting system for now

I never programmed in my life, and I am currently self teaching myself some C++ by reading books, online free classes and googling. After beginning to read about OOP and classes, and after seeing that ...
5
votes
2answers
117 views

Templated division by a power of 2

I've implemented a div_by_power_of_2() function, which lets me force the compiler to use left-shifting rather than proper division, in cases when the developer know ...
1
vote
0answers
29 views

Functions like std::stoi for unsigned and shorter types using __gnu_cxx::__stoa

C++11 introduced the new standard library function std::stoi, unfortunately there is no equivalent function to convert an unsigned number inside an std::string to ...
4
votes
1answer
81 views

Simple ring/circular buffer c++ class V3

The Original Post (v2) As stated in the previous post, i'm looking for feedback on the updated version of the code posted. A few things specifically I'm looking for feedback on, are: I switched to ...
2
votes
2answers
74 views

Simple ring/circular buffer c++ class V2

The Original Post (v1) I'm looking for feedback on the updated version of the code posted at the link above. ...
4
votes
1answer
139 views

STL Performance micro-benchmark

I'm fairly new to C++, so as a learning exercise for how to use various simple data structures efficiently and what I should and shouldn't avoid, I wrote the following code: ...
3
votes
1answer
80 views

Elevation to power function using class templates

I attached below a small working example of a function that is able to perform x^y. As it is possible to see the base (x) takes ...
2
votes
2answers
40 views

Graph library - graph interface

I am trying to write simple graph lib in C++, BFS, DFS etc.. I want to create class GraphI which will represent any graph and will include necessary methods so my ...
3
votes
2answers
126 views

Merge Sort C++11 C++17

Question Any way I can optimize this further using new C++11 or C++17 features? Would also like feedback on my variable naming, memory management, and style (notice my placement of ...
3
votes
0answers
41 views

Multithreaded OpenGL Rendering Pipeline

I've decided to move my rendering code to a separate thread, to help facilitate the move I've created a pipeline system for rendering. With this pipeline I can insert commands into a queue which will ...
3
votes
1answer
43 views

Iterative version of a permutations algorithm

For learning purposes, I've written an iterative version of a recursive algorithm for generating the set of permutations for a given set of unique integers. Can I make any improvements to increase ...
6
votes
3answers
954 views

Array Dynamic resize in heap

I have answered a Question in Stackoverflow link. a) Create a function called resize that can be used to increase the size of integer arrays dynamically. The function takes three parameters. ...
1
vote
1answer
48 views

Get a map containing elements which are present in unordered map A but are not present in unordered map B [closed]

I would like to create a function which returns a map containing differences between two unordered maps. Here is the code: ...
3
votes
2answers
113 views

Mario Party Snake and Ladders Board

Context Was inspired from this LeetCode post to do my own System Design exercise of the common Snake and Ladders problem. As I was writing the code Mario Party kept coming to mind so I added a little ...
1
vote
0answers
24 views

Average histogram combining multiple files and vector of vectors (in c++)

I run a program of simulation N times (I use each time a different random numbers to initialize it). The results of the program are stored in 2N directories: every run produces two approximations. The ...
4
votes
1answer
54 views

Min heap C++ implementation

I have implemented a min heap in C++, and I want to improve it in every possible way. Could you please review it and let me know your suggestions/comments? ...
3
votes
1answer
33 views

A matrix-vector multiply parallelized using boost::MPI

This program performs a matrix-vector multiply using MPI to split the computation up. It is not extremely robust (for example, it doesn't handle the case where the number of MPI processes does not ...
6
votes
1answer
86 views

Qt Number Generator v2

Link to the old question. I tried to learn some new things from the answers and here's what I did: Used Qt Designer so that in Config.h, all member variables and ...
4
votes
0answers
88 views

C++ shared_ptr memory pool

I put together this little memory pool class to help avoid the costs associated with heap allocation and deallocation of objects that are frequently created & destroyed. It creates C++ standard <...
4
votes
2answers
74 views

Simple device (fancy) pointer implementation

device_raw_ptr is a simple fancy pointer. It essentially wrap pointers to GPU memory. It's sole purpose is to separate out host pointers from device pointers, i.e. ...
6
votes
1answer
142 views

Implementing a queue: questions and clarification

Im trying to teach myself some computer science (and c++). I am relatively new to this (and to code review). I have attempted to implement a queue. I have copied the code below for reference. ...
2
votes
1answer
109 views

Cache with limited size; If full remove the oldest

Here is a class that stores a single value into the limited cache. If cache is full, it will remove the oldest element to make a space for a new value. I'm using 2 structures to accomplish this ...
15
votes
3answers
3k views

Modeling an IPv4 Address

I've recently picked up a book that gives various "modern" C++ challenges/solutions. One of the first ones I did was on modeling an IPv4 address in C++. Below is the full implementation; it's also on ...
8
votes
2answers
176 views

Creating a lock-free memory pool using C++11 features

I have created a thread-safe and lock-free memory pool program using C++11 features. A couple of notable features: g_memStack is a stack that contains the memory ...
3
votes
1answer
78 views

Effective message dispatching [closed]

I have some code, that works fine. However, I know there is a lot of code duplication and C-style programming. In the code example there only is a ...
4
votes
2answers
106 views

Replace unicode character in the string

A function which replaces an unicode character in a string: ...
10
votes
1answer
359 views

Google Kickstart Round A 2019 - Training

Problem: Training As the football coach at your local school, you have been tasked with picking a team of exactly P students to represent your school. There are N students for you to pick ...
8
votes
2answers
316 views

Finding all intervals that match predicate in vector

I have a function find_all_intervals_below that iterates through a vector and finds all the index intervals of at least a given length where each element within the ...
4
votes
1answer
183 views

Reverse int within the 32-bit signed integer range

Problem Reverse digits of a 32-bit signed integer. When the reversed integer overflows return 0. Optimized code here. Feedback I'm looking for any ways I can optimize this with modern C++ ...
5
votes
1answer
68 views

Passing uint64_t from C++ to R: Hilbert Mapping - xy2d function

I have been working with Rcpp to perform a forward and backward Hilbert Mapping. Below is an implementation based on this code. My application is in genomics and I may be dealing with enormous ...
5
votes
3answers
788 views

Stack Interview Code methods made from class Node and Smart Pointers

Mainly looking for feedback on my use of smart pointers to implement a standard stack. For interview level production code I have also include a namespace and asserts to test my class, let me know if ...
5
votes
1answer
123 views

Quad Tree Implementation in C++11

The following source code is working Quad Tree Implementation in C++11. How can I simplify the source code but also allow the user to bring his own Point Class Implementation? ...
5
votes
1answer
82 views

wrapper for common subset of auto_ptr and unique_ptr API

I read an interesting old question on the Software Engineering SE about how to transition away from std::auto_ptr. So I wrote a wrapper around the common subset of <...
0
votes
0answers
17 views

Recursive data-types, binary tree, list-initialization

I have copied the techniques used by https://github.com/nlohmann/json to define a class BSTNode<T> which represents binary search trees and is possible to ...
4
votes
1answer
113 views

std::vector free list

I'm trying to implement a free list by using a std::vector as its growable buffer. The reason I made this instead of just adding/removing elements directly into a ...
6
votes
3answers
87 views

Program that outputs binary values of input

I am looking to simplify my main() function. The nested if statements contain four lines of the same code, and I'm unsure of how to refactor and simplify it. I was attempting to use booleans, which ...
2
votes
1answer
43 views

Queue Interview Code basic methods made from struct Node optimized

Using feedback from my previous implementation I'm writing a very simple Queue of struct Nodes with only these methods get_front(), get_back(), pop_front(), push_back(), and a ostream friend method. I ...
6
votes
1answer
120 views

std::string like compile-time const char* string

I want to write a very simple std::string like compile-time const char* string. I need to work with strings in the compiletime, just like with strings, I implemented basic functions. ...
1
vote
1answer
60 views

Finding index in list in C++

I need to find correct index in a array by comparing ranges. Here is my first try: ...
1
vote
2answers
68 views

shared_ptr basic implementation for non array types

This is an implementation to simulate the basic functionality of c++ shared_ptr. This doesn't provide features like custom deleter and make_shared(). I would really appreciate any feedback to improve ...
3
votes
3answers
116 views

Linked List Interview Code methods, runtime, and edge cases refactored

In my previous post I had a number of steps given to me from the accepted answer on how I can write more production ready code. In this post I want this code to be reviewed as near production code I'd ...
2
votes
3answers
101 views

Queue Interview Code basic methods made from struct Node

Thanks for all the feedback, I optimized the code here. Here I'm Writing a very simple Queue of struct Nodes with only these methods get_front(), ...
1
vote
1answer
76 views

Linked List Interview Code methods, runtime, and edge cases

Refactored code here I want to write a very simple Linked List with only 3 methods Append, Remove and Print. This is not for production and is to be treated as code that could be used in an interview ...
7
votes
5answers
791 views

Vector-transposing function

I profiled a library I'm writing that uses vector transposes and found that I am spending a good bit of time doing the following transpose. I am using a std::vector ...