diff options
author | Jack Lloyd <[email protected]> | 2018-09-19 11:56:34 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-10-01 12:54:01 -0400 |
commit | 2230dd96311c8db3294bf10cf58d739061d26102 (patch) | |
tree | e6a42b2c11f6d158cd70243e0bb401f351e3ab94 /src/lib/utils/loadstor.h | |
parent | 8eb900731da945d276f723534af09592213ee582 (diff) |
Make a few simple functions constexpr
This is primarily just to verify that C++11 constexpr works.
Diffstat (limited to 'src/lib/utils/loadstor.h')
-rw-r--r-- | src/lib/utils/loadstor.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/lib/utils/loadstor.h b/src/lib/utils/loadstor.h index 70ad20591..2fb1543b0 100644 --- a/src/lib/utils/loadstor.h +++ b/src/lib/utils/loadstor.h @@ -36,7 +36,7 @@ namespace Botan { * @param input the value to extract from * @return byte byte_num of input */ -template<typename T> inline uint8_t get_byte(size_t byte_num, T input) +template<typename T> inline constexpr uint8_t get_byte(size_t byte_num, T input) { return static_cast<uint8_t>( input >> (((~byte_num)&(sizeof(T)-1)) << 3) @@ -49,7 +49,7 @@ template<typename T> inline uint8_t get_byte(size_t byte_num, T input) * @param i1 the second byte * @return i0 || i1 */ -inline uint16_t make_uint16(uint8_t i0, uint8_t i1) +inline constexpr uint16_t make_uint16(uint8_t i0, uint8_t i1) { return static_cast<uint16_t>((static_cast<uint16_t>(i0) << 8) | i1); } @@ -62,7 +62,7 @@ inline uint16_t make_uint16(uint8_t i0, uint8_t i1) * @param i3 the fourth byte * @return i0 || i1 || i2 || i3 */ -inline uint32_t make_uint32(uint8_t i0, uint8_t i1, uint8_t i2, uint8_t i3) +inline constexpr uint32_t make_uint32(uint8_t i0, uint8_t i1, uint8_t i2, uint8_t i3) { return ((static_cast<uint32_t>(i0) << 24) | (static_cast<uint32_t>(i1) << 16) | @@ -82,8 +82,8 @@ inline uint32_t make_uint32(uint8_t i0, uint8_t i1, uint8_t i2, uint8_t i3) * @param i7 the eighth byte * @return i0 || i1 || i2 || i3 || i4 || i5 || i6 || i7 */ -inline uint64_t make_uint64(uint8_t i0, uint8_t i1, uint8_t i2, uint8_t i3, - uint8_t i4, uint8_t i5, uint8_t i6, uint8_t i7) +inline constexpr uint64_t make_uint64(uint8_t i0, uint8_t i1, uint8_t i2, uint8_t i3, + uint8_t i4, uint8_t i5, uint8_t i6, uint8_t i7) { return ((static_cast<uint64_t>(i0) << 56) | (static_cast<uint64_t>(i1) << 48) | |