Questions tagged [c++11]

Code that is written to the 2011 version of the C++ standard, sometimes known by its pre-publication name of "C++0x". Use in conjunction with the 'c++' tag.

Filter by
Sorted by
Tagged with
4 votes
2 answers
344 views

Class for locking shared disk directory

I'm writing an application to sync files between two directories. In order to prevent simultaneous access to the shared directory from several computers, I implemented blocking of the shared directory....
3 votes
2 answers
165 views

Multithreaded disk scan

I'm writing an application to compare and sync folders on a disks. Scanning the contents of folders is performed in separate threads. I wrote a class to manage scan threads. The main application class ...
4 votes
2 answers
297 views

First use of std::map in factors and prime factorization program

This is from an older question of mine that I decided to revisit: Simplifying and optimizing factors and prime factorization generator In that question, someone suggested I use an ...
4 votes
2 answers
2k views

Getting all possible letter combinations of a word

I wrote a simple algorithm for finding all possible letter combinations of a single word. I want to know if my code can be improved in any way, although I'm mostly interested in efficiency. You can ...
13 votes
6 answers
7k 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 ...
3 votes
1 answer
102 views

std::list reimplementation for practice

I used cppreference list to implement this simplified std::list. The CXX_STANDARD is 11. My questions are the usual: Is the ...
3 votes
1 answer
127 views

Improving execution time of physics, data acquisition triggering system simulation

Background I'm attempting to write a physics simulation code, one portion of which involves simulating the triggering system of some equipment. The equipment works as follows: environmental noise (...
7 votes
1 answer
1k views

Pet Shelter in C++

The provided code represents an implementation of a Binary Search Tree (BST) in C++, specifically tailored for a "Pet ...
4 votes
3 answers
1k views

O(NlogN) sorting algorithms in C++

The following code is my lab which focused on implementing any 3 known sorting algorithms out there. Since the professor gave us a choice to pick any of them and compare their execution time I chose <...
6 votes
3 answers
4k views

dynamic_pointer_cast for std::unique_ptr

dynamic_pointer_cast is only implemented for std::shared_ptr. I need the same functionality for unique pointers. The wrinkle is ...
3 votes
2 answers
126 views

Covid Data Base Hash Map in C++

This is a follow up question to Date Checking in C++ I have these two function prototypes: void CovidDB::add_covid_data(std::string const COVID_FILE) ...
8 votes
1 answer
4k views

Propositional Logic: Proposition Evaluator

We implement a C++ class Proposition that represents a (possibly compound) propositional logic statement made up of named atomic variables combined with the ...
4 votes
2 answers
4k views

Bidirectional map based on memory manipulation

This is a bidirectional map implementation that stores the values as pairs on the heap, and uses pointer arithmetic for efficient lookup. codepad link, may be easier to read ...
2 votes
2 answers
1k views

SmallVector - std::vector like container on the stack

SmallVector is almost same as std::vector except it keeps its data inside a large array. Similar to ...
1 vote
2 answers
139 views

A simple String class and its special member functions

I am learning the behavior of C++'s special member function, using a naive String class as example. (The code is modified from this tutorial) Here is the ...
3 votes
1 answer
3k views

Safely starting and stopping a thread owned by a class

If I have a class running its own thread, I almost always try to write it like the following, with the thread started by the constructor. The reason for this is that an object can never be constructed ...
5 votes
4 answers
594 views

RGB Image Utility Class

I am writing a utility class to store RGB images and do a few utility functions as a way to learn C++. ...
4 votes
3 answers
1k views

Inline visitor implementation for C++11

I've been looking at getting back into C++11 after a few years and came across the idea of implementing the 'inline' visitor pattern. The idea is that you can specify your visitor class locally in the ...
7 votes
2 answers
1k views

Chess Game with GUI in C++ using SDL2

Introduction So, I recently completed a chess game with a GUI in Python, using Pygame. Upon research, I learned that Pygame is built on SDL, and since I wanted to practice C++ more, I decided to code ...
5 votes
1 answer
103 views

Logarithmic random distribution satisfying RandomNumberDistribution concept

I provide logarithmic_distribution to satisfy the C++ RandomNumberDistribution concept implementing the PDF ...
1 vote
1 answer
72 views

Implementing function groups

I have recently decided to build an event library for the Arduino/ESP microcontrollers, the idea is simple - if an action happens, it invokes a function. In the code it requires holding a vector of ...
10 votes
3 answers
2k views

C++ code for a simple single header logging library

I have been working out on C++ code lately just for fun and decided to make a simple logger in it. The code works fine, but it would be great if someone more knowledgeable could point out any mistakes/...
6 votes
1 answer
7k views

Timeout watchdog using a standby thread

