Search:

Type: Posts; User: cyberfish

Page 1 of 20 1 2 3 4

Search: Search took 0.04 seconds.

  1. Thanks yeah that does work.

    Thanks yeah that does work.
  2. Hey I remember you! :) I am indeed doing...

    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...
  3. Function template with a class template type arg

    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...
  4. Replies
    6
    Views
    5,908

    Yeah that would be nice! This is a whole...

    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 =...
  5. Replies
    3
    Views
    5,730

    This works because of the same thing I just...

    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...
  6. Replies
    3
    Views
    5,730

    Ah actually disregard. static_cast would do it....

    Ah actually disregard. static_cast<> would do it. I thought it was technically undefined but it isn't!
  7. Replies
    3
    Views
    5,730

    Converting signed to unsigned

    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...
  8. Replies
    6
    Views
    5,908

    Yeah but then when they try

    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...
  9. Replies
    6
    Views
    5,908

    Because many of the users of my libraries will be...

    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.
  10. Replies
    6
    Views
    5,908

    Handling std::endl without std::ostream

    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...
  11. Yeah definitely. I was reading an article on tips...

    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...
  12. As it turned out, I still had to derive from both...

    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...
  13. I am still in the early planning stages so...

    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...
  14. Inheriting from basic_iostream and streambuf

    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...
  15. Ah! That makes sense. I think I can work it...

    Ah! That makes sense.

    I think I can work it out from type traits and enable_if. Just needed the hint.

    Thanks!
  16. Multiple template specializations with the same body

    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) { ......
  17. Awesome thanks! Yeah I was mostly worried about...

    Awesome thanks! Yeah I was mostly worried about the cache behaviour, and using buckets does solve that! Will give it a try.
  18. Drawing multiple samples from a discrete probability distribution

    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>...
  19. Replies
    103
    Views
    20,056

    I have always been jealous of people who can...

    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!
  20. Replies
    6
    Views
    1,459

    Assuming you have the latest Pentium 4...

    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...
  21. Replies
    14
    Views
    2,280

    Ah! Good old CUDA. The constants are...

    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...
  22. Replies
    14
    Views
    2,280

    That seems fast enough (extended to 64-bit)....

    That seems fast enough (extended to 64-bit). What's the story behind that?
  23. Thread: Won't boot.

    by cyberfish
    Replies
    15
    Views
    1,830

    That sounds like the problem was somewhere else....

    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...
  24. Replies
    14
    Views
    2,280

    I have read your example multiple times, and...

    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...
  25. Replies
    14
    Views
    2,280

    Is there a theoretical basis for this being a bad...

    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...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4