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.

Filter by
Sorted by
Tagged with
0
votes
0answers
5 views

Dynamic array class in c++

So, as an exercise I wanted to write a dynamic array, like std::vector. I wanted to know if there are any things that could be done better or anything I did wrong. Thank you! ...
1
vote
1answer
43 views

Check if neighbors are active in spatially subdivided voxelization

I have a voxelization that I need to write out to a binary STL file. These voxels are inside a higher-level 3D grid, with each cell in the grid being made up of voxels. Individual cells may or may not ...
2
votes
1answer
55 views

Header only HTTP client library that is a wrapper around CURL

For learning purposes, I wanted to create a header-only C++ wrapper library around HTTP CURL functionality. At the moment the library only implements GET and POST, but I will add other HTTP methods ...
0
votes
0answers
51 views

Fast Stream Formatting Into String

I am trying to find a way to convert printable data types into a string in the fastest way possible. I originally read that a static variable of stringstream that ...
1
vote
1answer
62 views

Car Milage and Cost Calculating System based off menu selections (using a class)

I was wondering if anyone would be kind enough to review my basic c++ program. I'm a beginner programmer so was hoping to get feedback on how well I've used object oriented programming i.e. using a ...
2
votes
2answers
61 views

Find the next empty column on a chessboard [closed]

I was playing around with the "eight queens" problem, just to see how I could use C++ algorithms to write less code. I figured out a way to find the next unused column using ...
0
votes
0answers
47 views

Scheduling threads to run at a particular time

I was wondering if you could please comment on code quality, correct usage of c++17 constructs, stl/c++ compliant api, performance, or anything else that you might find relevant. Also do you think ...
0
votes
0answers
51 views

Merging rectangles

I am looking at some code that merges boxes: ...
3
votes
1answer
44 views

Timer for scheduling tasks in C++11

I have made a simple Timer class used for scheduling tasks. While defining the interface, I have followed the interface of a ...
4
votes
0answers
59 views

Tic Tac Toe with different level AI

I've already created a code in python here with almost the same logic: Tic-Tac-Toe with changeable board size (Part 1) Tic-Tac-Toe with changeable board size (Part 2) Here's the code in C++. As I'm ...
2
votes
1answer
84 views

Prim's Algorithm - Minimum Spanning Tree

I have implemented Prim's Algorithm from Introduction to Algorithms. I have observed that the code is similar to Dijkstra's Algorithm, so I have used my Dijkstra's Algorithm implementation. Please ...
2
votes
1answer
111 views

Multi-threaded LinkedList Implementation

I am learning to write a multi-threaded linked list class implementation with basic functionality such as push to front or back, ...
1
vote
1answer
55 views

How well does this ECS implementation follow these principles?

I'm currently learning about Entity-Component-System architecture Data-Driven design as a way to counter bad OOP design and optimize data fetching as a CPU friendly operation. I'm trying to write a ...
2
votes
2answers
67 views

Operator overloading in C++ to manage playlists of music

I've built this little C++ program just to take some rust off my coding skills since it's been ages since the last time I coded something. The purpose is to organize my music, so I've built the ...
3
votes
1answer
67 views

A runtime benchmark for multiple programs using the Python subprocess module

I would like feedback on my benchmark script. What's another method for benchmarking that might be better/easier? Overhead I've found that subprocess.run has an ...
7
votes
3answers
198 views

Optimizing Conway's Game of Life in C++

How could I further optimize my implementation of Conway's Game of Life? And how would you critique my current strategies? I'm taking a C++ optimization class, the deadline has passed and my ...
1
vote
0answers
26 views

Overloading both for (non) constant access [closed]

I'd offer a couple of iterator accesses to the class member, both constant and non-constant. I came to the following solution, but it seems to me far more verbose than needed. I'd like somehow to ...
4
votes
0answers
95 views

Polymorphic deleter for unique_ptr

There is a basic difference in the way C++ manages the deleter for std::unique_ptr and std::shared_ptr, mainly for allowing ...
10
votes
1answer
472 views

C++ Standard-Thread Threadpool

I have written a small and simple ThreadPool class for rather simple multithreading applications. The Threadpool class manages ...
5
votes
1answer
97 views

Wu-Manber algorithm for multiple pattern matching in C++

I'm trying to implement the Wu-Manber algorithm (http://webglimpse.net/pubs/TR94-17.pdf). From my understanding, the algorithm basically does string matching using a hash table-based approach with ...
4
votes
2answers
75 views

