Skip to main content
Share Your Experience: Take the 2024 Developer Survey

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
3 votes
1 answer
40 views
+50

Generic overloading bitwise functions to manipulate the enum type

Thanks to G. Sliepen, who gave me a lot very meaningful & useful advice on my implementation about overloading bit operators for a special scoped enum. Now I have modified the code snippet to ...
John's user avatar
  • 323
-4 votes
0 answers
45 views

Two body collision written in SFML [closed]

This program shows two objects that can be controlled with arrow keys, It's 569 lines. I have an 8 core CPU and this simple program takes around 30% of my CPU. I don't understand if SFML is causing ...
Resfe's user avatar
  • 1
4 votes
1 answer
657 views

Using builder pattern and facade pattern in real project

The code below is used to upgrade the firmware of three different types of cameras. I am not good at design patterns. I wonder if it is suitable to use builder pattern and facade pattern here. Since ...
John's user avatar
  • 323
2 votes
1 answer
50 views

Overloading bit operators for scoped enum

The code snippet is used to record the status of several cameras. Since the enum class MODULE_ENABLED should not be used by the customers directly, I marked it as <...
John's user avatar
  • 323
4 votes
2 answers
178 views

A simple text editor

I just have learned the Command Pattern carefully. I try to use this pattern to implement a simple editor. Some code may need some improvements, say the instance of ...
John's user avatar
  • 323
4 votes
1 answer
308 views

c++ quicksort pivots

Is this code for quicksort using the first index as a pivot correct? Also if I want to use the last or middle index as a pivot how would the whole code change? ...
Kqehzo's user avatar
  • 41
5 votes
1 answer
234 views

C++ extended switch for any class

Was thinking about extending the C switch beyond integers. Here is what it came to - will gladly accept any suggestions for improvement. Note: "Any class" in the title is not quite correct - ...
johngo's user avatar
  • 51
4 votes
2 answers
382 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....
Andrey Epifantsev's user avatar
3 votes
2 answers
187 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 ...
Andrey Epifantsev's user avatar
3 votes
1 answer
124 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 ...
Abner's user avatar
  • 39
3 votes
1 answer
130 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 (...
MomentumEigenstate's user avatar
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 ...
I_throw_but_dont_catch's user avatar
4 votes
3 answers
2k 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 <...
I_throw_but_dont_catch's user avatar
3 votes
2 answers
135 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) ...
I_throw_but_dont_catch's user avatar
1 vote
2 answers
147 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 ...
Lion Lai's user avatar
  • 297
3 votes
1 answer
8k 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 ...
jezza's user avatar
  • 205
5 votes
4 answers
960 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++. ...
jigglypuff256's user avatar
7 votes
2 answers
2k 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 ...
cold10's user avatar
  • 469
1 vote
1 answer
76 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 ...
Mark Tikhonov's user avatar
10 votes
3 answers
3k 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/...
Acedev003's user avatar
  • 111
5 votes
2 answers
627 views

RAII POSIX process created by fork

By analogy with std::thread, I've written an RAII POSIX process: ...
jezza's user avatar
  • 205
2 votes
2 answers
223 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 ...
prestokeys's user avatar
  • 1,371
4 votes
1 answer
234 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 ...
AdamF's user avatar
  • 43
4 votes
2 answers
185 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() ...
prestokeys's user avatar
  • 1,371
3 votes
1 answer
3k 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 -...
cold10's user avatar
  • 469
0 votes
1 answer
508 views

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

I want to serialize a class Mango recursively. ...
James_sheford's user avatar
3 votes
1 answer
125 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, ...
Marlon Smith's user avatar
4 votes
1 answer
3k 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 ...
Daya Shanker Prasad's user avatar
0 votes
1 answer
534 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. ...
Naveen Gupta's user avatar
1 vote
0 answers
24 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 ...
irishaccent's user avatar
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 ...
John's user avatar
  • 323
2 votes
1 answer
852 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 ...
VMachar's user avatar
  • 29
1 vote
1 answer
145 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 ...
Gabriel's user avatar
  • 1,053
0 votes
1 answer
115 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 ...
CaptainCodeman's user avatar
3 votes
1 answer
273 views

