814,685 questions
0
votes
0
answers
55
views
Static IIFE used for side effect
I have a list of callbacks to invoke whenever some event happens and I would like to allow subscribing to it without having to explicitly call the subscribing function:
// subscription.h
#include <...
1
vote
3
answers
180
views
Unable to call `std::stoi` on split string
I'm trying to read a string of numbers from a file, delimited by spaces, and then generate a vector of integers from the input using ranges.
std::ifstream infile;
infile.open("student.txt");
...
-5
votes
0
answers
117
views
Pointers, Classes And Linked Lists [closed]
The game I'm making using C++ requires a linked list like structure to make worms, but I'm unable to figure out how to declare and use nextnode within my worm object.
Here's my code of whatever I ...
1
vote
0
answers
147
views
Using modules and reflection
I am attempting to use C++ modules with reflection. When I #include <meta> things compile and work. Using import std; instead causes compiler errors.
import std; does work so long as I am not ...
Best practices
0
votes
7
replies
183
views
C++ Double Buffer Threading
I am working on a device where the I/O is incredibly slow and I have to SHA256 hash some data. So, I thought that I would use a double buffer to at least be able to do some I/O whilst the hash is ...
8
votes
1
answer
311
views
MSVC don't consider conversion operator when initializing aggregate with parenthesis
I stumbled upon this code:
struct type1 { int a; };
struct type2 { int a; type1 agg; int b; };
struct deducer {
operator type1() {
return type1{};
}
};
auto main() -> int {
...
1
vote
1
answer
119
views
Does implicit object creation necessarily happen at storage return location?
[intro.object] seems to say that implicit object creation, at least for operations that return a pointer, occurs at the returned location (https://eel.is/c++draft/intro.object#14 and https://eel.is/c++...
3
votes
1
answer
126
views
std::from_range does not work with explicit conversions
I'm trying to create a vector from an input range in a template code. Instead of using the begin - end constructor, I figured std::from_range constructor would be better in terms of readability and ...
-2
votes
1
answer
81
views
I have packages librdkafka librdkafka-dev on my Debian 13, but CMake find_package don't find them
On a Debian 13 OS, I have an Apache Kafka with roles Controller,Broker started by a:
#!/bin/bash
# Configuration
KAFKA_VERSION="4.1.1"
CONTAINER_NAME="kafka-beaufort"
CLUSTER_ID=&...
Advice
2
votes
13
replies
233
views
How do std::unique_ptr and std::shared_ptr differ in C++?
I’m trying to manage dynamic memory safely, but I don’t understand when to use unique_ptr or shared_ptr.
#include <memory>
std::unique_ptr<int> uptr = std::make_unique<int>(10);
std::...
0
votes
0
answers
129
views
Why does this short program using Boost coroutines always crash on Windows?
Can anyone shed light on why this fails to terminate correctly (always hanging or crashing) on Windows MSYS2 using Boost 1.91.0? The issue also occurs with Boost 1.90.0 and Boost-1.89.0 (built from ...
Best practices
0
votes
1
replies
41
views
Is Apple's UCCompareCollationKeys() a strong or a weak ordering?
I'm wondering whether the result of comparing collation sort keys (= already pre-processed strings for faster collation-compatible sorting/searching) is a strong or weak ordering. The implementation ...
3
votes
3
answers
155
views
timer using chrono in C++
I am trying to make a simple timer in C++ using the <chrono> library.
My code is as follows:
#include <iostream>
#include <chrono>
int main()
{
double timer;
std::chrono::...
-1
votes
0
answers
50
views
ESP32-audioI2S library for ESP32/Arduino not finding 'span' file
I am trying to utilize the ESP32-AudioI2S library with my Arduino Nano esp32, and have run into an issue with compilation, specifically regarding the aforementioned library. The error message directs ...
Advice
1
vote
7
replies
124
views
Coverage on casting Pointers to other data types
I have been studying C++ for a bit of time now. I am still a novice, but I continue to learn daily and practice and pickup new things.
One thing I haven't been seeing too much information on is ...
