From 1bce2b4a5b0d9d6d91ce9f4929f403dea80cd1eb Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Tue, 29 Oct 2013 17:59:14 +0900 Subject: [PATCH] [sprout.checksum] support for C++14 constexpr --- sprout/checksum/md5.hpp | 18 +++++++++--------- sprout/checksum/sha1.hpp | 14 +++++++------- sprout/checksum/sum.hpp | 14 +++++++------- sprout/checksum/xor.hpp | 10 +++++----- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/sprout/checksum/md5.hpp b/sprout/checksum/md5.hpp index aa076153..6b25d781 100644 --- a/sprout/checksum/md5.hpp +++ b/sprout/checksum/md5.hpp @@ -343,7 +343,7 @@ namespace sprout { static_cast((k_[3] >> 24) & 0xFF) }}; } - void process_block() { + SPROUT_CXX14_CONSTEXPR void process_block() { sprout::array x = sprout::md5_detail::round_all(k_, block_); k_[0] += x[0]; k_[1] += x[1]; @@ -352,7 +352,7 @@ namespace sprout { block_.assign(0); } template - void process_block_impl(InputIterator first, InputIterator last) { + SPROUT_CXX14_CONSTEXPR void process_block_impl(InputIterator first, InputIterator last) { for(; first != last; ++first) { process_byte(*first); } @@ -363,7 +363,7 @@ namespace sprout { , block_{{}} , bit_count_() {} - void reset() { + SPROUT_CXX14_CONSTEXPR void reset() { k_[0] = 0x67452301; k_[1] = 0xEFCDAB89; k_[2] = 0x98BADCFE; @@ -414,7 +414,7 @@ namespace sprout { return process_block(sprout::begin(bytes_range), sprout::end(bytes_range)); } - void process_bit(bool bit) { + SPROUT_CXX14_CONSTEXPR void process_bit(bool bit) { std::size_t index = static_cast(bit_count_ % (64 * 8) / 32); std::size_t offset = static_cast(bit_count_ % 32); block_[index] |= static_cast(bit) << (offset / 8 * 8 + (7 - offset % 8)); @@ -422,27 +422,27 @@ namespace sprout { process_block(); } } - void process_bits(std::uint8_t bits, std::size_t bit_count) { + SPROUT_CXX14_CONSTEXPR void process_bits(std::uint8_t bits, std::size_t bit_count) { while (bit_count--) { process_bit(((bits >> bit_count) & 1) != 0); } } - void process_byte(std::uint8_t byte) { + SPROUT_CXX14_CONSTEXPR void process_byte(std::uint8_t byte) { process_bits(byte, 8); } template - void process_block(InputIterator bytes_begin, InputIterator bytes_end) { + SPROUT_CXX14_CONSTEXPR void process_block(InputIterator bytes_begin, InputIterator bytes_end) { process_block_impl( sprout::make_bytes_iterator(bytes_begin), sprout::make_bytes_iterator(bytes_end) ); } template - void process_bytes(InputIterator buffer, std::size_t byte_count) { + SPROUT_CXX14_CONSTEXPR void process_bytes(InputIterator buffer, std::size_t byte_count) { process_block(buffer, sprout::next(buffer, byte_count)); } template - void process_range(InputRange const& bytes_range) { + SPROUT_CXX14_CONSTEXPR void process_range(InputRange const& bytes_range) { process_block(sprout::begin(bytes_range), sprout::end(bytes_range)); } diff --git a/sprout/checksum/sha1.hpp b/sprout/checksum/sha1.hpp index 15604346..111a1f91 100644 --- a/sprout/checksum/sha1.hpp +++ b/sprout/checksum/sha1.hpp @@ -379,7 +379,7 @@ namespace sprout { static_cast((h_[4]) & 0xFF) }}; } - void process_block() { + SPROUT_CXX14_CONSTEXPR void process_block() { std::uint32_t w[80]; for (std::size_t i = 0; i < 16; ++i) { w[i] = (block_[i * 4 + 0] << 24); @@ -424,7 +424,7 @@ namespace sprout { h_[3] += d; h_[4] += e; } - void process_byte_impl(unsigned char byte) { + SPROUT_CXX14_CONSTEXPR void process_byte_impl(unsigned char byte) { block_[block_byte_index_++] = byte; if (block_byte_index_ == 64) { block_byte_index_ = 0; @@ -444,7 +444,7 @@ namespace sprout { , block_byte_index_() , bit_count_() {} - void reset() { + SPROUT_CXX14_CONSTEXPR void reset() { h_[0] = 0x67452301; h_[1] = 0xEFCDAB89; h_[2] = 0x98BADCFE; @@ -478,23 +478,23 @@ namespace sprout { return process_block(sprout::begin(bytes_range), sprout::end(bytes_range)); } - void process_byte(std::uint8_t byte) { + SPROUT_CXX14_CONSTEXPR void process_byte(std::uint8_t byte) { process_byte_impl(byte); bit_count_ += 8; } template - void process_block(InputIterator bytes_begin, InputIterator bytes_end) { + SPROUT_CXX14_CONSTEXPR void process_block(InputIterator bytes_begin, InputIterator bytes_end) { process_block_impl( sprout::make_bytes_iterator(bytes_begin), sprout::make_bytes_iterator(bytes_end) ); } template - void process_bytes(InputIterator buffer, std::size_t byte_count) { + SPROUT_CXX14_CONSTEXPR void process_bytes(InputIterator buffer, std::size_t byte_count) { process_block(buffer, sprout::next(buffer, byte_count)); } template - void process_range(InputRange const& bytes_range) { + SPROUT_CXX14_CONSTEXPR void process_range(InputRange const& bytes_range) { process_block(sprout::begin(bytes_range), sprout::end(bytes_range)); } diff --git a/sprout/checksum/sum.hpp b/sprout/checksum/sum.hpp index 5cade481..bbb939c0 100644 --- a/sprout/checksum/sum.hpp +++ b/sprout/checksum/sum.hpp @@ -49,12 +49,12 @@ namespace sprout { ); } public: - SPROUT_CONSTEXPR sum_basic() = default; - SPROUT_CONSTEXPR sum_basic(sum_basic const&) = default; + sum_basic() = default; + sum_basic(sum_basic const&) = default; explicit SPROUT_CONSTEXPR sum_basic(sum_type sum) : sum_(sum) {} - void reset(sum_type new_sum = 0) { + SPROUT_CXX14_CONSTEXPR void reset(sum_type new_sum = 0) { sum_ = new_sum; } @@ -74,19 +74,19 @@ namespace sprout { return process_block(sprout::begin(bytes_range), sprout::end(bytes_range)); } - void process_byte(std::uint8_t byte) { + SPROUT_CXX14_CONSTEXPR void process_byte(std::uint8_t byte) { sum_ += byte; } template - void process_block(InputIterator bytes_begin, InputIterator bytes_end) { + SPROUT_CXX14_CONSTEXPR void process_block(InputIterator bytes_begin, InputIterator bytes_end) { sum_ = calc_sum(bytes_begin, bytes_end); } template - void process_bytes(InputIterator buffer, std::size_t byte_count) { + SPROUT_CXX14_CONSTEXPR void process_bytes(InputIterator buffer, std::size_t byte_count) { process_block(buffer, sprout::next(buffer, byte_count)); } template - void process_range(InputRange const& bytes_range) { + SPROUT_CXX14_CONSTEXPR void process_range(InputRange const& bytes_range) { process_block(sprout::begin(bytes_range), sprout::end(bytes_range)); } diff --git a/sprout/checksum/xor.hpp b/sprout/checksum/xor.hpp index f3ee5b78..98ad64a0 100644 --- a/sprout/checksum/xor.hpp +++ b/sprout/checksum/xor.hpp @@ -43,7 +43,7 @@ namespace sprout { explicit SPROUT_CONSTEXPR xor8(sum_type sum) : sum_(sum) {} - void reset(sum_type new_sum = 0) { + SPROUT_CXX14_CONSTEXPR void reset(sum_type new_sum = 0) { sum_ = new_sum; } @@ -63,19 +63,19 @@ namespace sprout { return process_block(sprout::begin(bytes_range), sprout::end(bytes_range)); } - void process_byte(std::uint8_t byte) { + SPROUT_CXX14_CONSTEXPR void process_byte(std::uint8_t byte) { sum_ ^= byte; } template - void process_block(InputIterator bytes_begin, InputIterator bytes_end) { + SPROUT_CXX14_CONSTEXPR void process_block(InputIterator bytes_begin, InputIterator bytes_end) { sum_ = calc_sum(bytes_begin, bytes_end); } template - void process_bytes(InputIterator buffer, std::size_t byte_count) { + SPROUT_CXX14_CONSTEXPR void process_bytes(InputIterator buffer, std::size_t byte_count) { process_block(buffer, sprout::next(buffer, byte_count)); } template - void process_range(InputRange const& bytes_range) { + SPROUT_CXX14_CONSTEXPR void process_range(InputRange const& bytes_range) { process_block(sprout::begin(bytes_range), sprout::end(bytes_range)); }