Newest 'c++' Questions

Q&A for professional and enthusiast programmers

In C++, is there any way to reduce the number of member functions with move semantics?

I am trying to write my vec class. For efficiency, I use move semantics. Vec<int> v1; Vec<int> v2; Vec<int> v3; Vec<int> v4; v4 = v1 + v2; // Line 1 v4 = v1 +...

PJSUA2 - Recording call to WAV in Windows with Null-Audio

I'm currently starting to work with PJSUA2. I want to develop an SIP client that accepts calls. When it accepts a call, I play a WAV file and record the input to a WAV file as well. PJSIP does not ...

C++ on iOS (XCode) Firebase #include firebase/app.h not found

I have my dependencies put in, gradle properties completed, pod installed and completed and JSON, SDK download and put to the relevant places. However why am I getting an error build on #include "...

Strange height value in the SDL_VIDEORESIZE event

I'm trying to create an application with the SDL, and would like the window to be resized. For now, if I try to maximize the window, it works, if I place it in the left or right half of the screen, ...

Read STL file to a winged edge data structure?

I am working on a project where I have to read large STL files(which may be defective) and do certain operations like grouping the triangles based on whether they lie inside or outside, finding the ...

exposing q_property from private member

In the code I'm working on I need to expose Q_PROPERTIES from private member(s) through one integrating QWidget. Something this would be nice: class MyWidget: public QWidget{ Q_OBJECT ...

Undefined behaviour or not undefined behaviour

Considering the following code: #include <stdio.h> int main() { char A = A ? 0[&A] & !A : A^A; putchar(A); } I'd like to ask, whether any undefined behaviour is observed in it ...

How to get recieved messages using Skype4COM in C++ [on hold]

So, i've been searching this everywhere but i don't see any documentation. Only C#, VB.NET or Java.. Anybody can show some code on how this can be done?

Trace all RPC calls in C++ gRPC server

I have a gRPC server written in C++ and I would like to trace or log all RPC calls to the server, including arguments and responses, if possible. The Go gRPC implementation has the very helpful ...

What does GDB run command do?

I am trying to dump the contents of a binary file, which is obtained as a raw bin content of a C struct in my embeded SW. The working steps to do this in GDB are File path/to/myelf.elf run path/to/...

How to use OpenCV 3.2 in Qt-creator 4.2.1 in Windows plattform

I want to use the OpenCV library 3.2 with Qt-creator 4.2.1 in Windows plattform. In the .pro file I used the following code: INCLUDEPATH += C:/OpenCV/opencv/build/include LIBS += LC:/OpenCV/opencv/...

use lambda in function template, can't deduce type, makeSet() use case

What I want to achieve is a makeSet() function accepting three arguments, a pair of iterator, and a function that transforms the value. One use case could be creating a set from a sequence of values ...

Initial Conditions on transfer equation

I programming the modeling equation(transfer equation) and i have a problem with set of initial conditions and finite conditions. For example in my task the function of initial condition is Hevysaid's ...

OpenCV Error: Assertion failed (samples.cols == var_count && samples.type() == CV_32F) in predict

