812,224
questions
0
votes
0
answers
7
views
Eigen vector restrict rule
Considering that C++ code compiled to x86/64 (GCC 11, -O2) :
static constexpr int N = 4;
typedef std::complex<float> cfloat;
typedef Eigen::Vector<float, N> VectorNf;
...
2
votes
1
answer
15
views
TRegistry GetKeyNames not working as expected
I am trying to use the following code to get a list of subkeys in the registry. GetKeyNames takes a TString object. Upon return, the TStringList object has a count of 3 which is the correct count. ...
-2
votes
0
answers
18
views
Lighting using transparency
I have a blank texture and a light texture that I have created a mask using both images and a shader. I can render the transparent image over the window and use a gradient circle to "punch a hole&...
0
votes
1
answer
37
views
How to make Visual Studio evaluate Qt expressions?
Whatever Qt expression i try to evaluate while debugging on Visual Studio 2022 doesnt work, for example:
Conditional breakpoints with Qt expressions doesnt work.
Any Qt expression on watch window ...
0
votes
1
answer
36
views
Why does my program not find my DLL file?
I have a program and it worked just fine, but when I compiled my MainDLL.dll file, my program won't find it. It returns (0x7E) (The specified module could not be found). The .dll file is in the same ...
0
votes
0
answers
16
views
cmake export static lib and hide 3rd party libs [duplicate]
I am creating a static library lets call it X. This library uses rapidjson library in .cpp files. When I export this as static library, I want to hide rapidjson dependency. Another project should be ...
1
vote
1
answer
18
views
How to use `Rcpp` to implement a similar function for regression analysis of `lm` functions in R?
In order to speed up the calculation for very large matrices, I use Rcpp to perform the calculation, which involves regression analysis. I noticed in r's documentation that lm uses the qr ...
0
votes
0
answers
20
views
How can I find the contour of a filled option in answer sheet?
I want to find the contour of an option circle which is filled by pencil, just like the ones in the picture, but findContours() can't work well. It is always finding the wrong contour or just even can'...
3
votes
0
answers
52
views
automatic dependency generation for c++20 modules
I try to use c++ module. For any real world project is is needed to get the dependencies automatically.
If I use "old-style" include <bla>; include "blub" I simply can use g++...
0
votes
0
answers
29
views
Unable to add external libraries
I am using c-lion and i have some cpp/h files and some external .lib/.dll files which are 32libs (glew32,glut32) . I am failing to link the external libs.
C:\Program Files\JetBrains\CLion 2023.3.2\bin\...
0
votes
0
answers
41
views
Is it safe to insert a range in std::vector if its source is the tail of the same vector? [duplicate]
Is it safe to insert a range in std::vector if its source is the tail of the same vector?
I need to insert some elements to std::vector as copies of elements in the same vector which positioned later ...
-1
votes
1
answer
37
views
how to make a linked list with template
i have problems with distributing template. i tried with different syntax, but not a successful way with the error text:
error C2512: 'node': no appropriate default constructor available
for the code
...
1
vote
0
answers
47
views
Are There More Efficient Awaiters for C++ Coroutines Than std::suspend_always?
I’m attempting to optimize a binary search workload using C++ coroutines on a 1GB sorted array of unique random integers to induce multiple memory misses. The approach involves using co_await when ...
3
votes
1
answer
47
views
Error when binding a constexpr reference to variable of different type
It is known in C++ that when initializing a reference, types must match. So the following code snippet causes an error (in global scope, the same below):
unsigned i;
int & p = i; // error
But ...
0
votes
0
answers
24
views
The OS keeps bootlooping on IDT loading
So I created a basic IDT for my custom OS in C++, but it keeps bootlooping. gcc doesn't have any output or error at all, so I can't find the issue is.
The IDT:
#include "isr.h"
// Define an ...
1
vote
1
answer
27
views
read issues during Concurrent fwrite to NFS
I have two processes: one is writing to a file in a loop using fwrite, and another is reading the file in a loop using read. The reader process sometimes returns positive read size but all 0x00 in the ...
0
votes
2
answers
65
views
My chessboard has no color, how do I add color to the boxes or spaces of it? [duplicate]
I am making a Chess game, atm I am making a chessboard and was about to finish when I realized that it has no color and was like...
"How do I add color?"
Heres the code, where and how do I ...
2
votes
1
answer
44
views
How to set a system_clock time_point with year, month, day
I want to convert a UTC year, month, day to a std::chrono::time_point (and also display it).
#include <chrono>
using namespace std::chrono;
void DisplayDate(int y, int m, int d) {//e.g. 2024, ...
1
vote
2
answers
69
views
Nested loops with recursive functions
Could some one help me how to implement below version of nested_loops with recursive_loops? I was able to generated the exact output what I want using nested_loops, but it is always limited to 3 loops....
0
votes
0
answers
63
views
Precompile std::variant instantiation?
I am using a C++ std::variant with around 100 structs as possible choices. This type is used throughout my application and compile times tend to point to the instantiation and generation of various ...
6
votes
0
answers
77
views
Do unevaluated template operands need to have valid defintions?
The major C++ implementations seems to have quite a different
idea about this. What to make of the validity of the following 4
assertions?
struct a {
template<typename T = void>
...
0
votes
2
answers
79
views
Single-element range
Given a function that accepts a range, for example:
void f(const std::ranges::range auto& r);
Sometimes I have only one element that I want to pass to the function.
There are multiple ways of ...
-3
votes
1
answer
48
views
Teapot fails to display with OpenGL? [closed]
I am writing code to import an OBJ and apply environmental mapping using OpenGL. First of all, I succeeded in displaying the skybox texture on the screen using cubemap. However, I failed to apply ...
2
votes
1
answer
104
views
Two instances of the same struct with same field values in are not bitwise-equal
I have a code where i want to CAS atomic struct (Update) and it returns false. That happens with expected and atomic structs having same field values (tested with one thread).
I went to cpprefernce ...
0
votes
1
answer
105
views
How to convert an int to a string using std::format at compile time
I'm trying to convert an unsigned integer to a string at compile time in C++23. I know that std::format is available for formatting strings, but it doesn't seem to support compile-time evaluation, and ...
0
votes
0
answers
50
views
Hooking std::plus<T>() to overloaded operator+
I practice easy coding on Codewars platform. There is a place where I found following exercise:
Write a function that accepts two square matrices (N x N two
dimensional arrays), and return the sum of ...
5
votes
1
answer
76
views
Data oriented design - preparing data for cache friendly iteration vs direct access
in Mike Actons talks here and here (links are with timestamps) as well as in this blog post they prepare/precondition/prefetch/query needed, non-contiguous data first to then iterate them / do ...
0
votes
0
answers
18
views
Managing the Lifecycle of re2::RE2 Objects with Cached and Stack-Allocated Options
I have a function re02_match(regexp, use_cache, ...) where I need to handle re2::RE2 objects differently based on whether a cached object should be used (use_cache = true) or a stack-allocated object ...
-3
votes
1
answer
92
views
How to fix cpp random crashes
This C++ program i have written keeps crashing when I run it.
#include <iostream>
using namespace std;
void compile_program() {
cout << "worked";
string *cppfile;
...
0
votes
1
answer
35
views
How to implement a generic publish–subscribe pattern where methods of subscribers that receive calls can be registered at the publisher?
More generic publish–subscribe pattern
I was looking for a publish–subscribe pattern that is advance in terms of more generic.
The usual publish–subscribe pattern that I know of has virtual functions ...
-1
votes
0
answers
18
views
ZyBooks 11.8 LAB: Longest common subsequences C++
I am trying to solve this ZyBooks LAB, here are the instructions:
"The LCSMatrix class is declared in the LCSMatrix.h file. Access LCSMatrix.h by clicking on the orange arrow next to main.cpp at ...
0
votes
0
answers
25
views
Unable to generate a valid Azure Storage SAS token in Cpp - Updated code
This is the final working token generator:
std::string crypto_GenerateSasToken(
const std::string& permissions,
const std::string& blobName,
const std::...
-2
votes
0
answers
47
views
Why do i keep getting "the following warning is treated as an error" when i try to compile my kernel driver? [closed]
So i keep getting "the following warning is treated as an error" when i try to compile my kernel, here is the part it's saying that
void debug_print(PCSTR text) {
KdPrintEx((...
-6
votes
0
answers
56
views
C++ writing sea battle game [closed]
I wrote game "Sea battle" on C++.I wanted to know how to set background picture for this game. I know that images don't work in the terminal.
So i want the game cover to be on the background ...
-1
votes
0
answers
60
views
How to delete item from std::vector while iterating [duplicate]
I am trying to find and delete all elements in a vector that holds a pointer to a class. I looked at lots of examples that show how to do this but they are all showing a std::vector<int> but my ...
0
votes
0
answers
31
views
How to convert dart CameraImage to opencv cv::Mat then to .png
Im trying to send CameraImage from flutter to c++ to process the frames with opencv then send each frame back to flutter but the frames are rotated 90 degrees, in grayscale and with a green lined bar.
...
1
vote
1
answer
67
views
how we can pass values to a coroutine
I want to know a method to pass values from the caller to the coroutine.
My idea:
Any awaiter type must provide a await_resume() function. This function can return something to the co_await inside ...
0
votes
1
answer
41
views
How to select the text of an application's input field with c++
I want to select the text of an application's input field with c++.
I have no problem selecting the text manually pressing ctrl+a on my keyboard but I am unable to do that with c++.
I thought I would ...
0
votes
1
answer
72
views
how do force the programmer to instantiate a template?
Here is some template constexpr function.
template <class> constexpr void function();
I want to force the programmer to instantiate function with a specific template parameter.
template void ...
1
vote
1
answer
78
views
operator<< overload not selected for rvalue std::ostringstream and std::unique_ptr
I noticed that the std::basic_ostream operator<< overload for rvalue ostreams is not selected for a temporary std::ostringstream in combination with std::unique_ptr.
#include <iostream>
#...
0
votes
1
answer
51
views
How to use IPrintDialogServices interface when calling IPrintDialogCallback::SelectionChange to get and change printer settings using WinApi C++
Tell me please how to use IPrintDialogServices interface when calling IPrintDialogCallback::SelectionChange to get and change printer settings.
I'm trying to use this construct, but I don't understand ...
2
votes
0
answers
60
views
How can I detect if multiple keyboard keys are being pressed at the same time in C++, in Linux, from the terminal?
I have some code which currently checks if the character "b" is being pressed:
#include <iostream>
#include <termios.h>
#include <unistd.h>
using namespace std;
char ...
0
votes
0
answers
61
views
Is a virtual destructor always needed if there are virtual functions? [duplicate]
Is a virtual destructor always needed if there are virtual functions? I was told at the interview that there is no, although everywhere they write that it is necessary. What do you think about this?
1
vote
1
answer
40
views
How can I suppress sanitizer errors from member functions in GCC?
I'm compiling code on an Ubuntu system with GCC 11.4.0 with -fsanitize=thread.
I am getting some sanitizer errors from external libraries called from my functions. I have read that I should be able to ...
0
votes
0
answers
55
views
Potential leak of memory pointed to by <variable>
I wrote this function in Qt 6.8.0:
QActionGroup *group = new QActionGroup(ui->toolBar);
foreach (QAction *action, ui->toolBar->actions())
{
action->setActionGroup(group);
QWidget *...
0
votes
1
answer
48
views
Why JNI env (JNI interface pointer) is thread specific?
Two doubts from JNI Design Overview docs:
The JNI interface pointer is only valid in the current thread. A native method, therefore, must not pass the interface pointer from one thread to another. A ...
0
votes
0
answers
40
views
C++ custom allocators: in what circumstances would I be asked to return more than 1 unit?
I've written several memory allocator that couldn't allow the allocation of more than 1 unit of the specified type T, as apparently required by the Standard C++ library's collections that take ...
3
votes
3
answers
135
views
How to generate std::array of primes up to certain maximum prime at compile-time
I am trying to generate std::array with primes up to 30. Not first 30 primes, but 2 3 5 7 11 13 17 19 23 29.
My best attempt is below and it works, but has ugly code repetition:
auto primes = ...
3
votes
1
answer
46
views
C++ preprocessor check if macro equals two double quotes
I'm running into an issue with a macro that is generated from an environment variable in platform.io:
-D SXM_VERSION=\"${sysenv.SXM_VERSION}\"
As you can see SXM_VERSION forced to start and ...
1
vote
3
answers
78
views
Sorting objects by key matching a specific sequence
I have a sequence of structs, say
struct Foo
{
std::string key;
int value;
};
The data points represented by these structs can arrive in any order, but need to go out in a specific order. I ...