Category "c++"

How to check if a std::thread is still running?

How can I check if a std::thread is still running (in a platform independent way)? It lacks a timed_join() method and joinable() is not meant for that. I thoug

Matplotlib in C++

I would like to use matplotlib to plot an x,y graph. To do this, I downloaded "matplotlibcpp.h" from github : https://github.com/lava/matplotlib-cpp However, in

Sorting array with MPI in C++

I want to sort array of random numbers using MPI library. The idea is to chop array with MPI_Scatterv and send it to the processes. Every process should localy

How to initialize and print a std::wstring?

I had the code: std::string st = "SomeText"; ... std::cout << st; and that worked fine. But now my team wants to move to wstring. So I tried: std::wst

How to get on top-level const pointer using "auto"?

In short words: Per C++ Primer, pg 69, "auto": "If we want the deduced type to have a top-level const, we must say so explicitly". I would get an top-level

Can sizeof(size_t) be less than sizeof(int)?

Can sizeof(size_t) be less than sizeof(int)? Do the C and/or C++ standards guarantee that using unsigned int for array indexing is always safe?

How can I make CMake use GCC instead of Clang on Mac OS X?

I can't find any info on it, but only the other way around (e.g., how to set CMake to use clang). I've installed gcc-4.8 using brew, setup all dependencies, he

sws_scale YUV --> RGB distorted image

I want to convert YUV420P image (received from H.264 stream) to RGB, while also resizing it, using sws_scale. The size of the original image is 480 × 800.

How to check the CRC of the function in C++

Is it possible to count the CRC of code in the memory of the function in the runtime? I have a function that compares user's password with the secret password.

Can I list-initialize a vector of move-only type?

If I pass the following code through my GCC 4.7 snapshot, it tries to copy the unique_ptrs into the vector. #include <vector> #include <memory> in

Can casts be completely avoided with a good design?

I'm wondering whether situation exists where casting is completely necessary. I'm talking here about casts between classes, not basic types. Is casting (be it

How to execute a piece of code only once?

I have an application which has several functions in it. Each function can be called many times based on user input. However I need to execute a small segment o

Correct way to find nth root using pow() in c++

I have to find nth root of numbers that can be as large as 10^18, with n as large as 10^4. I know using pow() we can find the nth roots using, x = (long int)(1

Video Poker in C++

I'm starting to write a video poker program and I'm running into some issues. I have a Hold function as you can see below: void Game::Hold( bool& choice

Linux script executing from C++ code with execv fails

I've a very basic Linux script (/home/scripts/script.sh): #!/bin/bash echo 'a' | /bin/netcat -vv 10.10.10.1 3333 echo "done" > /tmp/result When I try to r

Qt: How to change cursor by using style sheets?

I know I can change the cursor by "setCursor(const QCursor &)". Now I want to change it by using qss, but I don't know how to do it. QWidget has the cursor

How do I call ::std::make_shared on a class with only protected or private constructors?

I have this code that doesn't work, but I think the intent is clear: testmakeshared.cpp #include <memory> class A { public: static ::std::shared_pt

cppcheck How to suppress inline unmatched suppression?

I found that --suppress=unmatchedSuppression only suppresses unmatched suppression types in cppcheck options, but NOT unmatched inline suppressions. Is this t

worth the time investment to learn Qt (c++)? [closed]

i already know java, c++ (no one framework for GUI development) and little of c# (winforms for gui development) but i'm thinking to ivest my f

Why does QStringLiteral returns a garbled string

I'm programming a Chinese software, and embed some of the strings in the source file. To reduce runtime overhead (well, actually this is premature optimization,