Why is modifying a string through a retrieved pointer to its data not allowed?

Why can’t we write directly to this buffer? I’ll state the obvious point: because it’s const. And casting away a const value and then modifying that data is… rude. Now, why is it const? That goes back to the days when copy-on-write was considered a good idea, so std::basic_string had to allow implementations to support … Read more

Does reactive extensions support rolling buffers?

This is possible by combining the built-in Window and Throttle methods of Observable. First, let’s solve the simpler problem where we ignore the maximum count condition: public static IObservable<IList<T>> BufferUntilInactive<T>(this IObservable<T> stream, TimeSpan delay) { var closes = stream.Throttle(delay); return stream.Window(() => closes).SelectMany(window => window.ToList()); } The powerful Window method did the heavy lifting. Now … Read more

cin for an int inputing a char causes Loop that is supposed to check input to go wild

When an error occurs when reading from a stream, an error flag gets set and no more reading is possible until you clear the error flags. That’s why you get an infinite loop. cin.clear(); // clears the error flags // this line discards all the input waiting in the stream cin.ignore(std::numeric_limits<std::streamsize>::max(), ‘\n’); Also, it’s wrong … Read more

Pipe buffer size is 4k or 64k?

The other answers tell you that the pipe size is 64 KB. The reason why PIPE_BUF is 4KB is that PIPE_BUF is the largest size for which writes are guaranteed to be atomic. See http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html