Category "c++"

When is the compiler allowed to optimize away a validity check of an enum or enum class type value in C++?

While searching for an answer to the question above, I came across the answer of Luke Kowald to the question Check if a value is defined in an C enum?. It state

Brace Initialize struct with virtual functions

Brace initialization struct A { int a; int b; void foo(){} }; A a{1, 2}; It works fine. Bu

c++, ffmpeg tanscoding: time_base differs depending on the container

I transcode video (mkv and mp4). When mkv transcoded to mkv, output is fine (output video fps and duration are same as input), but if mkv transcoded to mp4, out

How to open a second QMainWindow from my first/original MainWindow?

I am creating a desktop app with Qt6 and C++ and I have my original MainWindow class. Using Qt Creator I generated ui,h,cpp for a new SummaryClass (QMainWindow)

Is there a simpler way to write a concept that accepts a set of types?

Essentially, is there a shorter/cleaner way to define Alphabet than using a bunch of std::same_as/std::is_same? struct A {}; struct B {}; struct C {}; ... temp

I need a function to delete certain characters from a char array in c++ without using any index

for example: if the user enters : ( 23+22+43) I want the function to do exactly the following : for(int i =0; i <strlen(x);i ++) { if (x[i]=='+') {

How to open GStreamer pipeline in OpenCV

I'm a software engineer in South Korea. I'm trying to open webm video using GStreamer pipeline in opencv program But I can't find any solution to figure out it.

Use templates to implement a subset of multiple virtual methods of a templated class

I am working on incorporating a new implementation based on an older, fixed API and moving in somewhat contradicting terrain because I need to pair a templated

My checkTie() function is not working correctly

I am working on my college project where we have to create a Tic-Tac-Toe game and I am completely made the game but for some reason, my checkTie() function is n

find_package() ignores <PackageName>_ROOT

In my CMake script I append the path to a folder containing <PackageName>Config.cmake to <PackageName>_ROOT and then call find_package(<PackageNa

QSqlDatabase is opened but QSqlQuery does not execute and shows error database not opened

I am working on a project. I am trying to run this query but it fails and gives the error. Here is the code: QSqlQuery* printQry = new QSqlQuery(); if

Automatic differentiation using expression templates c++

Introduction I am trying to learn about expression templates because it seems to be a very powerful technique for a wide range of calculations. I looked at diff

cmake : shared library or sub-prjoect

I am builfing a new c++ project and i want to integrate cmake and i dont know what is the best approach i have to follow my project tree looks like this : .

How come the fmt library is not header-only?

I know it is possible to use the fmt formatting library in header-only mode: How to use fmt library in the header-only mode? but - why isn't it just header-only

What is differnece between CreateWindowEx, CreateWindowExA, CreateWindowExW?

I read the documentation about CreateWindowEx CreateWindowExA CreateWindowExW and they all are seem to be identical to each other. if there is not difference w

Trying to run a cpp program but I get the following error: [process exited with code 3221226356 (0xc0000374)]

I am currently trying to execute the following cpp program on Windows: #include <cstdlib> #include <iostream> #include "math.h" #include <fstream

Drawing with cv::circle's over a line Iterator in c++ with openCV

I'm creating an iterator line, which I pass through a for() and draw with cv::circle points. So far so good, form a line drawing, by the iterator's line points.

How to shuffle a std::vector?

I am looking for a generic, reusable way to shuffle a std::vector in C++. This is how I currently do it, but I think it's not very efficient because it needs an

Does vector know to reserve first when initializing by a pair of iterators?

Consider the following code. struct MyData{ MyData(const BYTE* pData, size_t uSize) : bucket_(pData, pData + uSize) {} std::vector&l

GetCommTimeouts function failed with error code 50

when I develop a PCIe communication interface, I used CreateFile & Readfile function to operate the device. But when I tried to set timeout to the handle, I