Category "c++"

how do you insert the value in a sorted vector?

ALL, This question is a continuation of this one. I think that STL misses this functionality, but it just my IMHO. Now, to the question. Consider following c

is there a way to pass nested initializer lists in C++11 to construct a 2D matrix?

Imagine you have a simple matrix class template <typename T = double> class Matrix { T* data; size_t row, col; public: Matrix(size_t m, size_t n

Using :: (scope resolution operator) in C++

I am learning C++ and I can never tell when I need to use :: . I do know that I need to use std:: in front of cout and cin. Does this mean that inside of the io

how to view std:unordered_map member in GDB

When trying to access a member of std::unordered_map using [], I get an error: Attempt to take address of value not located in memory. There is a nice gdb

Use of observer_ptr

What exactly is the point of the construct std::observer_ptr in the library fundamentals technical specification V2? It seems to me that all it does is wrap a

VSCode C++ Compiled exe was infected with Win32:TrojanX-gen[Trj]

I am setting up VSCode for C++, made some simple code (test.cpp) to test if things are working. #include <iostream> using namespace std; int main(){

Armadillo porting imagesc to save image bitmap from matrix

I have this matlab code to display image object after do super spectrogram (stft, couple plca...) t = z2 *stft_options.hop/stft_options.sr; f = stft_options.

how to print a string to console in c++

Im trying to print a string to console in c++ console application. void Divisibility::print(int number, bool divisible) { if(divisible == true) {

Can't run my built Qt Design Studio (Qt 6) project with CMake on Windows

I'm trying to run a compiled Qt6 project with CMake and mingw64, however, Qt6 apparently can't find QtQuick.Studio.Effects, QtQuick.Studio.Components and QtGrap

VIsual Studio Code error cannot open output file main.exe

This is my first project with Visual Studio Code. When i go to run my "Hello World" project I get this cd "c:\Users\imaco\Desktop\Cpppractice" && g++ ma

Why is there std::logic_error?

I have been told that you will only throw exceptions to handle "external problems", like problems that are not internal, i.e., only with run-time problems. But

Scheduling a coroutine with a context

There are plenty of tutorials that explain how it's easy to use coroutines in C++, but I've spent a lot of time getting how to schedule "detached" coroutines. A

Qt and Intel realsense Getting started

I didn't know where to ask as a beginner. So If you can help... I want to create a project using: Qt 5.15.0 Visual studio 2019 C++ openCV 4.2.0 (if is nece

Why is my SDL_mixer playing my wav. file too fast?

From this Lazy Foo tutorial (https://lazyfoo.net/tutorials/SDL/21_sound_effects_and_music/index.php) I wrote the following lines of code: #include <SDL.h>

Integrating Crashpad with a Windows Qt application

We are trying to integrate Crashpad with our Qt application and have run into several errors. We built Crashpad and attempted to link it to our application usin

When to use std::launch::deferred?

Lines from Anthony William book: std::launch::deferred indicates that the function call is to be deferred until either wait() or get() is called on the fu

Performane issue for matlab-like reshape in OpenCV

I am translating a Matlab code to OpenCV. The Code Involves lots of reshaping of large Matrices. As the matlab reshape differs from OpenCV you can't just use Op

Significant digits with IEEE 754 float

The Wiki Double-precision floating-point format says: This gives 15–17 significant decimal digits precision. If a decimal string with at most 15 signific

Direct way of computing clockwise angle between 2 vectors

I want to find out the clockwise angle between 2 vectors(2D, 3D). The clasic way with the dot product gives me the inner angle(0-180 degrees) and I need to us

What's the difference between constexpr and const?

What's the difference between constexpr and const? When can I use only one of them? When can I use both and how should I choose one?