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 Ayxan Haqverdili
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Edit | Post #281520 |
Post edited: Qt is not all caps since it's not an abbreviation. |
— | over 3 years ago |
Suggested Edit | Post #281520 |
Suggested edit: Qt is not all caps since it's not an abbreviation. (more) |
helpful | over 3 years ago |
Comment | Post #281520 |
@Lundin [std::auto_ptr](https://en.cppreference.com/w/cpp/memory/auto_ptr) is actually removed from the language in C++17. And ref counter of [std::shared_ptr](https://en.cppreference.com/w/cpp/memory/shared_ptr) is atomic. The thing some people get wrong is that the object pointed by `std::shared_pt... (more) |
— | over 3 years ago |
Comment | Post #281519 |
C++ opted to store sizes of strings with the strings and that avoids all of these problems. Maybe a modern C code base could do similar. Something like `struct String { size_t size; char data[] };`. Sure, it's inefficient for super short strings, but I reckon overuse of `strlen` and other inefficienc... (more) |
— | over 3 years ago |
Edit | Post #281015 |
Post edited: Added some relevant tags |
— | almost 4 years ago |
Suggested Edit | Post #281015 |
Suggested edit: Added some relevant tags (more) |
helpful | almost 4 years ago |
Comment | Post #278896 |
Your CERT C link is broken. (more) |
— | almost 4 years ago |
Comment | Post #281020 |
@Lundin that's exactly what I am saying. OP names every single exception in a specific catch block and handles them all identically. A simpler way is to catch the base class `std::exception`.
(more) |
— | almost 4 years ago |
Edit | Post #281017 |
Post edited: |
— | almost 4 years ago |
Edit | Post #281017 |
Post edited: |
— | almost 4 years ago |
Comment | Post #281020 |
`rotten_tomatoes` could be a subclass of `std::runtime_error` (or some other standard exception) so there is no need to catch and throw another exception. It's good to have `std::exception` as the base class for all exceptions imho. (more) |
— | almost 4 years ago |
Edit | Post #281017 |
Post edited: |
— | almost 4 years ago |
Edit | Post #281017 |
Post edited: |
— | almost 4 years ago |
Edit | Post #281017 |
Post edited: |
— | almost 4 years ago |
Edit | Post #281017 | Initial revision | — | almost 4 years ago |
Answer | — |
A: Multiple catches with almost the same code. One solution would be to catch a more generic base class, like `std::exception`. If all your exceptions derive from that, you should be safe. Another solution I like better is using destructors to do clean-up instead of lots of try-catches. The more clean up is done automatically by destructors, ... (more) |
— | almost 4 years ago |
Edit | Post #277149 |
Post edited: |
— | almost 4 years ago |
Suggested Edit | Post #277149 |
Suggested edit: (more) |
helpful | almost 4 years ago |
Comment | Post #277341 |
`-Werror` can be used to turn all warnings to errors. (more) |
— | almost 4 years ago |
Comment | Post #280967 |
@Ludin Could be done to allow more aggressive optimizations by taking advantage of the fact that strict aliasing applies. The kind of optimization `restrict` allows in C. (more) |
— | almost 4 years ago |
Comment | Post #280967 |
I am assuming `__u8` is an integer type exactly like `unsigned char` except for the strict aliasing rule. So, a function like `void foo(__u8* a, int* b);` can assume that the arguments are pointing to different memory addresses. Would it then be possible for an implementation to do `typedef __u8 uint... (more) |
— | almost 4 years ago |
Comment | Post #280967 |
Could there be an implementation-specific type like `__u8`, which is a distinct type from `unsigned char` even though both are 8 bits? Then `uint8_t` could be an alias for that. (more) |
— | almost 4 years ago |
Edit | Post #280966 |
Post edited: |
— | almost 4 years ago |
Edit | Post #280966 | Initial revision | — | almost 4 years ago |
Question | — |
Is `uint8_t` always an alias for a character type if it exists? Is `uint8t` guaranteed to be a character type if it exists? Will using a `uint8t` to examine bytes of an object cause violation of the strict aliasing rule? Is the following legal code: ``` #include #include #include #include int main() { std::string str{"Hello"}; std::uint8t p = ... (more) |
— | almost 4 years ago |