Category "c++"

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

c++20 ranges view to vector

Now that the C++20 ranges implementation is actually here and released under GCC 10.2, I would like to know how to convert a ranges view back to an actual conta

c++: request for member [function] in [class], which is of non-class type [class]

while trying to compile this: class DateTime { private: Date d8; Time tym; public: DateTime(Date idate=Date(),Time itime=Time())

Can't bind OpenCV to my project via CMake in CLion

For an exercise at school I need to work with OpenCV, but I can't figure out how I can link this in CLion. I have chosen to put the entire OpenCV library in my

error MSB6006: "link.exe" exited with code 1 When run SDV ( Static Driver Verifier) , Visual studio 2019 , SDK 10 build 19041, windows 10 build 19041

We create new KMDF USB project , Open visual studio 2019 v 16.11, go to File -> new -> project -> chose Kernel Mode Driver, USB (KMDF). without any mod

Data race reported in Boost lockfree queue by TSan

I'm running the MPMC example given in boost lockfree queue documentation with thread sanitizer and to my surprise this basic example contains data races as per

Cannot get gfwl source package to work in vscode

I wanted to learn OpenGl because I was just getting into c++ and I thought it would be cool to learn but now I'm stuck and I don't know what to do. So basically