template<typename T>
bool from_string( const char* Str, T & Dest )
{
// créer un flux à partir de la chaîne donnée
std::istringstream iss( Str );
// tenter la conversion vers Dest
return iss >> Dest != 0;
}
How do you know that? >> returns a ostream which I can't find anything on what number is evals to.fluffrabbit {l Wrote}: returning whether or not it was successful.
ACtually It was Visual Cfluffrabbit {l Wrote}:ithout explanation because GCC doesn't always do a great joI care so little for C++ streams that I did not check the docs for that. Good find! I guess DrAltaica found this in a project somewhere, tried to compile it, and it failed wb of explaining things. Try Clang (in this case clang++) instead of g++ or $(CXX) or whatever.
DrAltaica {l Wrote}:How do you know that? >> returns a ostream which I can't find anything on what number is evals to.fluffrabbit {l Wrote}: returning whether or not it was successful.
C++ has text streams for a long time
The API still works in terms of char which means reinterpret_cast if you use std::byte in your code base.
If you want to do IO in memory, you're stuck with string streams that operate using std::string. Most binary data is stored in std::vector which leads to awful performance due to unnecessary copies.
There is no agreed standard for customization points for binary IO.
fluffrabbit {l Wrote}:C++ has text streams for a long time
Should be "C++ has had text streams for a long time"
fluffrabbit {l Wrote}:I know reinterpret_cast is the C++ way, but a lot of people (correctly or not) use C-style casts, which have slightly higher computational complexity but take up less space on the line.
fluffrabbit {l Wrote}:If you want to do IO in memory, you're stuck with string streams that operate using std::string. Most binary data is stored in std::vector which leads to awful performance due to unnecessary copies.
That is interesting. I try to use a chunk of memory when loading binary data from files, be it std::string or C-style allocation. I didn't know about the performance issues with std::vector. I always imagined that internally, std::vector calls realloc or something to expand its memory block, and beyond that it just casts chunks of data to a type. That's how I would do it. But yeah, I would like to see this change.
fluffrabbit {l Wrote}:There is no agreed standard for customization points for binary IO.
What do you mean by customization points?
fluffrabbit {l Wrote}:This is a very long document, longer than many an API feature RFC. All that explanation for a very simple feature: streaming stuff into bytes and dealing with the data properly. I hope somebody is excited enough about the C++ standard to read the whole thing and talk about it with the standards committee.
Umm, not sure, link to grammar explanation?
People are free to shoot themselves in the foot, no kind of proposal for C++ will fix that.
Legacy text streams are pretty much hardcoded to std::string. So if you have std::vector, first you need to copy bytes from std::vector to std::string and then move that std::string into the stream. That obviously takes time. Same thing in reverse if you want to assemble network packet in memory.
Lyberta {l Wrote}:There is also related term "niebloid", you can see a bunch of them here. I'm still not sure what is the difference between niebloid and customization point.
Any callable, constexpr-constructible object is colloquially known as a “niebloid,” in honor of Eric Niebler. A CPO is simply a niebloid that wraps a user-definable customization point.
Lyberta {l Wrote}:Niall Douglas who is the head of experimental IO group and author of LLFIO has reviewed my proposal twice and says that it is one of the possible alternatives and he can present it to WG21. So far so good.
Users browsing this forum: No registered users and 1 guest