2022 Developer Survey is open! Take 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
0 votes
1 answer
24 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 ...
user avatar
1 vote
1 answer
68 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 ...
user avatar
  • 993
0 votes
1 answer
37 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 ...
user avatar
3 votes
1 answer
52 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 ...
user avatar
1 vote
1 answer
68 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 ...
user avatar
2 votes
1 answer
87 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. ...
user avatar
0 votes
1 answer
56 views

Decorator Pattern with member functions

Motivation: without SaveDecorator, we would have to write: ...
user avatar
  • 1,089
0 votes
0 answers
29 views

AI for OpenTTD - Decision Engine: Is this an appropriate use for the state pattern and raw pointers to states?

I'm writing an AI in C++ for OpenTTD. If you'd like to run it yourself, it's on Github here: https://github.com/marlonsmith10/empire_ai. This class is the decision engine. It will be responsible for ...
user avatar
0 votes
0 answers
30 views

AI for OpenTTD - Road Station Builder

I'm writing an AI in C++ for OpenTTD. If you'd like to run it yourself, it's on Github here: https://github.com/marlonsmith10/empire_ai. This class is the road station builder. It takes in a path ...
user avatar
1 vote
1 answer
69 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. ...
user avatar
  • 1,089
1 vote
2 answers
62 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-...
user avatar
  • 141
2 votes
2 answers
95 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. ...
user avatar
  • 403
2 votes
1 answer
71 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 ...
user avatar
4 votes
2 answers
668 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. ...
user avatar
2 votes
1 answer
69 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,...
user avatar
  • 1,925
3 votes
2 answers
113 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 ...
user avatar
  • 265
2 votes
2 answers
408 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 ...
user avatar
  • 31
1 vote
1 answer
133 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: ...
user avatar
6 votes
2 answers
478 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 ...
user avatar
  • 64.1k
4 votes
5 answers
1k 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: ...
user avatar
5 votes
2 answers
322 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. ...
user avatar
  • 145
2 votes
1 answer
127 views

watchdog for c++11

I created a watchdog/notifier in C++ and wanted to make it better so it could be used by multiple people. The idea is that there is a timer class and event. client create events and pass a lambda ...
user avatar
0 votes
1 answer
156 views

The Abstract Factory design pattern as a Database Operations program

File - DatabaseOperations.h This file contain classes representing database operations for three different types of databases (relational, document based and graph based) like establishing connections,...
user avatar
2 votes
3 answers
126 views

Factory Method Design Pattern Implementation as a Coffee maker program

File: InfoFactory.h contains four classes. CaffienatedBeverage is an Abstract class with one pure virtual function Name. It ...
user avatar
3 votes
3 answers
641 views

Connect to telnet server

I've just started to learn C++. I have this class and I don't know where to put the following two lines because of the catch: delete[] chost; delete[] cport; I ...
user avatar
3 votes
2 answers
257 views

An implementation of the PIMPL idiom [closed]

I would like to ask you to verify the following implementation of the PIMPL idiom. In this dummy implementation the stream is read into a string. X.h ...
user avatar
1 vote
0 answers
63 views

template Matrix class with Static or dynamic size

I started implementing the folowing Matrix class in order to get a better understanding of templates classes in general. For now, it lacks a lot of features, it does very basic things: addition ...
user avatar
  • 11
0 votes
0 answers
32 views

Refactoring a simple ZeroMQ Server

I have a simple ZeroMQ client from zmqClient. I have refactored the code and done the following things. Created a class ZmqServer and added member variables and methods. Added a Server thread, using ...
user avatar
  • 161
2 votes
1 answer
47 views

Decoupling receiving data and processing data by passing callback and shared_ptr

Sorry for my poor English. I want to decouple receiving data and processing data, this is the demo code: ...
user avatar
  • 145
3 votes
2 answers
295 views

C++11 ThreadPool implementation

A new version of this code based on the provided advice can be found here. Latest improvement is found here. I made a simple ThreadPool implementation in C++ using ...
user avatar
3 votes
1 answer
251 views

Conditional Output Streaming in C++

I stumbled into an idea for creating a simple class that would entirely avoid streaming of any data unless some condition is met. The idea here is that a ...
user avatar
13 votes
1 answer
1k views

Simple NAPI wrapper around self written C++ msgpack, horrible performance