I'm trying to use OpenCV SVM classifier in cocos2d-x game. Here's a simple test function: void HelloWorld::testOpenCV(){ // Load SVM classifier auto classifierPath = FileUtils::getInstance()-&...

Why will my program not re-enter my 2nd while loop? C++

All of my commands and alters to the array work individually. However, when i try to return to the menu the screen just starts jittering and will not continue. I am forced to close the program. How do ...

String vs vector to store large texts

For data compression, I need to open files (here text files) and to store all their content in variables. Is it better to use strings or vectors of chars to store really large texts (millions or ...

Implicit conversion and user defined conversion

When I write code like this: struct foo { operator int() const { return 1; } }; int main() { foo a, b; auto tmp = (a < b); } it works, but while I write code like this: struct foo { ...

Convert a PXCImage into an OpenCV Mat (PIXEL_FORMAT_YUY2)

I'm working on the Intel's RealSense SDK and I have to convert it into an OpenCV format. I saw this solution in the forum (Convert a PXCImage into an OpenCV Mat) but for the "PIXEL_FORMAT_YUY2" type ...

Calling C function from within C++ Code [duplicate]

I am trying to call a C function from inside a C++ project in Visual Studio 2015. The error I get is LNK2019 "unresolved external symbols" Error LNK2019 unresolved external symbol ...

How can I check if pull is needed using libgit2 in c++?

I want to check if I have the latest version of program. I have my program shared to bitbucket.org , and I want my c++ code to write me if I need to pull the latest version, or I already have the ...

Tcl_Format memory usage

Here is an extension proc for TCL written in C(++) (that it's C++ does not matter here – I just use std::vector). I use Tcl_Format to create a new formatted string. If I don't use Tcl_DecrRefCount, ...

Refactoring tag dispatching structure

I have following code: #include <iostream> #include <cassert> #include <utility> struct real_type { struct real_category{}; typedef real_category num_category; }; ...

How to include correctly -Wl,-rpath,$ORIGIN linker argument in a Makefile?

I'm preparing a c++ app on linux (Ubuntu 16.04) with the use of a few poco libraries which I have dynamically linked. I have project folder that consists of : include, bin, lib , src and build folders ...

Dispatch for binary and unary callables in C++03

I'm having troubles implementing this in legacy C++, but I'm pretty sure it can be done. Say I have a higher order function that needs two versions, one for unary callables (function objects, ...

Color Text without console Output?

[This is my first post ever. please don't devour me] Hey Peeps! I'm pretty new ( like just a few hours ) to C++ I didn't learn any other "High" languages yet, I did most Things in Windows CMD, and ...

C++ taking a pointer and turning it into a callable function

I am currently reverse engineering a program to learn how it works and have just completed disassembling a function that the program calls. The starting address of the function is stored in a pointer, ...

How to access IP camera with OpenCV?

I have an IP camera that I want to use as the input to videocapture() I have seen many posts on how to use the IP camera with OpenCV. None of them worked with the camera I m using. The username is :...

Cannot profile XCTest in instruments

I have a performance test in my XCTest group that I want to profile in Instruments. Now I right click on the test in the test navigator, hit Profile "test..." and Instruments launches. When I choose ...

List all the minimum cuts in the graph

I am working on a problem of a network flow to find max flow using min cut theorum. This problem requires to list all the minimum cuts in the graph. But what I have found is Ford-Fulkerson and Edmonds ...

Repeated values from std::uniform_int_distribution

I don't understand what's going on here. #include <iostream> #include <random> #include <chrono> using namespace std; unsigned number_in_range(unsigned, unsigned, ...

C++ application crashes when `SHFileOperation` is used only under Windows XP

I have this class: class FileSystemHelper { public: static bool RemoveFolderWithFiles(string path) { cout << "Remove folder with files..." << endl; SHFILEOPSTRUCT ...

Qt - How to combine QtConcurrent and QThreadPool for a QProgressBar?

In the mainwindow.ui I created a QProgressBar named progressBar and a QPushButton named speckle which starts the heavy computation. Inside the mainwindow.h I have an appropriate private slot for the ...

Wrap C++ function for Tcl with Typemap

I'm a Newbie in SWIG and a Beginner in C++ and have some Problems wrapping C++ functions for Tcl/Tk. Assumed I have a function like this: bool doSomething(int value1, float &result1, float &...

How to know the time the current thread spent blocking for purposes like I/O? Basically the time the thread wasn't executing

So I am writing a profiler and the time the threads were not executing is relevant to my calculation. However, all the libraries I know provide the time for which the threads were executing e.g ...

Get nearest base class

I have a class hierarchy: struct B {}; struct D1 : B {}; struct D2 : B {}; Is it possible using some sort of std:: helper functions/classes (likely from <type_traits>) get common base class (i....

Mapping a std::tuple to another std::tuple

Let's assume I have a std::tuple<Types...>, I want to generate a std::tuple<std::priority_queue<Types...>> #include <queue> #include <tuple> template<typename ...

error initializing map<string, vector<string> c++ [on hold]

I have an object that contains a map (In header:) protected: map <string, vector<string> > data_map I want this to start empty (which is what a map is supposed to do). I later assign ...

Ascending Order of a set of integers [on hold]

I want to make a program in C++ such that it asks the user to input a set of numbers. (The amount is also "inputted" in by the user). How would I go about doing this?

checking whether g++ can link programs

I received the following error in the logs while I was trying to build glibc: configure:3180: checking whether g++ can link programs configure:3203: g++ -o conftest -g -O2 conftest.cpp >&5 ...

Call of the destructors in multilevel inheritance (c++)

I coded the following classes in order to test the multi-level inheritance concept. There is a point that I didn't really understand when I was trying to test the calls to constructors and destructors....

Create a specially formatted LIB file

Is it possible to create a LIB file which doesn't expose some of its functions to the public? I mean, I can open any lib file and see every single function of it, not just the "public APIs". Also if ...

Can't send mail from Windows server using EAsendmail library

I have the below program by which can send mail from local PC but can't send mail from Windows server. // TestEASendMail.cpp : Defines the entry point for the console application. // #include "...

Command line argument in c++? [duplicate]

I have to run programmed scene.exe -f SCENE.xml -s objects. I know SCENE.xml and objects are arguments of it. But I want know about what is the meaning of -f and -s.

How to add cmake project to another cmake project as library?

I have been researching over hours but I still couldn't solve my problem. This is Cmakelist of ProjectA. It perfectly works: cmake_minimum_required(VERSION 3.5) set(CMAKE_INCLUDE_CURRENT_DIR ON) ...

QVariant inside QMap not recognized in GDB

I'm in an enterprise environment (which means there's no possibility a priori to add pretty printers or change software at any level) using GDB (gdbserver) to debug an app using Qt on a different ...

How to use infile.open(file_nameI.c_str());

So I have this code that is coming back with error: no matching function for call to 'std::basic_ifstream<char>::open(std::string&)' and error: note: no known conversion for argument 1 ...

Cannot build XMP-Toolkit-SDK

I'm trying to use Adobe XMP-Toolkit-SDK (it's written with C++) with Visual Studio (VB.net) to build a project to EDIT the METADATA of PDFs. But I couldn't build or deal with the SDK yet. I think I'...

Program skipping over parts of input file C++

Here is part of the code from my unfinished project. Right now I am just to get the name and ID from the imput file, ignore the data, move to the next line and repeat. The program works except that it ...

Error: Compiler thinks I'm passing in Object*&. Am I?

I've been working on this code for a couple hours and I am having approximately zero fun so I'm asking for help. I'm making a function in a program that will place infected cities in a Linked List of ...

why using more than 2 threads consume more time?

sorry for this question but iam new to Multithreading and i tried this code to speed up the gradient process. The main thread compute gradient for the border of the image and the other threads each ...
Translating... 0%