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.
Activity for Dirk Herrmann
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Edit | Post #287000 |
Post edited: |
— | about 2 years ago |
Edit | Post #287000 | Initial revision | — | about 2 years ago |
Answer | — |
A: Cast uninitialized variable to (void) 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 already an expression. For the expression `x` the following holds: > 6.5.1 - 2: An identifi... (more) |
— | about 2 years ago |
Comment | Post #286979 |
A cast `(t)e` performs a conversion of the result of expression `e` to type `t`. Expression `e` in this case actually is a an lvalue expression. The cast to `void` in this case may give the compiler the possibility to optimize away the whole expression, but that is to my knowledge not mandatory, bu... (more) |
— | about 2 years ago |
Comment | Post #286974 |
What is the reason you want to do this, and what would be your intended behavior? It may be possible, but maybe the result / effect is still not what you are hoping for. (more) |
— | about 2 years ago |
Edit | Post #286922 |
Post edited: |
— | over 2 years ago |
Edit | Post #286922 | Initial revision | — | over 2 years ago |
Answer | — |
A: Create a list of Niven numbers in Python 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`. This object represents the sequence of numbers from `1` to (not including) `n+2`. At the... (more) |
— | over 2 years ago |
Edit | Post #286914 | Initial revision | — | over 2 years ago |
Answer | — |
A: Is there any benefit to using new? 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/doc/libs/1780/libs/pool/doc/html/boost/defaultuserallocatornewdelete.html. One unusual scenario is... (more) |
— | over 2 years ago |
Edit | Post #286771 | Initial revision | — | over 2 years ago |
Answer | — |
A: How to use grep to print only specific word from a string `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/armandmusl --> armandmusl which, within a sh script, you would use as dirname=`basename "$CCSR"` Note... (more) |
— | over 2 years ago |
Edit | Post #286720 |
Post edited: Distinguished the general case and the case where it is known there are no side effects. |
— | over 2 years ago |
Comment | Post #286720 |
If the compiler _knows_ that there are no side effects, it can perform all kinds of optimizations. And, for the std::string constructor the compiler knows there are no side effects, as it is defined by the standard. The copy elision rules only have relevance where there are known side effects or wh... (more) |
— | over 2 years ago |
Edit | Post #286720 |
Post edited: |
— | over 2 years ago |
Edit | Post #286720 | Initial revision | — | over 2 years ago |
Answer | — |
A: Do you need to use std::move to store a parameter passed by value? 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 constructor by a call to a move constructor could lead to a different behavior: The two constructors might ... (more) |
— | over 2 years ago |
Edit | Post #286628 |
Post edited: Small lexical error |
— | over 2 years ago |
Edit | Post #286627 |
Post edited: Small typo, formatting |
— | over 2 years ago |
Comment | Post #286628 |
To improve readability I would recommend some different name, that also makes the role of the argument more obvious, for example `assert_not_in_binary_if(cond)`. (more) |
— | over 2 years ago |
Suggested Edit | Post #286628 |
Suggested edit: Small lexical error (more) |
helpful | over 2 years ago |
Suggested Edit | Post #286627 |
Suggested edit: Small typo, formatting (more) |
helpful | over 2 years ago |
Edit | Post #286576 | Initial revision | — | over 2 years ago |
Answer | — |
A: Vim: how to search for all instances of a string, except for those that are between two specific strings As @Quasímodo has shown, the search pattern `\(abc.\)\@ (bird if not preceded by "abc") or (bird if not followed by "xyz") This is why @Quasímodo's answer works. Your search pattern `/\(abc.\)\@<!bird\(.xyz\)\@!`, however, has the following meaning: bird, if ((not preceded by "abc") AN... (more) |
— | over 2 years ago |
Comment | Post #286530 |
I agree that a statemachine usually does not receive "actions" but rather events (or "information", as you say).
However, I don't think raising exceptions is a design error. Often there are states which can not plausibly receive certain events. Think of a state machine with states A and B, where o... (more) |
— | over 2 years ago |
Edit | Post #286529 | Initial revision | — | over 2 years ago |
Answer | — |
A: A state machine in Python 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 that list. Consequently, the same observer can be registered more than once, and the order of execu... (more) |
— | over 2 years ago |
Edit | Post #286481 | Initial revision | — | over 2 years ago |
Answer | — |
A: How to open a file and edit its content in groovy script 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 modified (in this case `foo.txt`). The `patch` tool then also gets on the standard input the diff i... (more) |
— | over 2 years ago |
Edit | Post #286440 |
Post edited: Less radical change proposal, avoiding assumptions about OPs intentions |
— | over 2 years ago |
Suggested Edit | Post #286440 |
Suggested edit: Less radical change proposal, avoiding assumptions about OPs intentions (more) |
helpful | over 2 years ago |
Edit | Post #286447 |
Post edited: Added note about floating point to avoid confusion |
— | over 2 years ago |
Edit | Post #286449 | Initial revision | — | over 2 years ago |
Answer | — |
A: Measuring the impact of using exceptions instead of return values in an ASP.NET Core application 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 operation. For example, assume your data base operation takes 6ms, the return takes 1ns, and the excepti... (more) |
— | over 2 years ago |
Edit | Post #286447 |
Post edited: |
— | over 2 years ago |
Suggested Edit | Post #286440 |
Suggested edit: (more) |
declined | over 2 years ago |
Edit | Post #286447 |
Post edited: |
— | over 2 years ago |
Edit | Post #286447 |
Post edited: |
— | over 2 years ago |
Edit | Post #286447 | Initial revision | — | over 2 years ago |
Answer | — |
A: Child process works only once after the parent's two calls to scanf 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 proper solution is to either spawn one child process per calculation, or have the child process also p... (more) |
— | over 2 years ago |
Comment | Post #286440 |
The source code you have pasted is garbled, as if you have pasted it twice. Moreover, it is not clear a) what output you have got and b) what output you would have expected. I don't get the meaning of "the pid that work only one time" - pid is a variable in your code. (more) |
— | over 2 years ago |
Edit | Post #286432 |
Post edited: |
— | over 2 years ago |
Edit | Post #286432 | Initial revision | — | over 2 years ago |
Question | — |
Solving logical puzzle with negation and undefined aspects in Prolog 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. Question 1: Who is the oldest one? Question 2: What could be possible orderings by age? Obviously, Max ... (more) |
— | over 2 years ago |
Comment | Post #286351 |
I would phrase it slightly differently, namely that in your example scenario there would always be two different cases that at run-time would have to be distinguished. Keep in mind that the distinction could also be made by some indirect call through a virtual function table, where, depending on the... (more) |
— | over 2 years ago |
Edit | Post #286400 |
Post edited: |
— | over 2 years ago |
Edit | Post #286400 | Initial revision | — | over 2 years ago |
Answer | — |
A: Why can't a derived class add a const qualifier to a method? @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 wanted to write is no valid C++ code and thus compilers will reject it. Although not directly addressed ... (more) |
— | over 2 years ago |
Comment | Post #286352 |
The stack that a computer program implicitly uses is built of so called stack frames. Whenever a function is called, a new stack frame is created "on top of the stack".
Each stack frame contains information that allows the program to return from the currently executed function to the calling func... (more) |
— | over 2 years ago |
Edit | Post #286372 |
Post edited: The question is about operator precendence rather than type coercion. I was thinking also about changing the title in this direction... |
— | over 2 years ago |
- ← Previous
- 1
- 2
- 3
- Next →