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
2
votes
3answers
82 views

Batch extracting differences between two images with enhancement using opencv

I am attempting to extract the absolute differences image between two input images and then enhance the intensity (brightness) channel in HSV color space with the given times. The workflow is like ...
3
votes
1answer
68 views

Abstract wrapper for fundamental types

I have created this interface as part of my C++ learning path. This post inspired me a lot. The idea is to use its concrete implementations to perform some actions before and after any change of the ...
4
votes
2answers
47 views

Find the closest possible frequency of a pulser that uses limited number of fixed time intervals to generate the signal (CAEN V2718)

Disclaimer I've created this post not only for the code review, but rather because I think it would be helpful for the users of the CAEN V2718 module. Problem description I have a VME board (V2718) ...
0
votes
1answer
55 views

Writing a buffer that takes a header and a variable number of packets and makes a payload [closed]

I'm writing this as an exercise. I would probably use a vector as a buffer internally (the extra capacity pointer overhead is not important enough). Primarily it's an exercise in writing copy/move ...
2
votes
0answers
102 views

Implement Websocket using boost::asio::beast with serialized writes

Here's a proposal implementation of websocket using boost::asio::beast that is thread-safe to parallel writes. In this example below, the ...
0
votes
1answer
108 views

Improving poor man's translations mechanism in c++98 program

In order to add basic translation capabilities in an old c++98 program I've come up to a basic and shameless code summarized by this snippet: ...
1
vote
1answer
72 views

Providing a C interface to a 'Region' map

I decided using a C++ map or unordered_map is the most appropriate option to store 'Regions' where which can be loaded in ...
3
votes
1answer
114 views

Project Euler #43 (C++)

Here's my C++ solution for PE 43: ...
2
votes
3answers
242 views

C++ logger by template

If the log file is not available, then output the log message to the console. Any improvement or suggestion for this implementation for the logger by the template? Any potiencial problem that I should ...
1
vote
1answer
76 views

Replacing a char in the file name

I am formatting my TV series archive and can not do one by one. I wrote this code and it's working like what I want. I am a beginner and want to improve my knowledge of algorithm. What can you ...
5
votes
1answer
84 views

Algo to return a vector of available time slots for scheduling a meeting between two persons

There are 2 persons and their already booked meeting schedule is given and also time bound for both the person is given. Now, we want to schedule a meeting between them in an available time that suits ...
4
votes
1answer
93 views

Sorting visualizer

I've created simple sorting visualizer in c++ using SFML. I'd love some feedback on how can I improve the code and OOP design. Whole project: GitHub main.cpp ...
0
votes
2answers
57 views

Class using resource pointer- Resource class with copy constructor and copy assignment operator

I have created two simple classes: resource and container. below is the full code. actually container keeps resources. and in ...
1
vote
3answers
64 views

Validating an integer with affixes in compile-time or runtime

I'm implementing a function called is_proper_integer that will check the string whether it is a valid integer literal by borrowing the idea from C++ grammar. ...
3
votes
2answers
165 views

Simple "schema validator" of JSON using JSON Patch (nlohmann:json)

Well, it's not actually a schema validator but anyway... Motivation I'm writing a library which is a UI to work with some electronics - modules. Each real module is represented by a corresponding ...
0
votes
1answer
54 views

Unit Tests for the operators of image template class with Boost.Test framework in C++

This is a follow-up question for Tests for the operators of image template class in C++. As G. Sliepen's answer mentioned, I am attempting to use Boost.Test and several test cases are created with <...
1
vote
1answer
56 views

C++ winapi scale2x algorithm. Is it well implemented?

taking into account the scale2x algorithm for scaling an image to 2x. Im using winapi in an Emulator. When tha scale2x algorithm is used i don't see too much difference in the image scaled2x as it ...
1
vote
1answer
49 views

A Token class for a lexical parser

In a larger project, I need a (rather simple) expression parser able to accept numerical values, operators and string identifiers. Fine, a lexical parser fed with some input which gives tokens one at ...
1
vote
2answers
106 views

File reader and writer

I was told that the following code of mine was poorly written. How bad is it? Do you have any recommendations? ...
2
votes
3answers
169 views

string to double

I'm trying to write a function to replace the standard std::stod(...). I want to parse the following valid inputs: ...
2
votes
1answer
54 views

Makefile that compiles to two separate executables

I'm working on a project that will have both a server and a client, using Boost's ASIO library for networking. I'm not really comfortable working with Makefiles, but, with some help from Chase Lambert'...
4
votes
2answers
63 views

Mode and standard deviation for Math Library

