Liste des Groupes | Revenir à cl c++ |
On Wed, 25 Jun 2025 21:03:15 +0200You made the first reply in this post with grumping, moaning and insulting everyone involved in the development of C++.
David Brown <david.brown@hesbynett.no> wibbled:On 25/06/2025 17:52, Muttley@dastardlyhq.com wrote:Can always rely on you to come out with an insult in the first few lines.IIRC correctly the java version is runtime reflection, the C++ version will>
be compile time which is utterly pointless. If the compiler knows whats thereat compile them then so do you and you can write your code accordingly.>
>
I am not sure what your biggest problem is - your depressive pessimism,
your ignorance, or your lack of imagination. Have you ever actually
You must be a very insecure individual.
Yes.written code in C++? It is /full/ of features where the compiler knowsTemplates save a huge amount of cut and paste and often manual code mods.
something, and the programmer does not want to type it out manually
every time - "auto", templates, constexpr functions, type traits, etc.
constexpr's usualy return a single value that could easily be precomputedConstexpr data (and constexpr functions run at compile-time) return values that /are/ pre-computed. That's the whole point.
either beforehand or just put in a macro.
Meanwhile "if constexpr" seems toI believe that anything that can be achieved with "if constexpr" could also be written using template specialisation, yes. But in more complicated generic code, it is much simpler and clearer to use "if constexpr". So it is "reinventing the wheel" in the same way that for-loops are reinventing the wheel in a language that has while-loops.
just be a reinvention of the wheel in that the exact same can be achieved
with template specialisation.
You won't be surprised to hear I've never yetI am not surprised, no. I get the impression that you stopped learning or thinking about anything new a couple of decades ago.
used a constexpr in any code I've written.
Baring macro complications, you /always/ know the type of "p" because it is in code you wrote. You always know the type of "*p", and you almost always know the size of "*p" - code portable across different sizes of the most common types is rare. So why does the idiom use "sizeof *p" rather than, say, "sizeof(int)" when you have "int * p;" ? People use it because it means that there is no risk of inconsistencies, either when writing the code or during later maintenance. The same applies to using reflection - it means you don't need to re-write things yourself, and you won't make mistakes if there are later changes.Even C idioms like "p = malloc(100 * sizeof *p);" are asking theThe size of p could vary on different architectures so no, thats not always
compiler to fill in something the programmer already knows.
the case.
The C++ /language/ becomes more complicated with each revision, because backwards compatibility means existing features are left even when better alternatives come along. The point is to make the /code/ less complicated.You complain about C++ being complex - features like reflection make itOh please, we hear this cretinous refrain every time they chuck in yet more
/less/ complex in several ways. It makes it far easier to make your own
semantics. I've yet to notice C++ becoming less complicated. The last genuinely
useful features was shared_mutex which frankly should have been in from the
start of adding threads. 3 level locking is a basic part of threading
functionality.
You could start by looking at the proposal paper.There are all sorts of use-cases where reflection will let you writeFeel free to provide some before and after examples of code simplified
simpler C++ code, or write things only once but have the information
available in different forms (enum->string and string->enum being the
typical example).
using it.
Les messages affichés proviennent d'usenet.