Stack Exchange Network

Stack Exchange network consists of 174 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.

3
votes
1answer
87 views

value_ptr<T> - a C++11 header-only, deep-copying smart pointer that preserves value semantics for polymorphic and undefined types (updated)

My previous iteration was here. I've since finalized the concept as described in the title, and would appreciate any feedback GitHub Link Introduction: ...
7
votes
4answers
2k views

Most efficient way to find an entry in a C++ vector

I'm trying to construct an output table containing 80 rows of table status, that could be EMPTY or USED as below ...
6
votes
1answer
115 views

Trie Implementation in C++11

I implemented a Trie in C++11, but I am not sure if my usage of struct and std::unique_ptr, and ...
2
votes
0answers
34 views

Rehashing a hash table in c++ with quadratic probing

The code below is my attempt at trying to create a hash table. I'm currently stuck with the rehash function as I think it's not efficient enough (I believe it's O(n^2). I'd be grateful if someone ...
0
votes
1answer
66 views

Matrix arithmetic operations

I am currently attempting to implement Matrix Math for another project I am working on. However, I am not sure whether this implementation will work. Can someone please tell me if there are any ...
3
votes
2answers
43 views

Mockable clock meeting std::chrono TrivialClock requirement and interface

I'm using the time for e.g. ping and timeout calculation as well as animations in a game. So my (big) codebase uses std::chrono::steady_clock::now() in many places. ...
5
votes
3answers
118 views

Singly-linked list data structure implementation

This code seems to work correctly. I would appreciate any comments on how to improve the code, e.g. readability, algorithms, const-correctness, memory, anything else I am forgetting? Also, for the ...
4
votes
0answers
64 views

Trie (dictionary tree) data structure implementation: insertWord, printAllWords, searchPrefix, deleteWord, deleteTrie

This Trie implementation works, however, I would like to get an advice on how to improve this code. Any advice is appreciated: functions implementation, memory management, modern C++ usage, const-...
0
votes
1answer
25 views

Interval scheduling wrapper for Mongoose-OS C timers

I've written a library for Mongoose-OS C mgos_timers. I wanted to write a wrapper to take advantage of the full potential of C++ lambdas. The original C timers ...
4
votes
2answers
68 views

Modeling a parking lot

Here is my code for the design of a parking lot in C++. The following assumptions are made. Referred from Geeks for Geeks The parking lot has multiple levels. Each level has multiple rows of spots. ...
4
votes
2answers
59 views

ROS node to control Dynamixel servo motors

This code is for a ROS (http://www.ros.org/) node that controls a pair of servo motors (referred to in the code as grippers) that can be controlled individually or together. When they are controlled ...
-2
votes
3answers
73 views

Translate a day in year to month and day 2nd method

Take an integer representing a day of the year and translate it to a string consisting of the month followed by day of the month. For example, Day 32 would be February 1. I've already submitted my ...
1
vote
1answer
36 views

Implementing a random distribution satisfying RandomNumberDistribution concept

Improving on this code review, I provide logarithmic_distribution to satisfy the C++ RandomNumberDistribution concept implementing the PDF ...
1
vote
1answer
76 views

Translate a day in year to month and day

Take an integer representing a day of the year and translate it to a string consisting of the month followed by day of the month. For example, Day 32 would be February 1. This is what I came up with. ...
6
votes
2answers
542 views

Moving elements satisfying a predicate from one container to another

I've implemented a C++ algorithm that moves elements satisfying a given unary predicate from one container into the other, deleting them from the input container. This is my implementation: ...
4
votes
1answer
106 views

Reverse C++11 range-based for loop

I wrote this snippet: ...
7
votes
2answers
197 views

Unit conversion program into metre and stored input

I was curious as to how I'd be able to make this much clearer to read because from my perspective I understand what does what but how does it look to a third party? Also how are my object / method ...
1
vote
0answers
63 views

C++ embedded application to control a light with a timer

I enhanced the my daughter's bed light to IoT. Specifically I can turn the light on/off remotely and there is a timer & alarm function. All of this is implemented with a Particle Photon. This ...
1
vote
1answer
44 views

Implementation of a class that runs a child process with timeout using boost process in async mode

In the following code, I am trying to implement a program that runs a process and returns its return code, stdout and stderr. It ...
3
votes
1answer
47 views

Time series dataset with temporally enforced object lifetime

The purpose of this class is to have that can maintain data set where the samples contained within the set have an expiry time. Samples are inserted in chronological order. In an attempt to memory ...
3
votes
1answer
128 views

Search for rows in a 2D array that contain a given sequence

I have a 2d array of m * n dimension (m and n can vary from 1 to 100000). The following snippet of code checks if the sequence exists in the row and stores the index if it exists. The time taken by ...
6
votes
3answers
121 views

Progress bar wrapper class in C++

I've recently written a simple progress bar class in C++ to mimic usage of similar libraries I've used in Python. The idea is to take some iterable container (e.g. ...
2
votes
0answers
90 views

Yet Another Non-Intrusive Reference Counted Smart Pointer Implementation

I needed a reference counted smart pointer for my project, and for some reason early in my project, I decided that I did not like the std::shared_ptr. I can't ...
3
votes
1answer
72 views

Monitor asynchronous tasks, tracking their running times

Scenario: I'm getting requests through a (thread-safe) queue. Each request then needs to be handled in a separate thread. There is a chance that the function (which is actually calling a Java-program ...
10
votes
3answers
294 views

Implementation of Linux cp in modern C++

This is my simple implementation of the Unix cp command. It is a C++ program but makes use of some of the lower level C library I/O functions. Any suggestions for ...
11
votes
1answer
82 views

CodeVita challenge: forming the latest valid datetime in a year using some given digits

After answering someone's Code Review question, I decided to tackle a sequel: Given an input consisting of 12 non-decreasing single digits separated by commas, form the latest valid date time in a ...
7
votes
2answers
130 views

Vector-like type for type that can't be moved or copied

I was in need of a vector-like type that could hold types that couldn't be copied or moved so I implemented one. I tried to make it similar to standard STL containers. Is the use of the macro to ...
3
votes
1answer
462 views

Simple rwlock implementation in c++11

For answering this question of stackoverflow I have written the code https://stackoverflow.com/questions/12033188/how-would-you-implement-your-own-reader-writer-lock-in-c11 Can someone review it - ...
1
vote
3answers
78 views

Stack implemented with linked list

I have looked at some previous posts and changed my code accordingly. Do you have some suggestions about my current code? Here are my specific questions: What should ...
11
votes
3answers
2k views

Multithread to print odd and even numbers

I recently started on C++ multithreading. Here is my code to print odd and even numbers in two different thread. Can somebody please review this code? ...
1
vote
0answers
91 views

A simple and efficient packet frame encoder/decoder

I have written a simple packet-framing class, for converting un-encoded 'packets' into encoded/delimited 'frames,' to be sent over a P2P serial connection. The functionality is based on the RFC 1662 "...
5
votes
2answers
144 views

Implementation of deque

What can be simplified, altered, or implemented differently? I would like to know if there's a way to further improve this code. ...
3
votes
1answer
171 views

Transforming from spherical coordinates to Cartesian coordinates using Eigen

I need to transform the coordinates from spherical to Cartesian space using the Eigen C++ Library. The following code serves the purpose: ...
7
votes
2answers
517 views

Code to track execution time for each function in a class

Problem Statement I want to be able to look at log files and figure out where the bottlenecks are in the code in an easy/visual way rather than trying to do the math every time I make some ...
7
votes
3answers
285 views

Implementing numerical integration

I have this C++ code that implements a rectangular numerical integration. It evaluates the \$K\$-dimensional integral $$\int_{u_K = 0}^{\gamma}\int_{u_{K-1} = 0}^{\gamma-u_K}\cdots\int_{u_2}^{\...
-1
votes
2answers
74 views

Function to perform an arithmetic operation on two numbers and print the result [closed]

I have written this function (in C++) to apply an arithmetic operation on two numbers and print the result. ...
7
votes
4answers
619 views

reinterpret_cast vs bit shifts for extracting 32-bit integers from bytes, with either endianness [closed]

I've written some simple helper functions that read data types from a vector of bytes (binary files) and having a tough time deciding which route to go. Method 1 : reinterpret_cast ...
6
votes
1answer
115 views

Generic Producer-Consumer in C++11

I wrote the following simple 1 producer - 1 consumer problem, in attempt to learn some C++11 threading / generics. ...
4
votes
0answers
108 views

Recreated Microsoft's Console Registry Tool's query functionality in C++ (REG.exe)

I decided to try and recreate Microsoft's REG.exe query functionality."Reg.exe" is Microsoft's Console Registry Tool. I used Microsoft's documentation of "reg query" to recreate it's functionality ...
6
votes
1answer
164 views

Generic Skip list implementation in C++ Version 3

This is a follow up of Non generic Skip List implementation in C++ Version 2 If you don't know what a Skip list is: https://en.wikipedia.org/wiki/Skip_list I tried to incorporate as much ...
4
votes
3answers
279 views

Simple trie class in C++

I would be very grateful to get some thoughts on this toy-implementation of a trie that I wrote to practice my C++. Some questions I have: Is my create member ...
3
votes
2answers
182 views

Skiplist implementation

This is a version of my skip-list implementation. In my project I store my custom class that is similar to a pair of blobs. I replaced my custom class with int. At ...
7
votes
4answers
298 views

Remaking std::to_string in C++ with UDLs (User Defined Literals)

I would like some feedback on what I should change with my semi remake of std::to_string with UDLs (user-defined literals). This is compiled and working on linux ...
12
votes
6answers
3k views

Modern Vector implementation

Please give me some feedback on my attempt at a vector. I wanted this to be the lowest level concept of a vector that I'm using, so I'm primarily concerned with speed, and I would build wrappers ...
7
votes
3answers
2k views

Simple Encryption for Strings

I have written this code for practice. Here we will enter the number by which we want to shift alphabets. For eg. Enter by how many numbers you want to shift alphabets: 4 Enter string: ...
5
votes
2answers
151 views

A simple lock-free queue for work stealing

I am currently reading the book C++ Concurrency in Action by Anthony Williams. In chapter 9, he implemented a lock-based work stealing queue and mentioned it is possible to implement a lock-free queue ...
4
votes
1answer
182 views

Follow up: CPU Scheduling Algorithm (SJF, priority & Round Robin)

After implementing suggestions from my previous questions about SJF, priority and round robin. Here I have scheduling.h which contains a struct ...
1
vote
2answers
829 views

Round Robin Scheduling Algorithm

Here I have implemented code for Round Robin CPU Scheduling Algorithm. scheduling.h header file is also used in Shortest Job First Scheduling Algorithm and Priority Scheduling Algorithm, so it ...
2
votes
3answers
1k views

Singleton class and correct way to access it in C++

I'm currently trying to implement the singleton pattern in C++. After reading about it for a while now, it seems like there are a really large amount of different ways to do this. Is the way I ended ...