Skip to main content
12 events
when toggle format what by license comment
Nov 10, 2024 at 18:07 comment added indi Where on earth did you find someone saying they’re “equivalent”? I just tried googling “NDEBUG versus _DEBUG”, and the first 4 answers explain that they are different. The 5th is a VS documentation page about _DEBUG that doesn’t mention NDEBUG at all. The 6th is an O’Reilly C++ book page about NDEBUG that doesn’t mention _DEBUG at all. And the 7th is a detailed blog post about debugging options and why “debug build” is a nonsensical concept (also doesn’t mention _DEBUG directly, but does refer to its effects).
Nov 10, 2024 at 17:21 comment added pacmaninbw I was only discussing the errors that throw exceptions in the constructor. Returning std::unexpected for items not found then makes sense. From what I've read so far on the Internet, Visual Studio _DEBUG and !NDEBUG are equivalent. Can you point me to some documentation that doesn't agree with that?
Nov 10, 2024 at 16:18 comment added indi I think you need to tighten up your terminology, because the kind of “error” assert() is meant to check isn’t even in the same category as the kind of “error” std::expected is for. Also, standard C’s NDEBUG macro, GCC’s -g option, and Visual Studio’s _DEBUG compiler intrinsic are all different things, that all do different things, (mostly) unrelated to each other. Which one is correct in your case? Depends what you mean by “error checking”.
Nov 10, 2024 at 13:48 comment added pacmaninbw I'm curious about what you think about just performing the error checking when it is compiled -g (NDEBUG in gcc, _DEUBG in visual studio)? This would make the error checking more like an assert() I have modified the code to check for both NDEBUG and _DEBUG for the debug code.
Nov 10, 2024 at 13:44 comment added pacmaninbw Just FYI, the original version had no error checking. It was pointed out in 2 of the 4 reviews that it might need error checking. The use of std::unordered_map was added for the same reason. The most recent version has been changed to C++23 to make use of some of the features. It no longer requires the special format of the enum.
Nov 5, 2024 at 20:45 comment added indi An implementation of the expected monad was standardized in C++23, but the idea has been around since at least C++11. If you want to use expected monad error handling, it’s really easy to roll your own, and even make it so you can transparently interoperate with or switch to std::expected when C++23 is available. But, honestly, I don’t see the point here; pretty much any errors that happen here are going to be compile-time logic errors, and functionally unrecoverable. Exceptions just make more sense.
Nov 4, 2024 at 15:39 comment added pacmaninbw std::expected and std::unexpected are C++23 features. I don't believe they are available in C++20.
Nov 4, 2024 at 14:38 comment added pacmaninbw protected: versus private: Good catch, left over from when I was trying to make this an abstract class.
Nov 4, 2024 at 14:04 comment added pacmaninbw I have created a chat room specifically for this question and related questions and for the answers to those questions. I'd like you to join the discussion. I find your answers quite educational.
Nov 3, 2024 at 21:35 comment added pacmaninbw Yes, you understand the goal of the code.
Nov 3, 2024 at 21:32 comment added pacmaninbw When I mentioned concepts I wasn't thinking std::concepts. My bad. What I mean was is there any C++ technology (template, class, methods) that could shorten that code.
Nov 3, 2024 at 19:59 history answered indi CC BY-SA 4.0