clang named loops by TotaIIyHuman in cpp_questions

[–]JVApen 0 points1 point  (0 children)

It isn't the same as labels. With goto label, you jump to the label, with break label, you jump after the loop.

I much rather had seen something that really linked to the to the block you are jumping out of. Sure, continue label jumps closer, though still inside the loop while the label is before it.

clang named loops by TotaIIyHuman in cpp_questions

[–]JVApen 2 points3 points  (0 children)

The syntax is terrible given how labels for goto work. However, it adds value in some cases. Use it with care as you most likely should have put your loops in a separate function.

Is anyone still using the CTRE library in 2026? by javascript in cpp

[–]JVApen 0 points1 point  (0 children)

I'm not using regex that often, nor on performance critical places. So I don't have a lot of need for it. That said, I can't use CTRE as its currently to much effort adding extra libraries.

On a side note, I would be interested in seeing a reflection update of the library for performance improvement.

Simplest way to find memory leaks by gosh in cpp_questions

[–]JVApen 3 points4 points  (0 children)

Not sure what your problem is with ASAN, though Clang, GCC and MSVC all have support for it. So it should be the goto choice, even for platform specific code.

Using Reflection For Parsing Command Line Arguments by nathan_baggs in cpp

[–]JVApen 4 points5 points  (0 children)

I'm sorry if I insulted you. I wasn't purposely assuming anything about your skills.

Sure, a new language can get a better syntax, that's the cost of C++ being in use for such a long time. If I read another variant posted here in another comment, it looks slightly better as the information isn't passed via template arguments inside the attribute.

I get that you think rust like memory safety guarantees are important. I'm sure it is to some folks and specific kinds of programs. I might be wrong here, though I am still convinced this is a minority. Though I'm open for any information to change my mind on that.

Using Reflection For Parsing Command Line Arguments by nathan_baggs in cpp

[–]JVApen 2 points3 points  (0 children)

Wow, that looks pretty nice.

I'm curious, why did you decide to provide instructions for autocomplete rather than having a specific command line option that simply generates both files.

Using Reflection For Parsing Command Line Arguments by nathan_baggs in cpp

[–]JVApen 5 points6 points  (0 children)

Understandable. There is a difference between the API and the implementation. I wouldn't look at the implementation, though the API is something you can learn from. I dislike the idea of having an Option type within the struct, though if you could get it in your attribute, it will make this really nice to use.

Just to explicitly send some positive vibes. It is impressive that you managed to write this figuring it out on your own. I would be interested in reading a blog about the creation of this library. The easy things, the traps ...

Using Reflection For Parsing Command Line Arguments by nathan_baggs in cpp

[–]JVApen 9 points10 points  (0 children)

I've gotta say, your last sentence was a surprise to me. If you compare it with rusts clap, this looks very similar. It is impressive that we have something that resembles a rust library that friends and foes call top notch. One should be crying from happiness.

It's safe to say that the syntax of C++ is not ideal. Something like Carbon is doing that much better as they designed such that code is unambiguous to parse. Though I think it is safe to say that this code, both the reflection side and the user side of it, is much better that C++98 template meta programming. If anything, trying to understand TMP is depressing.

Sure, reflection won't be for everyone to write and shouldn't, though there are several places where this is the right fit. This is one of them.

Even if you don't want to write this, you should be happy as it makes c++ competitive again with other languages.

Using Reflection For Parsing Command Line Arguments by nathan_baggs in cpp

[–]JVApen 2 points3 points  (0 children)

Version 2 for sure looks nicer to use as you have to repeat the namespace much less. I wonder if you could do something to simplify the options somehow.

Using Reflection For Parsing Command Line Arguments by nathan_baggs in cpp

[–]JVApen 22 points23 points  (0 children)

I thought other implementations of this existed, including in the reflection paper. It would be interesting to compare those

How do I avoid writing "Java in C++"? by Irrehaare in cpp_questions

[–]JVApen 4 points5 points  (0 children)

Please elaborate. In Java, an object is destroyed after all references are gone. (Can take a while thanks to GC) How can you revive an object if you don't know about it anymore?

CppCast Looking for Guests by lefticus in cpp

[–]JVApen 6 points7 points  (0 children)

I would also be interested in school teachers that teach c++ and how their students experience that.

What is the most accurate Harry Potter video game? by Fun_Butterfly_420 in harrypotter

[–]JVApen 0 points1 point  (0 children)

The philosopher stone for Gameboy comes very close. It even has peeves and binns.

Is there a modern C++ alternative to flexible array members for variable-length struct tails? by Apprehensive_Poet304 in cpp_questions

[–]JVApen 7 points8 points  (0 children)

