void DoSomething(
_In_reads_bytes_(numBytes) const void * p,
_In_ size_t numBytes );
It's an anti-pattern in C++, which causes a lot of bugs and security vulnerabilities. That's why C++ Core Guidelines recommend to use std::span.The beauty and simplicity of the good old C-style void* in C++
161–170 of 182 posts
Re: The beauty and simplicity of the good old C-style void* in C++
#162Makes you wonder why OP is using cpp to begin with if theyre suggesting void*
Re: The beauty and simplicity of the good old C-style void* in C++
#163Earlier quoted context omitted.
Are your seriously comparing the C++ standard committee to the Trump administration? I know you have an axe to grind, but this is getting ridiculous. Where exactly have you seen this "parade of sycophants" in the C++ standards committee? As far as I know, Bjarne is just a regular committee members with just as many votes as everyone else and no veto powers. The committee frequently accepts or rejects proposals agains…
Yes, I am seriously making that comparison. It's not as bad of course but it's certainly enough to make me cringe. > Where exactly have you seen this "parade of sycophants" in the C++ standards committee? AIUI The committee itself operates under the "Chatham House Rule" in which participants agree not to tell anybody who said anything and so we can only see group outcomes for the committee itself. For example 100% af…
Re: The beauty and simplicity of the good old C-style void* in C++
#164Re: The beauty and simplicity of the good old C-style void* in C++
#165Re: The beauty and simplicity of the good old C-style void* in C++
#166Earlier quoted context omitted.
Well if compilation time is an issue, you chose the worst possible language to use. But if you must use C++, you should use the mechanisms that best communicate intent.
It’s this kind of attitude that perpetuates bad compilation time. Templates have to get parsed and instantiated over and over again. Then you need link time optimization to deduplicate all the redundant copies of the same code.
Re: The beauty and simplicity of the good old C-style void* in C++
#167Earlier quoted context omitted.
Are you asserting that WG14 never had the necessary skills among all the members to help improve this proposal, or dare to bring another one during the last 40 years?
This has not much to do with skill. Standardization does not work like this, and I told you this before.
You can tell me the times you wish for, I will keep playing my trumpet until I see something in C that resembles to Modula-2 was offering in safety, nowadays brought back by Zig.
Re: The beauty and simplicity of the good old C-style void* in C++
#168Earlier quoted context omitted.
Are you asserting that WG14 never had the necessary skills among all the members to help improve this proposal, or dare to bring another one during the last 40 years?
> Are you asserting that (...) No, I called out your opinionated ignorance on the topic. > WG14 never had the necessary skills among all the members to help improve this proposal (...) Frankly I don't think you even understand what you're arguing. I mean, to start off, if an idea is feasible then do you think it needs a full blown committee joining forces to magically fix all the problems? > (...) or dare to bring an…
Re: The beauty and simplicity of the good old C-style void* in C++
#169Earlier quoted context omitted.
There's no need: there's std::copy already. Or maybe the idea was to create a typesafe template wrapper around the generic function which is also very common and really nice. No need to create one wrapper per type, a single template should work.
And how was std:copy implemented? Your answer is valid only for a programming language which assumes that the standard library is implemented in another language. C/C++ are supposed to be languages in which any program can be written, unlike languages like Java or Python.
Re: The beauty and simplicity of the good old C-style void* in C++
#170> Why should people complexify and uglify their C++ code with the uint8_t pointer (or std::byte), when void* works just fine?? Fair point (although to be honest: 'complexify' feels a bit of an exaggeration here to me), but the answer to this why is simple: document and express intent clearly. The compiler gave you an error first such that you're forced to consider what you're doing. Any seasoned C++ developer seeing…
> Fair point (although to be honest: 'complexify' feels a bit of an exaggeration here to me) Both uint8_t and std::byte require a header ( or ) which may expose you to platform x config specific build failures if you do any conditional #including, and the latter is a whole damn enum class with a strange adversion to arithmetic, where `byte |= 1` becomes `byte |= std::byte(1)`, `byte += 1` becomes `byte = std::byte(st…
That's the point, std::byte is for opaque bytes. You're not expected to do arithmetic directly just like you can't do arithmetic on void.