Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Posts by Dirk Herrmann
The use of the terms expression and statement could vary between programming languages. However, the following distinction is widely used: Expressions are syntactic forms that allow software auth...
There are some reasons why a function would intentionally not be declared static. (In the following I use the term 'module', but in contrast to others, I use it not to describe a file or translati...
I would like to add further options to the set of possibilities, namely environment variables and GUI input. Moreover, I would like to distinguish reading information from stdin and from other (na...
@elgonzo mentioned correctly that the nice trick from @pnuts can not be applied if you are interested in the number of occurrences including overlapping ones. So, just in case someone is in need o...
From your description ... I have text (xml actually) files. Some files contain 'foo', some contain 'bar', some contain neither and some contain both. It's the both I'm interested in. ... I co...
When you think about how to organize your test code, you should develop an understanding of your goals. Typical goals about test code organization (which typically includes helper code only needed...
I see it such that it is undefined behavior (I refer to N1570 as the OP https://port70.net/~nsz/c/c11/n1570.html): After free(p), the lifetime of the object pointed to has ended (7.22.3p1: "The li...
The expectation for all posts is, that a post is always understood as the own work of the poster, who has the copyright and responsibility for it and offers it to the site according to the site's c...
There is one thing to clarify when mapping a float interval to an integer interval, namely how the boundaries of the float interval shall be mapped to the boundaries of the integer interval. Takin...
Starting with the goals: A naming convention typically aims at supporting several, partly contradictory goals, among which are the following: Compliance with the limitations of the language stan...
It is undefined according to my reading of the standard (I am referring to the latest public draft). int x; (void)x; In the second line, (void)x is a full expression, but x by itself is alread...
The way your code handles the variable i within the for loop seems to indicate a wrong understanding of the meaning of for i in range(1,n+2): range(1,n+2) will provide an object of type range. ...
Well, you still need (placement) new for the implementation of the smart pointers themselves. You would also use it (or malloc) to implement custom allocators, for example: https://www.boost.org/d...
grep is not the right tool for your case. You can use basename: basename a/b/c --> c basename a/b/c/ --> c or, in your case basename branches/features/arm_and_musl --> arm_...
Update: Distinguished between the general case and cases (as with std::string) where it is known that there are no side effects. In the general case, the substitution of the call to a copy constru...
As @Quasímodo has shown, the search pattern \(abc.*\)\@<!bird\|bird\(.*xyz\)\@! solves your problem. But, why does it work, and why does your original approach not work? What you want to achi...
Some thoughts about your design / code (not repeating what was already said by Derek): You have chosen member _observers of class State to be a list, and member function register to append to ...
One simple possibility to eliminate a set of lines with precisely known content is to use the patch tool. The below code shows an example shell script. The script calls patch on the file to be mo...
Since your code performs a data base operation, the cost of this operation is likely dominating the execution time. The cost of both a return or an exception may be negligible compared to that ope...
One problem of your code is the one that @celtschk already has reported: You start one child process, and that one child process does the area calculation exactly once. Thus, one step towards the ...
Assume this trivial logic puzzle which I have made up: There are three boys, Fred, John and Max. No two of the boys have the same age. Max is older than John. Fred is not the oldest one. Quest...
@InfiniteDissent gives an excellent explanation why such a feature would be problematic from a programming language design perspective. As a consequence, C++ is defined such that the code you wan...
The concept that is important to understand here is the concept of operator precedence. Assume you have an expression a + b * c. What does it mean? You could have the following options: (a + b) ...
To understand the concept of recursive tree traversal, I would like to give you an analogy. Imagine a labyrinth of rooms connected like a tree structure. That is, there is an entry to the first r...
Note: This answer was written for a version of the question that focused on getting rid of the if-else, rather than on an explanation of the workings of the recursive tree-traversal. One way of ge...