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.

723 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
24
votes
0answers
3k views

CMake Project Template for a General Cross Platform C++14 Project

UPDATE: I am no longer updating this post with the contents of my actual project since they have changed significantly (Unit testing is now done with doctest, code coverage is included, etc.). This ...
15
votes
0answers
659 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 ...
13
votes
0answers
2k views

Asynchronous serial port communications class in C++

Please review my serial port class written in C++. It is completely asynchronous, ie event driven. My idea for later is to inherit from this a sync_serial, where timeouts can be specified and it ...
13
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 ...
13
votes
0answers
201 views

Multi-function memoizator and multi-type container

I'm trying to write a multiple functions memoizator, which I've talked about here. The main problem is creating a container containing different and heterogenous functions. I found a working solution,...
11
votes
0answers
154 views

Creating an istream peeker

I want an istream that you can safely peek arbitrarily many characters from. This works as far as I can tell, but I am unsure if this is really "the right way" to ...
10
votes
0answers
674 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 ...
10
votes
0answers
172 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 ...
9
votes
0answers
333 views

C++ library to compile-time merge sets to a single array

I built this small library to create a compile-time assembled array from several hard-coded sequences (of unequal length) of a type T: ...
8
votes
0answers
157 views

Neural Network with Template Metaprogramming

I was implementing a simple neural network, and I noticed that, if I ever wanted to change the layers' activation functions, i would have had to completely rewrite some parts of the code, so I tried ...
8
votes
0answers
377 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
342 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
1answer
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
477 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
258 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
284 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
126 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 ...
7
votes
0answers
98 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
162 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
130 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
2k views

Using multiple console windows for output

In my current project I found the need to concurrently track the progress of multiple concurrent components, and having all of them output their (debug) information into a single console window made ...
7
votes
0answers
253 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
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 ...
7
votes
0answers
326 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
147 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
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
149 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
207 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 #pragma once using Entity = ...
6
votes
0answers
199 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
69 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
140 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
182 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
138 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
163 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
81 views

Extending functions to tuples

Intro: Imagine you have defined addition on types A and B with function A add(A,A) and ...
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
67 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
209 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
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/...
6
votes
0answers
462 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
303 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
173 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
51 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
46 views

calculating upper bound on normalized weighted levenshtein distance

Current implementation I am using a normalized weighted Levenshtein distance for two utf32 strings with the following costs (insertion: 1, deletion: 1, replacement: 2). The normalization is performed ...
5
votes
0answers
48 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
465 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
46 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 ...

1
2 3 4 5
15