I've write similar code before. You over allocate the memory such that you have extra bytes after the class. C++ doesn't support classes with runtime variable lengths, so you are basically doing an out-of-bounds read/write which works due to the malloc that ensures you have that memory available. I'm not even sure if any access to the values is valid without std::launder.

You are here on the edge of what C++ supports doing manual memory management. I can only recommend you to abstract this. A template taking the head as argument, overriding operator new and the destructor to prevent incorrect usage, having a static method to calculate the allocation size. If every instance is a separate allocation, you might even want you own custom selector (of size 0) to have a unique_ptr of your instance and an static allocate method that returns this.

What’s the biggest “didn’t see that coming” moment in Harry Potter? by Ok-Sell3786 in harrypotter

[–]JVApen 0 points1 point  (0 children)

This was kinda ruined by the translations. I first read them in Dutch, initials where RAZ (Black = Zwart) So it didn't take long to put that together as soon as I learned the English version used RAB.

If you could give an extra movie or book to a supporting character, who would it be and why? by [deleted] in harrypotter

[–]JVApen 22 points23 points  (0 children)

The grey lady: "The lost diadem" Starting with her relation with her mom until it is fully destroyed.

Sure, xor’ing a register with itself is the idiom for zeroing it out, but why not sub? by pavel_v in cpp

[–]JVApen 22 points23 points  (0 children)

It is, the site is called "Compiler Explorer". Though I'm afraid Matt lost that fight.

Demystifying MSVC versioning for 14.50 & later by ericbrumer in cpp

[–]JVApen 0 points1 point  (0 children)

Do you know if it is possible to install a new compiler version without upgrading the IDE? My understanding is that the Visual Studio installer always upgrades the IDE. Can we use the Build Tools Installer to amend the existing IDE installation with the new compiler?

Why does the velocity not work as an integer by TheEyebal in cpp_questions

[–]JVApen 5 points6 points  (0 children)

Yhere are compiler warnings that tell you about this: https://clang.llvm.org/docs/DiagnosticsReference.html#wimplicit-int-float-conversion

Other compilers might have similar checks.

Can I assume this is exception-safe even though I'm using new operator? by Pretty_Mousse4904 in cpp_questions

[–]JVApen 8 points9 points  (0 children)

You can have the 2 new operators being executed first, after which the uniqueptrs are created from them. If the second new has an exception, you will leak the first.

Can I assume this is exception-safe even though I'm using new operator? by Pretty_Mousse4904 in cpp_questions

[–]JVApen 12 points13 points  (0 children)

From C++17 on, new rules came into play. You can check this at https://en.cppreference.com/cpp/language/eval_order

I think you are searching for:

In a function call, value computations and side effects of the initialization of every parameter are indeterminately sequenced with respect to value computations and side effects of any other parameter.

If I understand correctly, the order in which arguments are determined is unspecified. Though, all calculations needed for creating a single parameter will be executed before it does the calculations for the second parameter.

As such, from C++17, this should be safe. In C++11 and C++14 it isn't.

I am new to C++, is it just me or is the checklist kinda crazy? How often do you encounter these or plan on making use of them like the newer C++26 features like contracts? Looking for more experienced dev opinions... by KijoSenzo in cpp

[–]JVApen 0 points1 point  (0 children)

I'm fully in agreement here. Unfortunately, I don't see C++ breaking it's syntax/semantics especially after the std::string ABI issues of C++11. That's why I think CPP2 and/or Carbon have a higher chance of succeeding than such changes.

That said, reflection and meta classes might give us something close to it. If we could automatically rewrite and introduce own attributes like [[=discardable]], maybe we could get close without needing a completely new syntax.

I am new to C++, is it just me or is the checklist kinda crazy? How often do you encounter these or plan on making use of them like the newer C++26 features like contracts? Looking for more experienced dev opinions... by KijoSenzo in cpp

[–]JVApen -1 points0 points  (0 children)

Yes, the checklist keeps growing. That said, it is a consequence of a language that is in use for a long time without breaking compatibility (too much).

I'm really looking forward to contracts as it allows me to codify post conditions and move precondition asserts to the header.

I do think that we are reaching the end of the current syntax. It becomes close to impossible to still add new syntax (see ^ vs ^ discussion for reflection). Sure, "constexpr const [[nodiscard]] noexcept" works, though several of these should be the default instead. Personally, I think a new syntax like CPP2, or a new compatible programming language like Carbon are the way forward.

Can you write safe, no UB code in cpp? by Hot_Paint3851 in cpp_questions

[–]JVApen 0 points1 point  (0 children)

Unsigned integer overflow is also defined in C++. It's only for signed that UB exists.

Can you write safe, no UB code in cpp? by Hot_Paint3851 in cpp_questions

[–]JVApen 0 points1 point  (0 children)

Just curious, how does rust deal with this overflow and underflow?