Questions tagged [c++]

C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. This tag should be used for any question which requires knowledge or expertise with the C++ programming language. This is a general tag which is used for any of the C++ language standards (C++98, C++11, C++17, etc.). The question should identify the compiler being used, the operating system, and which of the C++ standards is being targeted.

734 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
16
votes
0answers
771 views

Autotools detect C++ language standard support

I have been updating my build tools to optionally use autotools (autoconfig/automake/libtool etc.). As part of this change I have written a couple of M4 macros. This not being something I have done ...
14
votes
0answers
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 ...
11
votes
0answers
726 views

A polymorphic callable wrapper for any callable

I recently answered a question that had an interesting problem statement (I've slightly modified the wording): I have an abstract class A which is base for the ...
11
votes
0answers
179 views

Parser for a custom scene definition format for a raytracer

For a raytracer I’ve been writing with a classmate, we use a custom scene definition format that allows specifying shapes, composite shapes, materials, lights, cameras and transform and render ...
10
votes
0answers
367 views

C++ Parsing with chain of responsibility

The task was to create the parser for the string input, that would return the std::vector< int > of parsed numeric results and the type of given input (e.g. numbers, division by zero error, out of ...
8
votes
0answers
421 views

Hunt the Wumpus GUI (FLTK)

I used the code from the text based hunt the wumpus game discussed here: Text based game “Hunt the Wumpus” Version 3 to create a gui Version based on excercises from PPP by Stroustrup. For the GUI i ...
8
votes
0answers
1k views

Small Virtual Machine executing its own byte-code

I want present to you my little Virtual Machine. It nothing really sophisticated. It is an stack only virtual machine with the exception for some 'global' variables which i would count as registers ...
8
votes
0answers
1k views

Unique Function, a move-only std::function replacement

The Unique Function is supposed to be able to replace std::function in most situations where you do not need to be able to copy the functions, just move them. This ...
8
votes
0answers
489 views

Simple, intuitive and (hopefully) safe EventDispatcher

For my own game engine I need an event system. I tried to avoid the single-huge-enum-approach for minimizing compile times. The BasicEventListener is the (...
8
votes
0answers
275 views

C++ constexpr trampoline

For fun, I implemented a trampoline function for C++ constexpr functions, since the recursion limit for constexpr functions is ...
8
votes
0answers
292 views

.NET DLL Injector in C++

I built a DLL Injector with User-Interface. The program lists all processes, the user chooses one of them and a DLL, and inject it. It's my first project in C++, and I know it's not exactly C++ ...
7
votes
0answers
89 views

A simple Qt + MQTT doorbell application

So I built a house recently and didn't want to rely on "privacy-questionnable" systems like Google Home or Amazon whatever so I decided to build a doorbell system myself. Hardware I use a ...
7
votes
0answers
117 views

Implementing GSL synchronized_value

Core Guidelines mention a type synchronized_value<T>, which supposedly pairs std::mutex with the internal value. I couldn'...
7
votes
0answers
219 views

c++ std::function implementation

When I first tried to implement std::function I thought it would as easy as creating a class that holds a function pointer. Consequently, I quickly figured out that ...
7
votes
0answers
2k views

Yet another multi-producer single consumer queue in C++17

Here's an implementation of a multi-producer single consumer queue that I wanted to use with tasks such as logging from multiple points in a program to a single sink. The implementation is inspired ...
7
votes
0answers
152 views

C++17 pointer_traits implementation

pointer_traits is a lightweight trait that provides a uniform interface to builtin pointers and user-defined fancy pointers. That said, things like ...
7
votes
0answers
265 views

C++17. A blockchain implementation in 207 lines of code

There is a blockchain class with minimal functionality inspired by naivechain. It has template data and hash function parameters: ...
7
votes
0answers
329 views

STTCL FSM framework based on the GoF State Pattern, Part I: The basic interfaces

Preface I have decided to let my pet project created some years ago to undergo a code review here. The review will be broken into parts according to meta question Multiple reviews or one big review?...
7
votes
0answers
151 views

Find an arithmetic expression near to target value

I wrote this program as an answer to Express a Number challenge on the Programming Puzzles & Code Golf site; it may be worth looking there for the context. The concept is simple (and familiar to ...
7
votes
0answers
6k views

I am using boost::process to call an external process, and using stdout, stderr, and stdin to supply/retrieve data

I have some program which takes input via stdin, writes output to stdout, and errors to stderr. I would like to call that program from another program, supplying data via stdin, and capturing output/...
7
votes
0answers
3k views

constexpr Sin Function C++ 14

I have written a constexpr sin function using c++14 and would like to know what I can do to improve it. I am trying to balance code clarity/maintainability with ...
6
votes
0answers
81 views

Create 'classical' visitor from lambdas

I've watched a talk by Fedor Pikus on design patterns held at CppCon 2019. Motivated by this, I wrote my own visitor implementation and some helpers which allow me to create a visitor from a couple of ...
6
votes
0answers
171 views

Optimizing bit-matching performance using AVX compiler intrinsic

We are working on a complicated math problem, very detailed question with description of the problem is here: C++ multi-threaded determination of curling numbers in vectors. That code is now converted ...
6
votes
0answers
326 views

C++ Event System - Game Engine

Introduction I have just started learning templates and experimenting with function pointers. I wanted to create an event system that met a couple of goals: Event types are PODs, and do not inherit ...
6
votes
0answers
249 views

C++17 ECS Implementation

I am (relatively) new to game programming and have been exploring creating an entity component system for my simple 2D game engine. Here is what I have so far: Entity.h ...
6
votes
0answers
212 views

Buddhabrot made in CUDA

In the past I have made programs that have generate a buddhabrot with mostly success however all of them were on the CPU and single threaded. As a result they were all slow so I wanted to remake the ...
6
votes
0answers
71 views

Game event loop for multi-threaded application

My take on this problem for a hobby project. I have an event loop that advances game state and processes user input. Rendering is no concern of this event loop, and is intended to run on a separate ...
6
votes
0answers
141 views

Implementation of container searchable by any element

Writing game engine as a hobby, I've come across many situations where I need a container like a map, but searchable by different keys: a block allocator where a block needs to be searched by either ...
6
votes
0answers
219 views

Simple lock-free queue - multiple producers, single consumer

I have a simple lock-free queue, which supports multiple producers, but only one consumer. It is based on a constant-sized ring buffer and stores only pointers to a class and not actual instances. ...
6
votes
0answers
145 views

General algorithm to calculate sums of all subsets of a given sequence of numbers

Background A recent question Print sums of all subsets made its way to the Hot Network Questions list. The problem is simple: Print sums of all subsets of a given set Given an array of ...
6
votes
0answers
176 views

Resource cache based on Stroustrup 22.2.4

I recently read "The C++ programming language" chapter 22 and I thought the example given in chapter 22.2.4 was quite interesting. I thought it should be possible to make this system caching, so it ...
6
votes
0answers
103 views

Read stock files, gets the candles sequence and makes a report - follow-up

My first question: Read, calculate, write The only thing I kept is the function try-block. This is still a work in progress, that's what I have done so far. Source: ...
6
votes
0answers
68 views

Model for a multi-channel programmable electrical power supply

I am modeling a programmable electrical power supply which has multiple independent channels (or "ports") in a class I'm calling Supply. One of its features is the ...
6
votes
0answers
211 views

Value semantic type eraser

I've been using std::unique_ptr for cases where I want to store a derived-type value with type erasure, and felt that unique_ptr being nullable was an undesirable ...
6
votes
0answers
473 views

Console Command module (in-game console or base for script engine)

I've created a console/terminal command handling module that allows the programmer to bind functions to a command name and later execute them from std::string. What's new is that it handles most stuff ...
6
votes
0answers
309 views

Better rand() API

I use this document as a basis for my mini-library: Motivation The std::rand friends are discouraged in C++14, so we want: A direct replacement to ...
6
votes
0answers
1k views

PostgreSQL datatypes for libpq in c++

Following on from my earlier question: Very simple PostgreSQL ORM in C++ using libpq (tldr; I'm creating a set of helper classes for working with libpq) I've decided to have another attack at the ...
6
votes
0answers
3k views

Event system using callback functions in C++

I am learning C++ and have been trying to create an event system for use in a small game. This will be the mechanism by which game entities communicate. I would be eternally grateful if someone with ...
6
votes
1answer
190 views

Worker pool implementation

With the new additions in c++11 and c++17 I wanted to create a simple implementation of thread pool. I would like your opinion on: Thread safety API performace and general code quality I also ...
5
votes
0answers
106 views

Implementation of std::atomic<std::shared_ptr<T>> for C++20

As you may know, C++20 has added std::atomic<std::shared_ptr<T>> specialization to the standard, but sadly, most compilers have not implemented it yet. ...
5
votes
0answers
77 views

Emplace a lambda which captured a unique_ptr into container like queue

I'd like to emplace a lambda which captured a unique-pointer into a container, but it failed to compile under GCC 7.3.0 as C++17. From the error messages, it's calling the copy constructor of ...
5
votes
0answers
555 views

Make Flutter app on Windows a drop target to accept files

My aim was to provide functionality for a Flutter app on Windows to accept drag-and-dropped files. Flutter apps are written in Dart and compiled to native code, but since this is a cross-platform ...
5
votes
0answers
77 views

Using an extra mock simply to take advantage of the behaviour observation tooling

I'm writing integration for a project, but our framework doesn't provide any ability to inject dependencies, so I've written tests with a unit testing framework (GTest) and used a mock (GMock) in an ...
5
votes
0answers
622 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 ...
5
votes
0answers
52 views

Interfaces and OOP Design for Image Editor software

I'm new to C++ programming, and I'm building an Image Editor software like Lightroom/CameraRaw from scratch. Apart from procedural code (actually seems that all the functions works correctly) my goal ...
5
votes
0answers
1k views

C++ game engine event system implementation

I am currently working on the implementation of Event System on a game engine. I have zero experience in Event System implementation or the patterns that are used. What I have done is what I've seen ...
5
votes
0answers
1k views

Bubble sort in parallel

I have done bubble sort algorithm on a vector that is filled with randomly generated values. Bubble sort is actually done with odd-even transition method: ...
5
votes
0answers
154 views

C++ string Formatter Again Part-4

Previously asked here. The code is now available on GitHub. Since the previous review I have added unit tests. Since it is big it will come in a couple of parts. Part 1 | Part 2 | Part 3 | Part 4 ...
5
votes
1answer
157 views

State logger for optimization problems

I am working on a C++ project for solving a class of optimization problems. The project will be header-only, and for now, I would like to stay with C++11 (so, not fold-expressions). To be able to ...
5
votes
0answers
88 views

C++ library with tools for (arithmetic) type manipulation and mixing

Broken out from a previous question (C++17 saturating integer (arithmetic) type library) is a small C++17 header-only library to deal with issues that arise working with arithmetic where signed, ...

1
2 3 4 5
15