Lock-free, thread-safe trie container

This is a Trie data structure for mapping strings to integers or pointers in O(n) time. Based on the idea that we never delete anything from the container, we can perform concurrent read/write ...
CaptainCodeman's user avatar
1 vote
1 answer
399 views

Low-Latency Multithreaded Logger

My goal was to have a logger that does the blocking file I/O in a separate thread. A few notes: I made it a singleton rather than having a global "logger" variable, or a bunch of loggers ...
CaptainCodeman's user avatar
2 votes
1 answer
339 views

Leaky Bucket Algorithm with no Queue

Basic implementation of a leaky bucket, the idea is you call it by saying I will allow e.g. 5 login attempts per 60 seconds. ...
CaptainCodeman's user avatar
0 votes
1 answer
326 views

Decorator Pattern with member functions

Motivation: without SaveDecorator, we would have to write: ...
prestokeys's user avatar
  • 1,371
1 vote
1 answer
122 views

Memento Pattern between sister classes

The following is my usage of the Memento Pattern when one class uses the copy constructor of a sister class (a separate derived class of the base class) and wishes to revert to the previous class. ...
prestokeys's user avatar
  • 1,371
1 vote
2 answers
261 views

Simple terminal TicTacToe

Coming from JavaScript, I needed to learn C++ recently, so I thought a great way to start is to create a simple terminal-based tic-tac-toe game. I encountered some difficulties especially with multi-...
code's user avatar
  • 149
3 votes
2 answers
981 views

Accessing multiple dynamic libraries with the same extern C methods

I have multiple pre-compiled dynamic libraries that use the same extern "C" function names. The functions can behave differently for each dynamic library. ...
Greg's user avatar
  • 443
2 votes
1 answer
206 views

C++ template and inheritance - Generic Sqrt Decomposition

So I tried implementing a easily extendable solution for Sqrt decompostion, I deduced that only identity value, operation and block update logic change and rest of the code is same. So i created 3 ...
Abhay Raj Singh's user avatar
4 votes
2 answers
1k views

Custom implementation to provide an immutable range of a vector without copying it

Edit: A new and improved version can be found in this question, based on the feedback! I needed to pass a const reference to part of a std::vector without copy. ...
Dávid Tóth's user avatar
2 votes
1 answer
248 views

A proxy class as a generic replacement for getters and setters v2

Have you ever written proxy objects, instead of using a setter and a getter method? In that case, I'm interested in your opinion on the following design for a templated proxy. This is a second version,...
einpoklum's user avatar
  • 2,015
3 votes
2 answers
266 views

C++11(14/17/20) Thread Management

I'm implementing something of a thread janitor in modern C++. What I've got works, and while it's not organized in the way I'd like yet, I'd like some feedback on the fundamentals. Thank you in ...
pdm's user avatar
  • 307
2 votes
2 answers
535 views

How to avoid excessive for loops in C++ [closed]

I have been trying to write a small test program and I was trying to think of any potential optimization I could do, especially if there is any chance to avoid some of the for loops. The program has ...
Brian's user avatar
  • 31
1 vote
1 answer
499 views

Win32 UI with tabs and buttons

I am making a UI library for the fun of it, and decided to use move semantics instead of pointers with new/delete. Everything is working, but I am not satisfied. Given this code: ...
Shigoto Shoujin's user avatar
7 votes
2 answers
5k views

Time duration conversion with units

I recently was asked to upgrade some C++11 code to add a feature by which the user can set a time duration from the command line of the program. The requirement was to have a default time of 1500 ms ...
Edward's user avatar
  • 66.4k
4 votes
5 answers
2k views

C++11 Custom Vector Implementation

This was my solution to an interview question: Q: Implement an std::vector style container (does not have to be exactly compatible) with a fixed buffer and the following requirements and restrictions: ...
Dávid Tóth's user avatar
5 votes
2 answers
2k views

C++ template class to calculate CRC

Here is a template class to calculate various CRC checksums. I go out my way to achieve a good C++ encapsulation for a C style code . Any advice or suggestion is welcome. ...
John's user avatar
  • 323

1
2 3 4 5
35