4 ms·
This is a "hello world" of C++11 threading. I'm not sure what this is doing on HN.
by knorker 7y ago
This is a "hello world" of C++11 threading.
I'm not sure what this is doing on HN.
- stabbles 7y agoI wonder how many people would know about using return_type = typename std::result_of<F(Args...)>::type though.
- 0xffff2 7y agoIt's a neat trick I hadn't seen before, but it doesn't seem particularly advanced. There are all kinds of things in the STL that I don't remember or care about until I actually need them.
- knorker 7y agoMaybe in this context they shouldn't, either. using return_type = decltype(f(args...)); seems easier to read and "more C++11". Also the "> >" is a pre-C++11 pattern.
- JakobProgsch 7y agoEarlier versions did use decltype but that causes issues with pointers to member functions. See: https://github.com/progschj/ThreadPool/commit/ac2a77d5cc04361d341f63b1d19706a4d1b4943e https://github.com/progschj/ThreadPool/commit/ac2a77d5cc0436... result_of has now been deprecated in newer C++ versions but since this advertises itself as C++11 thread pool I intend to leave it as is.
- Vel0cityX 7y agoIt also has 2.9k stars on GitHub for some reason.
- nomel 7y agoFundamentally concepts are enjoyed by most everyone, including those who are learning about them the first time, especially when they're explained clearly.
- hellofunk 7y agoYou definitely have a different interpretation of "Hello World" than most people. There is some pretty sophisticated syntax happening in this short example. If I were to do a real hello world, it would be more high-level and a lot shorter, but also not as useful as this example.
- joker3 7y agoNot everyone on HN knows about C++11 threading. A "hello world" is of interest to some people.