Category "c++"

If there is a difference between two constructs

If there is a difference between two constructs I would like to know std::string name = std::string("Eugene"); and std::string name = "Eugene";

Bitshifting a uint64_t gives wrong result

As was said in the title, bitshifting a uint64_t type gives wrong results. I have absolutely no idea why this is the case. It seems like on the edges of the shi

What is this weird colon-member (" : ") syntax in the constructor?

Recently I've seen an example like the following: #include <iostream> class Foo { public: int bar; Foo(int num): bar(num) {}; }; int main(void) {

Save template type parameter pack for later use

I'm working on a code where I can bind events and callbacks to react to those events, the interface looks like this: void on_close(); struct S { void the_a

How to set rgb colored symbol on specific pos (Win terminal)?

Iam making terminal game but iam struggling with the render part, i want to set symbol on specific pos with rgb color. so first question is how to set symbol in

Why are function pointers and data pointers incompatible in C/C++?

I have read that converting a function pointer to a data pointer and vice versa works on most platforms but is not guaranteed to work. Why is this the case? Sho

Mask from bitfield in C++

Here's a little puzzle I couldn't find a good answer for: Given a struct with bitfields, such as struct A { unsigned foo:13; unsigned bar:19; }; Is the

How to draw QRubberBand on a QGraphicsView using Mouse?

I have my MainWindow with a GraphicsView on which I want to draw a QRubberBand using MouseEvents. Therefore I created a custom GraphicsView class where I have t

Finding max consecutive 1 in a given array (leetcode)?

class Solution { public: int findMaxConsecutiveOnes(vector<int>& nums) { int ctr = 0, max = 0; for(int i=0; i<nums.size(); i++)

Python C API Py_NewInterpreter() freezes thread when creating new sys.stdin

I am building a Python wrapper for a C++ SDK in Python The app I am building on top of is using a console that is always listening to input on stdin Everything

MinGW pacman -Sys Unable to lock database

To start Code and Compile C++, must install a compiler. For my case, it is MSYS2 through which MinGW is available. According to the installation guild mentioned

Identifier "Return" is undefined in gtest?

SPIGtestMain.cpp #include "gtest/gtest.h" #include "gmock/gmock.h" TEST_F(GivenANewSPI,WhenDemoIsCalled_TheComponentGetsVal) { unsigned char const *Ptr;

how can I use vcpkg to install sqlite3 and use in cmakelist.txt?

I use vcpkg to load sqlite3 for my C++ project. for vcpkg, I think I integrate it correctly: PS D:\tool\vcpkg\vcpkg> .\vcpkg.exe integrate install Applied us

PyTorch - Using {N,H,W,C} format in customized operation

I'm thinking about upgrading some of my customized PyTorch operations to support {N,H,W,C} format. However, I'm still confused about using channel-last-format t

Why hasn't not_null made it into the C++ standard yet?

After adding the comment "// not null" to a raw pointer for the Nth time I wondered once again whatever happened to the not_null template. The C++ core guidelin

Why don't we have to declare static functions the same way we need to declare static variables in c++?

Consider the following struct: struct Toto { static int a; static void Print() { std::cout << a; } }; And the following main functio

Attempting to solve this problem more efficiently

I read a natural number with at most 9 digits. I have to form a vector with the even digits of that number, in ascending order, with each digit appearing once (

How to show cursor during application debug c OpenGl on ubuntu in Visual Studio Code

window = glfwCreateWindow(winW, winH, "TestApp", NULL, NULL); After calling this command, the mouse cursor disappears. When a breakpoint is triggered after thi

Can I mix C++ and Swift in the same swift package, using the Swift Package Manager?

I would like to write one module in C++, and make some functions in C that are accessible in Swift. I am somewhat baffled, because no matter what I do, the SPM

Question about the declaration about the aliasing constructor for `std::shared_ptr`

I think the 8th constructor of the std::shared_ptr<T> should be decalared as template< class T, class Y > shared_ptr<T>( const shared_ptr<Y