Random line remover from file

This asks the user for the file name and the number of lines they want to remove. It then stores each line into a vector. A dynamic array is used to hold the random line numbers (generated by random ...
3
votes
1answer
160 views

Consistent and extendable way to store data for session

I am making session store which will store some data and read some, This session store can store multiple data( SessionInfo) to the map. Data Structure ...
4
votes
1answer
73 views

Generating words sounding similar to the ones given in a wordlist — Core program only

This topic is about the same project as this previous one. I think posting the full project was a bit too much, so here I post again only three functions, which are the core of my program, with a few ...
1
vote
2answers
112 views

Container of data structure: a better solution to an interview task

A shipping company has a warehouse of Containers. Basically, a Container is a data structure with the following fields: price commercial campaign id a list of possible shipment countries (empty list ...
2
votes
1answer
66 views

Token class implementation

I have implemented Token and FieldToken classes as part of my project and would like to hear some suggestions for improvement. ...
0
votes
1answer
77 views

Insert elements into a map container

I am inserting elements into the map container. For this I am using the same statements multiple times in the below function. Is there any way I can write a generic function for this? So that even at ...
3
votes
1answer
55 views

How to optimize the code snippet which has several calls to find method that is to read files and load them into the map?

I wrote a functionality to read files and load them into the map m_fileParams. Then I am searching the specific keys in the map container using ...
1
vote
0answers
29 views

Limit framerate [closed]

I have made this class. Not sure if there is anyway to make it better. It seems to work alright half the time, but other times frames jump up higher then the set limit around 30frames more if i set it ...
2
votes
0answers
32 views

C++ Sql-like base operating on csv files

I implemented very constrained trivial implementation of sql querries operating on user files (in csv format). Where possible i tried to use modern C++ features. The fancy goal is to serve MySql ...
3
votes
1answer
66 views

Multithreading Ticket class to wait for parallel task completion

I've implemented a "Ticket" class which is shared as a shared_ptr between multiple threads. The program flow is like this: parallelQuery() is called to start a new query job. A shared instance of ...
4
votes
1answer
56 views

Reading from a stream but reserving N bytes at the end of stream

What I'd like to do is read data from a stream (like ifstream::read), but reserve N = 4 bytes from being returned. The last 4 bytes of the stream are not part of the data itself, but are metadata. In ...
3
votes
1answer
89 views

Stereo image matching implementation in Halide

The authors of this paper compute support_points of a 900×700 image in 118 ms. I have implemented their algorithm below in Halide. In my algorithm, the nested for loops over length and width iterate ...
3
votes
1answer
79 views

Producer consumer with threads and using boost ring buffer

I have two threads, one is the producer and other is consumer. My consumer is always late (due to some costly function call, simulated in below code using sleeps) so I have used ring buffer as I can ...
2
votes
1answer
129 views

generic flyweighting function

I made this little function for flyweighting any type that has operator<. I followed the convention of make_unique and ...
6
votes
1answer
95 views

A straightforward method for computing the Binomial probability mass function

I've been writing up code to test an alternate way of calculating the Binomial probability mass function. The Binomial random variable is the number of heads out of N coin tosses with coins that have ...
1
vote
1answer
71 views

A minimalistic kind of read-copy-update class

This is a very simple read-copy-update (RCU)-inspired synchronization class: ...
1
vote
1answer
67 views

Boolean class using shared referenced memory

To improve my knowledge I am trying to make a bool class from scratch, or derivative of. I am using MinGW g++11 compiler on a Windows 7 laptop. ...
4
votes
0answers
156 views

C++ simple inter-process notification system

I needed to synchronise several processes, so I developed this ipn::Notifier class that uses a mutex+condition variable stored in shared memory to notify all ...
3
votes
1answer
69 views

Predefined values for some values in a template function like with a #define macro (e.g. template<int foo, typename bar>)

I want to overload an operator (e.g. operator<<) with different types, but also change only 1 or 2 values in the function itself. I want to get some fancy output of a vector with the primitive ...
5
votes
3answers
1k views

A STL-like vector implementation in C++

I'm implementing a STL-like vector with the essential functionalities. I would like to know what is good in this code and what is bad. In terms of everything (memory usage, functions implementations, ...
2
votes
0answers
365 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
149 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
2k 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
60 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
134 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
124 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
122 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
136 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
88 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
156 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: ...