diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-08-08 14:16:31 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-08-08 16:15:07 +0100 |
commit | 8e69c9c459600901b998faee80edf654819e2b5b (patch) | |
tree | aee97c616eb6b0c760d9edf01919db1437082b50 /lib/helpers.h | |
parent | Extract WritePqCopyStrm into its own file (diff) | |
download | mygrate-8e69c9c459600901b998faee80edf654819e2b5b.tar.bz2 mygrate-8e69c9c459600901b998faee80edf654819e2b5b.tar.xz mygrate-8e69c9c459600901b998faee80edf654819e2b5b.zip |
Simplify some bits with concepts
Diffstat (limited to 'lib/helpers.h')
-rw-r--r-- | lib/helpers.h | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/helpers.h b/lib/helpers.h index 5bf1bd8..f09a206 100644 --- a/lib/helpers.h +++ b/lib/helpers.h @@ -8,9 +8,8 @@ #include <utility> namespace MyGrate { - template<std::integral I> constexpr inline auto - bitslice(const I i, uint8_t offset, uint8_t size) + bitslice(const std::integral auto i, uint8_t offset, uint8_t size) { return (i >> offset) & ((1U << size) - 1U); } @@ -25,9 +24,8 @@ namespace MyGrate { return expr; } - template<typename T> constexpr inline auto - mod100_extract(T & i) + mod100_extract(std::integral auto & i) { const auto r {i % 100}; i /= 100; @@ -41,6 +39,7 @@ namespace MyGrate { std::to_string(a) } -> std::same_as<std::string>; }; + template<typename T> concept Viewable = requires(T a) { |