Category "c++"

Adding a node to the beginning of a double-linked list

I am trying to create a function that adds a node to the beginning of a double-linked list in C++, and I'm getting this error in Xcode. I know it must be becaus

incorrect output when using C++ lower/upper_bound function with custom compare operator

I've been experimenting with the "lower_bound()/upper_bound()" functions in C++ w.r.t. arrays/vectors, and I get incorrect results when applying custom compare

Deleting a pointer from a vector... Error: terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc

I'm getting the error after I delete a pointer from the vector and try to delete a second one. I'm still new to pointers I created a base class of shapes and ha

What is the fastest way to get the lowest set bit of a C++ std::bitset?

I noticed that std::bitset does not have a function for returning or popping the lowest set bit of a bitset (nor the highest set bit for that matter). What is t

Directshow Transform filter's implementation exposes data race? [solved]

I'm writing a transform filter in Directshow. I've looked at the Transform filter implementation. They use 1 filter_lock for protecting filter's state and anoth

Why is this texture displaying all black?

Here is the function where I am calling all of my draw operations. I also compile the shaders inline in the function. It displays the quad correctly when I just

How to access the files in the res folder in the imgui conan package?

I am using conan to handle dependencies, for those of you familiar with imgui, it provides a series of backends you can include. When you look at the conan pack

Error Missing Type specifer - int assumed . Note C++ does not support default init

In order to make two objects, User1 and User2, of a class User sending and receiving messages, #include <iostream> using namespace std; class reply { p

Using for_each to print the highest value in a vector

I've this code: vector<pair<double, complex<double>>> vC; GetFourierCoeffs(N, t, A, vC); so vC is a vector that contains pairs with doubles a

Delete cl::buffer from Device in OpenCL C++

I am trying to set up memory management in my program as I noticed that my GPU's VRAM slowly fills up. I tried with clReleaseMemObject but it gives me the No s

in-tree include directory with bazel custom toolchain

Is it possible to configure a Bazel custom toolchain to include directories in the repository? Assume that I have following in the root of my repository: sysroo

C++ how to declare an array of priority_queue with customed comparator

With the idea from: declaring a priority_queue in c++ with a custom comparator , I tried to use lambda as comparator for the priority_queue, but when I tried to

Understanding behavior of trivial constructors in C++

I'm trying to understand how the following construction behaves differently across C++ standards, and what the guarantees are on elements a and b. struct X {

Why is Windows Defender scanning my code?

I am compiling C++ code using Visual Studio 2019. The code ranges from simple projects to learn C++ features to game dev. But no matter the scope of the project

alignof(T) with T=__m512 is not equal to alignof(__m512)

I ran into a strange situation that alignof(__m512) is not equal to std::alignment_of<__m512>::value compiled by Apple's clang. After some testing I found

Making a namespace a friend of a class?

I'm trying to encapsulate the Allegro5 C++ library and I want to have a namespace of rendering functions. The problem is that in order to use the rendering func

multithreaded C++ read access violation 0XCDCDCDCD

I'm writing a simple multithreaded md5 hash cracker using a task farm, except i keep getting read access violations seemingly at random. heres the function the

Macro doesn't handle bool conditions when they are "inline" but works via variable

I've written a basic macro which asserts regardless of debug or not: #define ASSERT_ALWAYS(cond) \ do \ { \

no NPOT issues on msvc but when on mingw-w64 the screen stays blank

I'm using olc::PixelGameEngine and I'm using the Example Program except that I'm enabling STB image. on MSVC, PGE worked great for several months without any is

O(n) and time complexity function of the given code

If the following loop structure is under Analysis of Upper bound, does it still compute to O(n^2)? I'm confused since inner loop has a dependency on the outer l