Skip to main content

Questions tagged [c++]

C++ is a general-purpose programming language. Use this tag for questions about/utilizing C++. Do not also tag questions with [c] unless you have a good reason. C and C++ are different languages. Use a versioned tag such as [c++11], [c++20] etc. for questions specific to a standard revision.

Filter by
Sorted by
Tagged with
0 votes
0 answers
6 views

Very slow CPP color detection when checking for mass amounts of color pixels

So, I am creating a program where it counts of pure black pixels given an x,y range on the monitor. The only problem is that this method provided below takes so long to run, while in java, it can run ...
wasddsaw's user avatar
0 votes
0 answers
9 views

How to include version information in a C++ project?

I wrote a C++ static library, and I want to add version information for it in a designated header. I'm working with C++14. I'm contemplating on multiple approaches: Adding it as macros: #pragma once ...
lielb's user avatar
  • 1
0 votes
0 answers
61 views

How to executing code before a process is launched?

I am currently working on a project where I need to execute some code before a certain process is launched. I am not sure how to approach this problem and I was hoping someone could provide some ...
q2333's user avatar
  • 19
-2 votes
0 answers
27 views

Are STL containers assigned by copy? [duplicate]

Recently I have encountered some problems when reading the source code of MSVC STL thread, I am very confused about how thread implements parameter copy, he clearly uses a perfect forward, and perfect ...
Ly_Bin's user avatar
  • 1
0 votes
0 answers
10 views

How can I change camera view of MuJoCo simulation?

I am working on a robot simulation using a MuJoCo (ver.3.1.1) with C++ language. And I am trying to change the default camera view of simulation, but I have a trouble in this work. My project composed ...
theInvincible's user avatar
0 votes
0 answers
17 views

Setup subdirs project with app and lib subprojects for qmake in QtCreator

I'm setting up a sample subdirs projectmain with two subprojects: projectgui (app template) and and projectsub1 (lib template). I'm using QtCreator 13.0.2 with Desktop Qt 6.7.2 MSVC201964bit kit on ...
Ajay's user avatar
  • 386
0 votes
0 answers
26 views

error: no match for 'operator!=' (operand types are 'QVector<Object>' {aka 'QList<Object>'} and 'QList<Object>')

