New answers tagged

1

You can avoid the complex declaration of j by just post-decrementing i: void dispatch(auto i, auto&& ...f) noexcept(noexcept((f(), ...))) { ((!i-- ? (f(), 0) : 0), ...); } But as JDługosz already pointed out, this is a very convoluted way of dispatching. Also, the compiler is generating quite bad code, equivalent to: if (i++ == j) f[0](); if (...


2

I don't get it. j is the same type as the underlying type of i but without the const, and you could have made that clearer by using an explicit template parameter so you could leave the const out of the deduced type. But the only thing you do is increment it, and since it started at 0, j++ just makes it 1. So why not just initialize it to 1 instead of ...


1

For tic-tac-toe the efficiency of the scoring function doesn't matter much; you can do exhaustive search (as in your scorePosition) because the search space is very small. Perhaps you could encode the positions as a product-of-sum type rather than a tuple of integers, which would eliminate a bunch of error checking: data Coord = C1 | C2 | C3 deriving (Eq, ...


1

Build I believe build scripts are a major part of the code. If nobody can incorporate it into their build, then the piece code is useless. Yours is good, but it seems the default distribution provides pkg-config files. I tried to use pkg_check_modules inside cmake, but after scratching my head for two hours I gave up on doing it by the book, for now (I will ...


Top 50 recent answers are included