Questions tagged [c++]
Questions about C++, a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language.
2,795 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
4
votes
3
answers
157
views
Does (possibly) failable destructor require to change invariant violation error handling?
First, I'd like to highlight my personal premise on error handling approaches in C++ (as it might be the source of confusion in the first place). C++ Standards, 2004 (Sutter, Aleksandrescu), item 68 ...
3
votes
6
answers
653
views
Can a language be sound if it doesn't promise safety?
It is said that C's type system is unsound, which means that it has "false negatives", it tells the programmer everything is fine, but then the code fails at runtime. for example, "the ...
3
votes
2
answers
276
views
"dimension" vs "extent", "axis" vs "dimension" - when should I use which term?
I'm defining a small API involving both uni-dimensional and multi-dimensional data. In addition to representing the data itself, I also have function/methods/operators for creating a new multi-...
1
vote
3
answers
164
views
Ensuring proper initialization order in event-driven C++ applications
I'm working on a C++ system where I have a concept of a "Board" object. Each board can have services attached (e.g. UpdateService, LoggingService, etc.).
I'm trying to design how these ...
1
vote
3
answers
475
views
Should I include the header of the source file always in C/C++?
I have a source file that is used by other sources so it has a header file. If in the header, there are types used that needs inclusion of other headers, I'm better to include this header in its ...
1
vote
4
answers
550
views
How can I get started on refactoring my code base?
https://github.com/Darkroman/PK-Battle-Simulator/
Over some time I made a fully working (text based) Pokemon Battle Simulator in C++ as I was learning the language on my off time. At the moment I have ...
12
votes
6
answers
4k
views
What's a good way to use exceptions in a C++ project?
The basics: what I know
I understand the basics of exceptions:
If a function cannot perform its assigned task, it can signal it by throwing an exception,
When writing a function, one must make sure ...
-2
votes
3
answers
317
views
What is beyond ordinary c++, when trying to optimize a function?
Backstory:
Writing a QImage to Sixel renderer.
Feel like I have optimized it the best I can using basic c++.
I have heard suggestions here or there that you can utilize things like GPU, SIMD, insert ...
0
votes
4
answers
433
views
What is a suitable format for writing large amounts of data within few milliseconds
I have a c++ code that needs to store some data whenever an event is triggered. The data contains about 3000 floating point values. So each of these values needs to be written in a file when the event ...
5
votes
4
answers
325
views
A [[byvalue]] attribute for C++?
Background
C++ attributes are a useful way to document assumptions and intent within code, and to prevent warnings. (e.g. [[fallthrough]])
Now, the Core Guidelines recommend to For "in" parameters, ...
2
votes
4
answers
450
views
How to combine multiple functions into a single template based function
Threre are two functions FindMaxDistanceVector and FindMaxDistanceList whose implementation is almost same except some debug information added in FindMaxDistanceList. Note that these two functions are ...
2
votes
1
answer
214
views
Extracting type info
Suppose that I want to implement the following scenario.
There is a board and each board has a set of peripherals like leds, temp sensors, gpio and so on. Each of them implements the according C++ ...
3
votes
1
answer
231
views
Passing info between different branches of a class hierarchy in C++?
So, I have a class hierarchy that looks like this:
It is an embedded project, so the entire code will be run over and over.
I have several algorithm classes, that compute some result given some inputs....
3
votes
4
answers
378
views
When wouldn't I want to allow polymorphic deletion in C++?
When designing a pure virtual base class (interface) in C++, in what cases would I not want to allow polymorphic deletion via a pointer to my base class?
I've seen questions about why you should make ...
3
votes
0
answers
244
views
How to encapsulate functions inside a library
I'm working on a project that uses an in-house library, which is also used by other projects.
There are some classes and methods in other classes that are not used outside the library itself, is there ...