I have Qt code that looks like following: class test_gadget { Q_GADGET Q_PROPERTY(QString test MEMBER test) public: QString test; }; class test_gadget2 { Q_GADGET Q_PROPERTY(...
user1558325's user avatar
2 votes
1 answer
27 views

How to forward constructor parameters to a contained tuple when one of the tuple elements has a default constructor and another one doesn't [duplicate]

I am trying to write a class that uses a std::tuple to store a bunch of objects with potentially different types. If the elements all have ctors that take some parameter, I can initialize the tuple ...
Anders Lindstrom's user avatar
0 votes
0 answers
19 views

How to use cudaMalloc and cudaMemcpy to allocate dynamic memory in a struct?

I try to use cudaMalloc and cudaMemcpy to allocate dynamic memory but meets Segmentation Fault error during running. I think I never allocate memory for double *data for device, but I don't know how ...
if_summer's user avatar
0 votes
0 answers
34 views

Why do flushing using std::endl when the buffer is not full [duplicate]

In C++, a newline could be printed using std::endl or adding a "\n" to the end of the printed text. Though in the latter case, the output buffer is not flushed until it is full, but this ...
Andrew Wang's user avatar
0 votes
1 answer
27 views

Why does separating the interface and implementation of a `std::formatter` specialization cause constraints to fail?

I was trying to specialize std::formatter<T> for a basic custom type Vector3D, but I'm receiving a compiler error. Here is a minimal reproducible example: vector.h defines the Vector3D class and ...
Christopher Miller's user avatar
0 votes
0 answers
28 views

why cv::waitKey(x) is not closing frame after x seconds?

#include<opencv2/imgcodecs.hpp> #include<opencv2/highgui.hpp> #include<string> int main() { std::string path = "wallpaperflare.jpg"; cv::Mat img=cv::imread(path); ...
Indu's user avatar
  • 37
-3 votes
0 answers
34 views

Setting values inside a tuple of vectors in a Singleton with std::get

I am creating a tuple of vectors of various objects - and it is a singleton. I have nested this singleton class within another class. Right now I have no idea what the issue is, but I am unable to ...
Jacob Elliott's user avatar
0 votes
2 answers
43 views

C++ logical error: strstr function not finding an available entry

I wrote the code below to try the strstr() function to search for a name in a list, but it is not finding it. Can someone please explain why this code fails to find the name I am trying to look for? #...
Siham Mohammad 's user avatar
0 votes
1 answer
93 views

Smallest element after xor

Starting with array of N positive integers, support Q queries. Each query contains a positive integer i. To answer the query, replace each element of the array with the result of xoring it with i, ...
user25680598's user avatar
1 vote
1 answer
88 views

Is it possible to initialize a struct reference with an array?

Is it possible to do something like this?: struct S { int length; char data[100]; }; class C { uint8_t buffer[10]; S& s = buffer[0]; }; If I use pointer it compiles, but working with ...
Maple's user avatar
  • 249
0 votes
0 answers
27 views

QT no matching function for call to 'makeCallableObject'

I'm trying to use the default Qfontcombobox in my qt app to change the font of a text edit, and i am getting this error for some reason. Here is my definition for my mainwindow.cpp #include "...
icy icy's user avatar
  • 33
-3 votes
1 answer
52 views

Understanding usage of std::for_each with structs [duplicate]

I am trying to understand how below code works, from cpp reference website: std::vector<int> v{3, -4, 2, -8, 15, 267}; struct Sum { void operator()(int n) { sum += n; } int sum {0}; }; ...
barribow's user avatar
  • 111
0 votes
1 answer
24 views

NCryptSignHash returns NTE_INVALID_PARAMETER (0x80090027)

I'm working with some old code that was signing data using an installed certificate and the CryptoAPI, and I need to migrate it to use CNG. I've tried two different approaches, one using ...
David's user avatar
  • 108
0 votes
0 answers
45 views

How should i set my .json files in vscode?

How should i set my .JSON files in my c++ directory: task.JSON launch.JSON c_cpp_properties.JSON settings.JSON I'm using GCC. My current configurations are: 1. launch.JSON { "configurations&...
Mairon's user avatar
  • 1
0 votes
2 answers
104 views

How do interfaces solve the circle-ellipse problem?

It is sometimes said that interfaces solve several problems of object-oriented programming, in particular the circle-ellipse problem. It would be this interface class IEllipse { public: virtual ...
V. Semeria's user avatar
  • 3,216
-2 votes
1 answer
47 views

Access elements in list<vector<int>> without using temporary space

I had a query on how to access the elements in a list<vector<int>>, I can access the elements by assigning the values of the iterator into a temp vector. For example, list<vector<int&...
Grimshingamii's user avatar
0 votes
6 answers
87 views

C++ function template specialization based on the templated return type

In C++20, instead of doing size_t count = 42; std::vector<int> my_vector; vec.reserve(count); std::copy_n(std::istream_iterator<T>(std::cin), count, std::back_inserter(vec)); I want to be ...
ashpool's user avatar
  • 243
0 votes
1 answer
45 views

Allowing STL algorithms to swap when iterators dereference to a wrapper class (i.e. an rvalue)

I am implementing a C++ wrapper for a C library that has a "vector of vectors" container. In the C++ interface, I would like iterators to dereference not to a raw C pointer, but to a ...
Szabolcs's user avatar
  • 25.3k
-1 votes
0 answers
35 views

C++ removing LAST object from map causes program to terminate [duplicate]

I'm new to C++ and I'm working with some old C++ code. Below is a basic example of the code that is failing? There are some comments in the example code explaining the error. Basically when removing ...
user1337497's user avatar
0 votes
0 answers
34 views

Incorrect value of CMAKE_SYSTEM_PROCESSOR when using cibuildwheel and scikit-build-core on GitHub macos-14 runner

Below are demo files to reproduce the issue. I expect the value of CMAKE_SYSTEM_PROCESSOR should be arm64. However, it is x86_64. See line 1233 in the Build wheels section, which corresponds to the ...
Jiawei Lu's user avatar
  • 527
-4 votes
2 answers
54 views

I was working on vs code in C++ and suddenly I got an error not showing any output in terminal [closed]

I was working on vs code in C++ and suddenly an error appeared that no output was shown in the terminal. I tried Please help guys, because this error is hindering my work. I was working in oop on ...
Abdallh Rafat's user avatar
0 votes
0 answers
16 views

Youtube LiveChatMessages resource caching with ETag not work

My app every 5s requests live chat messages for YouTube live stream api and to prevent unnecessary data transfers I'm also utilizing ETags. const auto listLiveMessagesRequest = yt::api::live::...
GloryOfNight's user avatar
0 votes
1 answer
47 views

Why is ARM NEON SIMD Sum is slower than serial sum?

I have been trying to benchmark memory bandwidth on my M2 Mac and one thing I noticed that when I try to use ARM NEON SIMD it seems that it has a slower processing time and lower memory bandwidth. ...
Bob Fang's user avatar
  • 7,221
0 votes
0 answers
16 views

wxWidget frame / window not closing

I have been developing a custom UI for Autodesk Alias. I use wxwidget for this. i follow youtube tutorials and made a window / frame. i have problem now. when i click the close button in menubar ,the ...
Karthick Panchaatcharam's user avatar
0 votes
1 answer
32 views

Tooltip not appearing in FLTK custom widgets

I am creating a tool for a project using Fl_Tabs and some custom widget, which encompasses some other custom classes. I would like to have a tooltip appearing when the mouse is hoovering on the custom ...
Eddymage's user avatar
  • 1,050
-2 votes
0 answers
39 views

Find Camera Location Using solvePnP [closed]

As part of a project I'm working on, I need to find a camera location using solvePnP. The goal of this project is to find the position of the camera using solvePnP, and compare to the true camera ...
Barak Daniel's user avatar
-7 votes
0 answers
39 views

Clarification about pointer to constant Foo where Foo is a struct [duplicate]

Code: struct Foo { int a = 0; int const b = 1; }; int main() { Foo f{}; Foo const *const_ptr_f = &f; const_ptr_f->a++; // error } // error: increment ...
avid_learner's user avatar
0 votes
0 answers
29 views

how to fix this Error: qrc:/main.qml: No such file or directory

I'm developing a very basic QML GUI for a C++ project, but I'm having trouble adding file URLs to the program. I've tried using absolute paths, ./path, and ../path, but none of them work. Whenever I ...
Pouya Tavakoli's user avatar
2 votes
0 answers
35 views

Weird behavior dealing with c++ std::variant comparison and operator functions [duplicate]

I have been trying to make a game in Visual Studio using c++17, and I created a class type called ErrorType to represent all the error numeric values (nan, inf, etc). By using std::variant<long ...
RandomGuy's user avatar
0 votes
0 answers
29 views

Websocket from ESP32 to Python to slow

I am working on a project where I have Python server that's connected to an esp32 cam (AI Thinker) via a websocket. The ESP32 cam constantly takes frames and sends them to the server, where they are ...
yardenK's user avatar
  • 193
0 votes
1 answer
29 views

qt6apptestqt_debug_metatypes.json: illegal value

EDIT My CMake file looks like this: cmake_minimum_required(VERSION 3.16) project(testqt VERSION 0.1 LANGUAGES CXX) set(CMAKE_AUTOMOC ON) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(Qt6 6.4 ...
user1558325's user avatar
-6 votes
1 answer
88 views

find the index of first occurence in a string

class Solution { public: int strStr(string haystack, string needle) { int pos = -1, i, j = 0; for (i = 0; i < haystack.size(); i++) { if (haystack[i] == needle[0]) { pos = i;...
darvince's user avatar
1 vote
1 answer
55 views

Calling a consteval function within if consteval causes error in non-constexpr context

The following code does not compile with g++ 14.1 or clang++ 18.1: #include <type_traits> consteval int plusone(int n) { return n+1; } constexpr int maybeplusone(int n) { if (std::...
user3188445's user avatar
  • 4,322
0 votes
1 answer
23 views

JVM cannot find Agent_OnLoad in agent lib

I am coding a Java Agent library. However, the JVM cannot find Agent_OnLoad function even if I have explicitly exported it in my C++ code. JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM* vm, char* ...
Rabbit0w0's user avatar
1 vote
1 answer
31 views

Unable to compile a QT app utilising PCL Visualizer due to missing VTK/MPI C component

I'm trying to build a demo QT application using the Point Cloud Library (PCL) and its provided visualiser component (#include <pcl/visualization/pcl_visualizer.h>). I'm using Cmake for the build ...
Josh's user avatar
  • 2,770
0 votes
0 answers
32 views

Sticky guidelines for QSplitter

I am trying to implement a snap-to-grid/snap-to-guideline functionality to a QSplitter. The idea is: Integer values are set onto the QSplitter (or possibly its parent widget or another ancestor) ...
Atmo's user avatar
  • 3,603
-1 votes
0 answers
24 views

How to configure CLion to avoid build failed while running

I have written a simple program in CLion C++ that solves USACO 2016 February Contest, BRONZE, Problem 1. Milk Pails. However, as I tried to run it, I got the following error ld: open() failed, errno=...
Ow Ji's user avatar
  • 82
0 votes
0 answers
48 views

Templating CUDA

CUDA supports templates and that is nice, I have however problem with interplay with C++. Let's say I have functions template <typename T> void CUDAZeroPad2D(dim3 threads, ...
VojtaK's user avatar
  • 610
-1 votes
0 answers
24 views

spellchecker with doublyLinkedBag [duplicate]

I have an assignment i am trying to write I keep getting this error: Added: watermellon Added to dictionary: watermellon Added: pineapple Added to dictionary: pineapple Misspelled word: apple ...
Tony La Valle's user avatar
0 votes
0 answers
36 views

Huge slowdown when specifying `target_file_name` with the same directory as `target`

auto sink = boost::log::add_file_log( boost::log::keywords::auto_flush = true, boost::log::keywords::enable_final_rotation = false, boost::log::keywords::file_name = logDir / (name + "...
Maksim Popov's user avatar
0 votes
0 answers
23 views

Ceres-Solver-does the initial reference 3D point matter? Experiencing significantly high reprojection error

So I have a set of 2d-3d correspondence points where the 2d coordinate points are detected by a corner detection algorithm (not written by me, and verified to be correct) and 3d coordinate points ...
Yajax's user avatar
  • 73
0 votes
0 answers
30 views

Calling methods from array of method pointers not executing [duplicate]

This doesn't execute any suggestions: void (CClient::*pMethod[CNetwork::ClientEvent::E_CE_MAX_EVENTS])(); pMethod[CNetwork::ClientEvent::E_CE_ACCEPTED] = &CClient::Accepted; pMethod[CNetwork::...
developer68's user avatar
0 votes
0 answers
48 views

Unable to properly use Visual Studio Code for C++ Coding [closed]

Some Backstory and Info:- This is my first time using Stack Overflow. So I may be inefficient in describing my issues, I apologize for that. I mainly use C++, and also know C and Python. I am a ...
ARUNAVA MUKHERJEE's user avatar
0 votes
0 answers
72 views

C++ Rule of Zero with guaranteed/C ABI

I love and often use C++ Rule of Zero, but now there's a use case where I find it challenging to use. I have 2 libraries, both maintained separately and even compiled with different compilers to ...
Paul's user avatar
  • 6,569

1
2 3 4 5
16189