Taking forward the code written for the math library previously mentioned here. link. Wrote templatized functions for mode and standard deviations. (Some of the changes to the previous reviews were ...
0
votes
0answers
29 views

Using shared memory in cuda kernel to populate arrays of different dimensions

I want to know if I can use shared memory to optimize my code and get better performance. I will explain how my code works: The inputs to my kernel are a matrix d_e ...
5
votes
1answer
187 views

Implementing apply_each for tuple c++

I'm implementing apply_each for tuple-like object as a general function which may be a combined version of for_each and ...
4
votes
3answers
570 views

Compute shortest path in undirected graph

In a recent coding interview I was asked to write a program which takes as input two text lines: The first one represents a graph, formatted as a sequence of undirected edges like ...
2
votes
2answers
268 views

piping a std::tuple into a function

This is a mythical beast we discussed in a previous question: ...
2
votes
2answers
90 views

An implementation of Uber's “Fare Estimator”

CodeSignal put out a challenge by Uber that involves writing a "fare estimator" that involves a function dependent on cost per minute, cost per mile, ride time and ride distance. The formula ...
6
votes
5answers
623 views

Mean and Variance for Math Library

Taking forward the code written for the math library I'm developing. I wrote templatized functions for mean and variance. std::accumulate() (or summation in ...
2
votes
1answer
105 views

looping over variables of heterogeneous type

These snippets are nothing special, but they remind us to sometimes loop without a for or a while loop. It is even possible to ...
3
votes
1answer
144 views

Permutation function for a math library in C++

Continuing the code for combinatorics library, adding the definition of ⁿPᵣ. This is an extract from a larger codebase. Is there any way to limit the code of gcd()...
1
vote
2answers
85 views

General coding style and efficiency of a maze maker

I have just finished making a maze maker. I took inspiration from this video, but its my own implementation. I just wanted to know what you guys thought of it and if there are any improvements that ...
3
votes
2answers
325 views

Simple Blackjack Game in c++

I made a simple BlackJack game and I want to make it as good as possible before I move on to creating a few other games in my "casino" - let me know how I can improve it I added a few things ...
1
vote
1answer
71 views

Combination function for a math library in C++

Taking forward the combinatorial library link, I have tried to implement the nCr function. Please mention if this is prone to failing somewhere Any other test code that needs to be added. Any more ...
9
votes
2answers
2k views

Factorial function for a math library in C++

I am trying to code up a basic combinatorial math library for C++. Started with the implementation of the factorial function. Here I include the code and the test code. Please review. Is the way of ...
3
votes
1answer
91 views

Implementation of Multidimensional numerical integration in C++ and R

I'm trying to perform a 4-dimensional numerical integration in R using a function I wrote in C++ code which is then sourced in <...
0
votes
1answer
75 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,...
2
votes
3answers
102 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 ...
3
votes
2answers
104 views

BASIC Computer Games: Battle in C++

As a C++ newbie, I am practicing my C++ skill by implement games in BASIC Computer Games and here is my C++ version for Battle. Suggestions I want Any suggestion are welcome! Current Project code from ...
7
votes
0answers
98 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 ...
4
votes
1answer
50 views

Preprocessing invalid xml before feeding it to a parser

As part of a larger project I'm writing to learn C++, I'm trying to read through some almost-XML files generated by another program. Unfortunately this program uses its own custom escaping logic, so ...
3
votes
3answers
540 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 ...
2
votes
1answer
70 views

Custom C++ wxWidget Ranged Slider

I wanted to make a bounded slider since the ranged slider wxwidgets includes isnt very useful for my use case. I wanted a left and right bounded slider to control a dynamic way to control a graph or ...
3
votes
2answers
238 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 ...
2
votes
3answers
89 views
0
votes
1answer
30 views

Reviewing my shader class for efficient use

Im just trying to setup my shader function in a class in a way that would make me work with it easier and in a more understandable way. In Shader.h: ...
3
votes
2answers
112 views

Rubik's Cube rotation with OpenGL

I've been trying to make a rubik's cube project and it succeeds nicely . The only problem(or something like that) is that i need to optimize my code for easier understanding and more flexibility. Here'...
1
vote
4answers
96 views

Print a 10x10 times table

I have been on the C++ learning grind for the last 2 weeks using caveofprogramming videos so don't judge too hard if this seems like a dumb question. My last lesson covered arrays and the assignment ...
3
votes
2answers
84 views

floor modulo or modulo rounding towards negative infinity

The first function will always try to correct the final result, while the second uses a conditional to know when to compensate. I think that in general the second function will be faster, but it will ...
0
votes
1answer
40 views

An efficient way for removing rows with zero elements iteratively while constructing the matrix

Based on a previous post, Accelerating creation of matrices and finding ways for optimal scaling, we managed to accelerate the way that I construct a matrix in Rcpp (inputs for example are at the end ...
1
vote
2answers
77 views

Parallezing merge step and divide step in mergesort algorithm with OpenMP

We wrote a code that parallelizes the divide phase of the mergesort algorithm. I.e. every recursive call is assigned to a thread but our teacher was disappointed because he said we should also ...