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.

Filter by
Sorted by
Tagged with
0
votes
1answer
72 views

Image pixelwise operation function with multiple inputs in C++

This is a follow-up question for Tests for the operators of image template class in C++ and A recursive_transform template function for the multiple parameters cases in C++. I appreciated G. Sliepen's ...
-1
votes
1answer
105 views

I wrote a header file to write German umlauts in a textfile properly

This function is about the fact that a std::wstring was used in another cpp file in order to be able to read strings with German umlauts from the console. Since it is difficult to get wstrings into a ...
2
votes
1answer
60 views

C++ simple type serialization for streaming primitive- / pod types over a web socket (e.g. asio)

I am experimenting with asio web sockets and tried to write a simple serializer / deserializer. I am also thinking about an approach on how to serialize some type information alongside the actual data....
1
vote
2answers
111 views

Chess engine generates moves

I am currently writing a chess engine to improve my C++. I was able to improve my first results in terms of performance. (It is still really weak, but it does not lose a queen in one move) I ended up ...
3
votes
0answers
83 views

A Compile-time templated event system and dispatch manager

Problem I would like to make an efficient, extensible, and potentially asynchronous parallelizable event system using modern features in c++20. My solution I've ...
10
votes
5answers
2k views

Sine function calculated via look-up table and linear interpolation

I have been attempting to implement a function calculating values of the sine function. I know that there are several similar threads regarding this topic but my goal was to try to implement such ...
6
votes
1answer
109 views

C++ producer-consumer using blocking buffer

I'm working on a programming exercise (university, nothing related to industry) which basically asks to implement a Buffer to be used by two threads (a producer and a consumer). The first one enqueues ...
3
votes
1answer
57 views

Factorize a function where inheritance is unwanted

I have this piece of code which I'd like to improve: ...
4
votes
1answer
352 views

Google API Wrapper

Playing around with the google API. I have written demo applications to use the google gmail API. But what I am actually looking for is a review of the C++ wrappers for Authentication (OAuth2) and an ...
2
votes
1answer
75 views

A recursive_transform template function for the multiple parameters cases in C++

This is a follow-up question for A recursive_transform template function for the binary operation cases in C++. Thanks for G. Sliepen's answer. Based on the mentioned suggestion, I am attempting to ...
1
vote
0answers
63 views

A recursive_transform template function for the binary operation cases with execution policy in C++

This is a follow-up question for A recursive_transform template function for the binary operation cases in C++, A recursive_transform Template Function with Unwrap Level for Various Type Arbitrary ...
2
votes
2answers
94 views

Creating a threadsafe, mutable, global configuration struct wrapper with C++17

I'm trying to create a relatively simple class that stores global configuration in some serializable struct, and reads/writes from/to a file. My main goal is to make this class easy to use correctly. ...
2
votes
1answer
90 views

A recursive_transform template function for the binary operation cases in C++

This is a follow-up question for A recursive_transform Template Function with Unwrap Level for Various Type Arbitrary Nested Iterable Implementation in C++ and A recursive_print Function For Various ...
2
votes
1answer
46 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: ...
1
vote
3answers
158 views

Codewars Kata: Converting snake_case identifiers to CamelCase in C++

I did this kata from codewars: Complete the method/function so that it converts dash/underscore delimited words into camel casing. The first word within the output should be capitalized only if the ...
1
vote
1answer
111 views

Target OS implementation

I was able to make an implementation to detect the OS. I'm not sure if it works the way it should, so I asked this question TargetOS.hpp ...
1
vote
0answers
91 views

How can I remove the duplicated code in this code?

this is some function: ...
1
vote
1answer
51 views

How to make the initialization of the mocks more readable?

In an Arduino project, I'm using some code which is a slightly modified version of a public library. I made several modifications to it: I performed some minor changes I needed to make the code work. ...
2
votes
1answer
63 views

Tests for the operators of image template class in C++

This is a follow-up question for Two dimensional gaussian image generator in C++. Thanks for Cris Luengo's answer and JDługosz's answer. I am attempting to update the implementation of ...
1
vote
1answer
61 views

Accelerating creation of matrices and finding ways for optimal scaling

I have the following specific task, for which I have written code, in Rcpp, but it doesn't scale well and I would like to improve it. I'll describe first the steps of the procedure Step 1: We have ...
3
votes
2answers
69 views

Posix signal implementation

My hobby is Unix-like operating systems. Recently I began writing my own sel4-based Posix compliant OS. Here's the code for internal signal handling functions which presents a kind of backend to help ...
2
votes
0answers
65 views

Structuring a project that generates triangles inside triangles

Basically I made this completely useless program that generates triangles inside triangles. Its not perfect yet but my question is about the structure. I am generally happy with it but I want to know ...
2
votes
1answer
45 views

Creating a structural type array wrapper to be qualified as non-type template parameter C++

I'm trying to replicate std::array but with modifications that I should put the private data member to the public so the class template ...
7
votes
2answers
187 views

Two dimensional gaussian image generator in C++

This is a follow-up question for Two dimensional bicubic interpolation implementation in C++ and Two dimensional gaussian image generator in C. Based on user673679's answer, another file ...
5
votes
3answers
250 views

My little C++ library for comfortable programming