I have written a relatively small msgpack implementation in C++, with performance that is not too bad, so I decided to write a NAPI wrapper around it, but the performance is just horrible. I am ...
user avatar
  • 233
2 votes
1 answer
238 views

Simple Rock Paper Scissors

I made a Rock Paper Scissors game. It works fine but I would like to know how can I improve it further. ...
user avatar
  • 3,248
7 votes
6 answers
3k views

C++ implementation of depth-first search

I got the C++ implementation of depth-first search (DFS) from here and made slight modifications to it. The modified code is as follows: ...
user avatar
  • 425
0 votes
0 answers
56 views

Optimizing matrix vector multiplication with keyword "register" and unsafe pointer arithmetic

I know this piece of code is quite strange, but it does its job very well performance-wise , reducing the running time of a very computation intensive operation by 3 - 5 times without using a better ...
user avatar
2 votes
1 answer
1k views

dynamic_pointer_cast for std::unique_ptr

dynamic_pointer_cast is only implemented for std::shared_ptr, I need it for unique pointers. The wrinkle is that dynamic_casting ...
user avatar
8 votes
3 answers
1k views

C++ Creating custom vector

I am new to C++ and Data structures, so I have started writing a custom vector as a practice. Please provide critique and advice. I know it is quite long, so thank you very much in advance. I just ...
user avatar
2 votes
3 answers
194 views

LRU Cache Implementation in C++

I am learning C++ by implementing small design problems. I have tried to implement LRU cache and the implementation that I have attached here works fine. However, I am not sure whether my code is in ...
user avatar
6 votes
2 answers
911 views

shared_ptr and make_shared implementations (for learning)

Recently, I've been going through Scott Meyer's Effective Modern C++ and found the discussion on shared_ptr really interesting. I also watched Louis Brandy's ...
user avatar
  • 123
1 vote
1 answer
59 views

Household Outgoings Calculator (OOP)

I would really appreciate feedback on my OOP Household Outgoings calculator. My objective is to develop in OOP. Have I used good OOP techniques? How can I improve on it? And anything else you might ...
user avatar
1 vote
1 answer
58 views

generating stochastic coloured noise for many oscillators

I have a system of n oscillators which oscillate with time. To each of these oscillators I am adding a fluctuating coloured noise term with a different seed for each oscillator. Here is my code for ...
user avatar
1 vote
1 answer
52 views

Priority scheduling algorithm using std::vector

I'm learning priority scheduling algorithm and trying to implement it using std::vector. But the current performance of my code that's partially implemented is not ...
user avatar
  • 247
9 votes
1 answer
9k views

Deck of Cards written in C++

I created a deck of cards that I used in a BlackJack game. I stripped out my black jack logic and left just the Deck, card and minimum dealer. The deck class is there because I want to create ...
user avatar
2 votes
1 answer
248 views

Random index generator in C++

I have a training dataset from which I want to draw samples in a random fashion such that all samples are used before getting randomly shuffled again. For this reason I implemented a simple random ...
user avatar
  • 1,003
0 votes
1 answer
54 views

C++ Error/exception handling [closed]

I know the following code are horrible, so I'd like a review. Criticism are welcome. I want to know what went wrong, and how I can avoid the same mistake in the future. Version 1 ...
user avatar
7 votes
1 answer
308 views

Modular synthesizer framework for C++

While working on a much more complicated audio application, I was thinking about modular synthesizers, and whether it could be made simple to build a C++ application that implemented a modular ...
user avatar
  • 32.6k
2 votes
1 answer
83 views

An Implementation of Two Dimensional Plane as Monochromic Image Container with std::unique_ptr in C++

I am trying to implement a monochromic image container with std::unique_ptr. The example usages The example usages is as below. ...
user avatar
  • 3,302
13 votes
5 answers
2k views

Simple dataset class in C++

As part of my training, I implemented a dataset class in C++ that allows me to create synthetic datasets to get more familiar with features that C++ offers such as object oriented programming. This ...
user avatar
  • 1,003
2 votes
2 answers
251 views

My String Class

Here's my very basic String class. This is my first attempt, to try to design and write a basic String class in C++, without using the absolute new features provided by newer C++. ...
user avatar
  • 135
7 votes
2 answers
823 views

Using c++11 random header to generate random numbers

I'm new to programming. I have a question regarding the usage of c++11 random header to generate random numbers. I tried to learn it, but was unsuccessful. Recently, I've tried the following approach ...
user avatar

1
2 3 4 5
35