11,416 questions
-1
votes
0
answers
84
views
gtkmm-3.0 Segmentation Fault in g_sequence_iter_get_sequence and g_sequence_iter_is_end() with corrupted backtrace [closed]
I am developing a C++ application using gtkmm-3.0 on
root@colibri-imx6ull-15625953:~# cat /etc/os-release
ID=tdx-x11
NAME="TDX X11"
VERSION="5.7.1-devel-20221213120311+build.0 (dunfell)&...
Advice
0
votes
11
replies
149
views
Handling of Negative Exponent in Recursion, Confused
I want to know how this concept can be implemented in C++ with recursion:
My program was running fine before, but when I try to implement negative exponent handling, it is giving me a Segmentation ...
Advice
0
votes
8
replies
146
views
Find the Maximum Value in a Vector Array using Recursion
I am asked to implement:
int maxVal(const vector& arr, int i = 0)
Using recursion only, no loops.
I have the idea that I have to compare each element, but I'm confused how this idea should be ...
0
votes
0
answers
79
views
Class template argument deduction (CTAD) failing with error: deduced class type ... in function return type on a templated class [duplicate]
In the following C++ code (compiled with g++ 10.2.0), the declaration of myManager_not_ok produces the error:
error: deduced class type ‘Manager’ in function return type
while the other, quasi-...
-2
votes
0
answers
147
views
What does storing in buffer (for std::cout) actually mean? [duplicate]
std::cout stores values in a buffer and then prints them to the console.
I have this example:
#include <iostream>
int main() {
for(int i=0;i<10000;i++)
std::cout << "A&...
Advice
0
votes
13
replies
118
views
Pulling in an include path from within a C++ project's source
I have the following directory structure for a C++ project:
external
eigen-5.0.1
Eigen
source
<source files>
When compiling, I add both external/eigen-5.0.1 and source to the -...
5
votes
1
answer
210
views
How to get Monday and Friday's date in C++ with date.h
With Howard Hinnant's date.h (I am using C++17), how can I get Monday's date and Friday's date using the library?
I can get today's date using this:
auto todayDate = date::floor<date::days>(std::...
4
votes
1
answer
205
views
The Ephemeral View: Performance Over Safety in std::string_view Ownership [duplicate]
#include <string_view>
#include <iostream>
int main() {
std::string_view sv = std::string("Hello") + " World";
std::cout << sv << std::endl;
}
C++...
Best practices
0
votes
12
replies
192
views
How to switch over a large number of cases with an extremely skewed distribution in an efficient way?
We have a service that when sending messages to us, includes a uint8_t error code. With several hundred possible codes. In our application, we translate this into about 8 categories of errors in an ...
Advice
0
votes
6
replies
148
views
Looking for a pattern to add information in any output stream that could be used later by another tool
I created a template function tostr(...) that is able to convert a lot of types to string with several options. Example of possible code:
std::vector<double> x = {1.123456789, 9.987654321};
std::...
-1
votes
3
answers
308
views
How to overload operator<< for a C-style array passed by reference to a function?
I am trying to overload operator<< for a C-style array passed by reference to a function, like this:
#include <cstdint>
#include <iostream>
#include <algorithm>
#include <...
4
votes
1
answer
124
views
Cereal serialization of inherited classes doesn't work
I'm writing a 2D game engine in SDL3 and C++ and I'm trying to serialize my node trees with cereal (https://uscilab.github.io/cereal/).
Every node can have a list of components, and I'm having ...
3
votes
2
answers
158
views
Instantiating an object with a function pointer, with its arguments filtered by type [closed]
Given ViewPath is a class which takes a void function pointer and a varying number of std::variant<std::string, int> as arguments in its constructor. Given the arguments of said function pointer ...
2
votes
3
answers
200
views
Using std::apply in a class template
I want to run a member function with arguments defined by a tuple. The tuple itself gets its types from the template.
I have looked at answers such as https://stackoverflow.com/a/69694086/18658154, ...
4
votes
0
answers
103
views
Full template specialization using void{} produces different results on GCC and Clang [duplicate]
This code prints:
1 when compiled with g++ v15.2.1,
0 when compiled with clang++, v21.1.6.
The -std=c++17 flag is used with both compilers.
#include <iostream>
#include <type_traits>
#...