Category "c++"

C++ Vector returning odd output for last iteration?

I am attempting to figure out the Skyline problem to better understand C++, right now I am learning more about how I can use vectors. I am trying to iterate thr

How to test a singleton generic template to be thread safe?

How do I make Singleton generic template, and how can I test it? Right now I am interested in seeing with my own eyes that 2 threads that invoke get_instance()

MQTT message is not received because of object in object

Libraries: <PubSubClient.h> <ESP8266WiFi.h> "ArduinoJson.h" When I send this JSON, the message is received and I can do things with it: {"topic":"d

MulVAL: make[1]: *** [Makefile:4: attack_graph] Error 1

I'm trying to compile MulVal, everything is already setup tried all of the solutions, getting this error, don't know if it was from the compiler or the code it

Garry's Mod: How to send a DLL?

Garry's Mod provides a C++ API to create server-side and client-side DLLs. As it is said in the article "Creating Binary Modules", they must be placed in the "g

How to make this code faster in python (algorithm question)

Today I was browsing for some questions that I saw this: Algorithm - Air Battle C ++ time limit: 1 second Java time limit: 2 seconds Python time limit: 10 secon

Different values for integer

Trying to insert values of square and cube of a number in set st and st1. (Let n = 10^7). After printing, set st is having negative values due to limit of integ

Using 'memcpy()' inside a class with a union

I have a class foo that manages data using small buffer optimization (SBO). When size < 16, the data is held locally (in buffer), otherwise it is stored on t

C++ {fmt} library: Is there a way to format repeated format fields?

I have a program with many formatted write statements that I'm using the fmt library for. Some of them have many fields, say 100 for example purposes, something

Why do std::shared_ptr<void> work

I found some code using std::shared_ptr to perform arbitrary cleanup at shutdown. At first I thought this code could not possibly work, but then I tried the fol

clang-14: warning: cannot compress debug sections (zlib not installed) [-Wdebug-compression-unavailable] while using address sanitizer

I have a sample C++ program that would cause an obvious segmentation fault. test.cxx: int main() { int* ptr{nullptr}; *ptr = 3; } So I am using address san

Coroutines are not distributed over asio::thread_pool threads

I wanted to try out to c++20 coroutines together with asio. In a simple test three are coroutines which would be executed on a asio::thread_pool with 4 threads.

How to structure data without bloating the size because of alignment?

Lets say we have a struct Original as this: class Original { int x; bool y; bool z; }; Due to alignment, the sizeof(Original) is 8 bytes. 4 for the int,

How to find the center and radius of an any dimensional sphere giving dims+1 points

given a vector of N-dimensional points. The vector will be of size N+1. Is there a generalized algorithm to find the center and radius of the ND sphere using th

Debugging NASM in VS code

I have a simple C++ program that calls some NASM code: main.cpp: #include <iostream> extern "C" int foo(); int main() { std::cout << "The result

Can you relink/modify relative shared library look up paths?

I am running into the following situation. Project A has libraries A1, A2, A3... That follow their own directory structure. For example: Libaries/ | |--Dir1/ |

Bazel: How can I exclude the build warnings from the external included header files

I have a situation where I include the header file of the library which I want to use in my main program. The main program is warning free and it has a feature

boost::asio::io_context::stop segfalt in gtest setup and teardown

Using C++17. I am trying to setup a gtest fixture that will create a fresh io_context to run timers on for each test case. My test segfault about 90% of the tim

Unrolling nested loops c++

I'm trying to unroll a nested loop that stores data in a 2D dynamic memory allocation in C++. Although, I'm not quite sure how to do it. Here is my original loo

Change output for TFLite_Detection_PostProcess op

From Tensorflow Object Detection API, I have noticed that TFLite_Detection_PostProcess has cut off the original outputs from Tensorflow Object Detection model