You are here |
www.think-cell.com | ||
| | | |
www.foonathan.net
|
|
| | | | The size of std::array is known at compile-time given the type. Yet it only provides a regular .size() member function: template struct array { constexpr std::size_t size() const { return N; } }; This is annoying if you're writing generic code that expects some sort of compile-time sized range. | |
| | | |
www.foonathan.net
|
|
| | | | Let me share a useful insight with you: constexpr is a platform. Just like you write code that targets Windows or a microcontroller, you write code that targets compile-time execution. In both cases you restrict yourself to the subset of C++ that works on your target platform, use conditional compilation if your code needs to be portable, and execute it on the desired target platform. You can thus view constexpr as another platform you can target; it just so happens to be run by your compiler. This insig... | |
| | | |
www.foonathan.net
|
|
| | | | In my previous blog post, weve discussed the static constexpr std::integral_constant idiom to specify the size of a range at compile-time. Unlike the standard, our (think-cells) ranges library at think-cell already supports compile-time sizes natively, so I was eager to try the idiom there and see how it works out in practice. namespace tc { template constexpr auto size(Rng&& rng); // runtime-size of a range, like std::ranges::size template requires tc::has_constexpr_size constexpr auto constexpr_size = ... | |
| | | |
www.softdevtube.com
|
|
| | Computers are orders of magnitude faster than when most of us started programming and yet a lot of software runs much slower than it should. Nobody likes progress bars. Slow code provides for a horrible user experience, drains batteries faster, and increases our cloud bill. This session explores some of the reasons why software is |