The simple but generic timeout class to be used watching for network connections, user input, filesystem events, and is intended to have a very simple interface specific to only our use cases (i.e. no ...
2 votes
2 answers
314 views

myhash - library with hash functions

I had a file with 2 hash functions (DJB2, NMEA0183), written in C-like way, e.g. something like this: ...
5 votes
2 answers
617 views

RAII POSIX process created by fork

By analogy with std::thread, I've written an RAII POSIX process: ...
2 votes
2 answers
201 views

Memento Pattern with abstract base classes and partial restoring only

Here I illustrate the use of the Memento Pattern to restore certain (but not all) data of a class that has data in abstract base classes. A Spellcaster has spells ...
15 votes
1 answer
1k views

C++11 Threadpool

I have developed a threadpool using the standard c++11 features and am looking for feedback. Right now I think the implementation is pretty solid, but as I recently learned about multithreading I'm ...
4 votes
1 answer
183 views

Growable vector on the stack with fixed capacity

Implements most (if not all) applicable member functions from std::vector and std::array Compatible with C++11, C++14, C++17, C++20 [] operator allows unchecked access, all other member functions ...
4 votes
2 answers
179 views

Dependency problem with field changes

The Observer Pattern is used here to notify changes in a Person's data. For example, when age changes, the value of can_vote() ...
3 votes
1 answer
2k views

Wordle game in C++

I am a programmer who likes making clones of games. Having completed a version of Wordle in Python, I challenged myself with making a version of it in C++. This includes a solver as well (add a flag -...
4 votes
1 answer
117 views

Entity component system for text-based console on Windows

I have written this code base on AsciiEngine. How can I improve this code? ...
3 votes
0 answers
229 views

Simple Win32 console library (mimicking almighty SFML) - follow-up

I'm trying to mimic the SFML library to be suitable for text-based games. The library called MSLIB in GitHub here. Here is a sample of the library implementation. It prints gray square onto the ...
3 votes
3 answers
2k views

Algorithm to add all lucky numbers under [N] to a Vector

A lucky number is defined as a positive integer whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. I need to check ...
0 votes
1 answer
417 views

What can I do better in my C++ serialization implementation?

I want to serialize a class Mango recursively. ...
5 votes
3 answers
3k views

Template Matrix Class: implemented some basic functionalities

Basically I have written a matrix class for addition, multiplication and scalar multiplication. I need your review of the class implementation below in terms of efficiency, memory consumption and new ...
7 votes
1 answer
8k views

Queue with std::vector

How can I improve this code? ...
2 votes
2 answers
29k views

A binary tree , its copy constructor and assignment operator

I implemented a binary tree in the following code. Its node's copy constructor and assignment operator should copy itself and all its descendents. Similarity a node's destructor should delete itself ...
3 votes
1 answer
109 views

Queue using circular linked list

I'm reading through Algorithms Fourth Edition by Sedgewick and doing some of the practice exercises in C++11 instead of Java. Exercise 1.3.29 is to write a Queue that uses a circular linked list, ...
8 votes
4 answers
3k views

Parallel factorial algorithm using std::thread

This code calculates the factorial of a number on multiple threads. My issue: it is only a little bit faster than the sequential version of it (and I think I know why, I just can't find a way to solve ...
4 votes
1 answer
2k views

Timer thread implementation

I've implemented a timer thread whose job is to call functions at a certain interval. The functions may be called multiple times if their interval > 0 millisec otherwise only one time. Even if the ...
1 vote
2 answers
4k 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 its ...
0 votes
1 answer
352 views

Count the number of objects created statically and dynamically in C++

I have written below program to count the number of static and dynamically created object of the class. ...
1 vote
0 answers
21 views

Return type-erased object to the caller, use typesafe cast in a subsequent call [closed]

Libraries might need to return "context" objects to the caller, and then require the same object in subsequent calls. In some cases, the user is not required to know what's the concrete type ...
1 vote
3 answers
2k views

Any bettter way to achieve this lookup table?

What I need: I need a lookup table. Once the keywords are all found, then the value of the std::unordered_map is returned.And I don't care about the sequence of the ...
2 votes
1 answer
570 views

Modify a string by identifying a substring, and replace it and the characters following it with a newly computed substring

I'm working on a string manipulation code in C++ for my internship project, where I have to find a substring within a string and essentially replace it and some characters following it with a newly ...
4 votes
1 answer
159 views

AEC-to-WebAssembly compiler in C++

Now that my new compiler is capable of compiling programs such as the Analog Clock in AEC, I've decided to share the code of that compiler with you, to see what you think about it. File ...
7 votes
4 answers
386 views

Safe Integer Library in C++

I've designed a single-file safe integer library in C++. It catches undefined behavior prior to integer overflows or underflows and throws the respective exceptions. I intend this to be portable, to ...
27 votes
2 answers
10k views

C++11 Any class

This is a polymorphic wrapper capable of holding any type. (It is loosely based on boost::any) In particular, this is useful when you want to store a ...
1 vote
1 answer
137 views

Connect Four in C++

This is a library that implements the logic of Connect Four. There's nothing related to graphics or user input here. This library is supposed to be integrated into any environment where one could run ...
0 votes
1 answer
102 views

Data Wrapper Class with Automatic Saving and Locked Read/Write Accessors

This is a wrapper for a synchronized data structure that: Saves periodically Keeps track of dirty flag automatically (set when a write access is requested) Maintains a lock on data Only allows access ...

1
2 3 4 5
35