Thanks yeah that does work.
Type: Posts; User: cyberfish
Thanks yeah that does work.
Hey I remember you! :)
I am indeed doing something like that, and the reason why I don't want to specify the template parameters directly is because I want to define a bunch of constants that...
Hello!
I am trying to write a function template that takes a class template (with non-type arguments), and my brain (and Google) can't seem to find the right syntax for this.
A few lines of...
Yeah that would be nice!
This is a whole 'nother level of hacky, but it worked!
BufferedOutputStream& operator<<(
std::ostream& (*manipulator)(std::ostream&)) {
using char_type =...
This works because of the same thing I just realized in my own reply above - the standard guarantees that casting a signed type to unsigned preserves the bit pattern in 2's complement (and...
Ah actually disregard. static_cast<> would do it. I thought it was technically undefined but it isn't!
Is there a way to store the absolute value of a signed value into an unsigned type of the same size? I don't want to use a larger type, because this is a template function that will need to work with...
Yeah but then when they try << std::endl, they get a cryptic error message, since most people don't actually know how IO manipulators work under the hood - a function pointer that takes a pointer to...
Because many of the users of my libraries will be reasonably new to C++, so I want to make it behave as much like std::iostream as possible, for simple use cases, from the user's perspective.
I am working on an alternative implementation of input/output streams that have similar semantics to std::istream and std::ostream (for size reasons - on my microcontroller instantiating an...
Yeah definitely. I was reading an article on tips on how to use iostreams, before realizing it was actually written in the early 1990s before standardization! And they have stayed more or less the...
As it turned out, I still had to derive from both streambuf and iostream, because readsome() is the only non-blocking call supported by the iostream interface, and it's seriously inadequate. There...
I am still in the early planning stages so unfortunately not.
Yeah, it's looking like providing a streambuf for the user to wrap in her own iostream is a better way to go.
By async IO I...
Hello!
I am writing a library for an embedded system where I want to provide the user with an std::basic_iostream interface to some peripheral (let's say an UART).
The straightforward way to do...
Ah! That makes sense.
I think I can work it out from type traits and enable_if. Just needed the hint.
Thanks!
Is it possible to do template specializations with the same body for unrelated types?
template <typename T>
void f(T &x) { ... default implementation }
template<>
void f(A &x) { ......
Awesome thanks! Yeah I was mostly worried about the cache behaviour, and using buckets does solve that! Will give it a try.
Given a list of pairs (value and probability), what's a fast way to draw many samples from the distribution?
For example, the input could be something like -
<"bob", 0.25>
<"cindy", 0.5>...
I have always been jealous of people who can cook... I can only cook things with up to 4 ingredients, and I count water as an ingredient!
Assuming you have the latest Pentium 4 (Prescott), one core in the latest i5/i7 would be about 3.5x faster at the same clock speed.
Prescott to Conroe (Core 2 architecture) is where the big jump...
Ah! Good old CUDA.
The constants are 0x155555..., so it basically shifts the number by all even amounts, then xor them together. And to make sure the lower bits aren't too static, the upper bits...
That seems fast enough (extended to 64-bit). What's the story behind that?
That sounds like the problem was somewhere else. Probably a lose connection somewhere that happened to be fixed when you replugged things in.
PSUs don't care which way they are mounted. They are...
I have read your example multiple times, and still don't think I get it.
Are you essentially trying to say Table[3][1 << 15] can happen to be equal to Table[3][0]? Because that's the only case the...
Is there a theoretical basis for this being a bad thing?
In this case, I wouldn't say the higher bits are excluded from changing the computed hash. If they were different, the computed hash would...