I've tried to make a little library in C++, to gather all useful and necessary functions. I wrote the code(in one file, to make it more portable). Unfortunately, it works on Windows only. ...
3
votes
0answers
82 views

C++20 Coroutine Task

This project is the natural extension to my attempt to make a templatedgenerator coroutine. This time, I tried what I called a "...
1
vote
2answers
110 views

Unsigned 64bit subtract-with-borrow in Standard C++

I'm writing a (compile-time-)fixed-width unsigned big integer. To implement subtraction, a subtract-with-borrow primitive is required. When efficient platform-specific implementation isn't available (...
3
votes
1answer
114 views

A TicTacToe command line game in c++

So I've just started teaching myself C++ a few weeks ago and I've decided to work on an implementation of Tic Tac Toe, using the command line. The program allows a human to play against a bot, which ...
2
votes
1answer
110 views

Win32 Snake game

I made a trival snake game below to practice my C++ and Win32 programming skills. ...
3
votes
1answer
314 views

Two dimensional bicubic interpolation implementation in C++

This is a follow-up question for Two dimensional bicubic interpolation implementation in C and A recursive_transform Template Function with Unwrap Level for Various Type Arbitrary Nested Iterable ...
5
votes
2answers
1k views

C++20 Coroutine Generator

Here is a coroutine generator class... Just like Python yields. It was a bit tedious to support both co_yield and co_return (...
9
votes
4answers
2k views

std::list reimplementation

I've decided to rewrite the standard library list in a smaller version. This is similar to another question of mine, where my main concern is memory management. I allocate a new array each time the ...
20
votes
3answers
2k views

C++ lock-free, MPMC Ring buffer in C++20

I have some performance critical inter-thread messaging code in C++. Multiple producers, one or more consumers. Profiling dozens of iterations of this messaging code over several years of development, ...
1
vote
1answer
120 views

C++ vector bubble sort in my edition

I made a small adaptive function that sorts vector: ...
2
votes
2answers
69 views

Updated version of my first neural network in c++

I got lot of suggestions for optimizing my neural network last post I made, now I wanted to post updated version of it were I got rid of most of performance eaters, now I would really appriciate ...
0
votes
0answers
62 views

Transform inertia tensor

I am trying to translate book: Game Physics Engine Development by Ian Millington to DirectXMath and faced with the code wich transform inertia tensor. Is it right to convert code from book like that: ...
1
vote
1answer
85 views

C++ Improved ThreadGroup Implementation

After the amazing feedback from these questions; I have prepared a third version of the original posted code. The Idea is the same: An std::size_t variable ...
0
votes
1answer
79 views

Why is this racket n queens code so inefficient?

I have the following code for the n queens problem described here: https://leetcode.com/problems/n-queens/ ...
-1
votes
1answer
59 views

Passing a partial application as an argument of an other function with no overhead [closed]

I am trying to find a way to pass a partial application as an argument of an other application with no overhead. I think I have find a way to do it (which might be dirty). The templated structure &...
8
votes
3answers
691 views

My first functional naive neural network in C++

I just wrote my first standard neural network with SGD gradient descent in c++, I am really interested if I have done anything wrong or inefficient, suggestions would help me a ton (There is lots of ...
3
votes
2answers
89 views

C++ ThreadGroup Implementation

Edit: An improved code based on feedback is available here. As a kind of sequel to the previous question, here is an improved version( with clarified naming ). The Idea is the same: An integer ...
2
votes
3answers
90 views

A file system watcher class for on-fly file reloading when it has been modified

I wrote a file sytem watcher class that is used to monitor file modification and then execute user-defined handler. Other file system events like moving or deleting don't need to be monitored. The ...
3
votes
2answers
262 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 ...
-1
votes
1answer
38 views

c++ program with 2 classes [closed]

Im making this project from few days , and now i need little help because i am struggling. The task says II. Define a student booklet class CStudBook that inherits CStudent with a member data ...
6
votes
4answers
287 views

Packing and unpacking values in a buffer

I have to deal with raw memory manipulation. For that I wrote a function which stores data one after another, and another function which reads this data and stores it into variables. More precisely: <...
5
votes
3answers
229 views

Find the mean of two values, take two

This is my generalisation of std::midpoint incorporating advice received for Find the mean of two values. As well as supporting arithmetic types and pointers, as <...
2
votes
2answers
63 views

A simple write-once-read-many indexed based database

I started writing a cyrptocoin from scratch, and then got sidetracked writing the database portion which I eventually turned it into its own project. Data is written to the database and then retrieved ...
4
votes
2answers
118 views

Merge two pulses if they match

The function processFus() takes : Two lists of pulses (200 000 in each), as an input Two lists of pulse, empty, pulseValid and invalid. The function must fill them ...
9
votes
2answers
130 views

Find the mean of two values

A very easily stated problem that has a surprising number of gotchas - return a value that's midway between the two supplied values. Depending on the types given, we need to be aware of arithmetic ...
1
vote
1answer
67 views

Typesafe implicit wrapper for C enums

This is meant to go in a vulkan.hpp-like strongly-typed wrapper for a pure C library. A wrapped enum provides back and forth implicit conversion between itself and ...

1
3 4
5
6 7
173