fix non-const constexpr function call

This commit is contained in:
bolero-MURAKAMI 2016-01-24 18:54:16 +09:00
parent b9440c0e9c
commit 15fc54b379
8 changed files with 124 additions and 58 deletions

View file

@ -279,7 +279,7 @@ namespace sprout {
} }
SPROUT_CONSTEXPR md5 const process_bits_impl(std::uint8_t bits, std::size_t i) const { SPROUT_CONSTEXPR md5 const process_bits_impl(std::uint8_t bits, std::size_t i) const {
return i == 0 ? *this return i == 0 ? *this
: process_bit(((bits >> (i - 1)) & 1) != 0).process_bits_impl(bits, i - 1) : c_process_bit(((bits >> (i - 1)) & 1) != 0).process_bits_impl(bits, i - 1)
; ;
} }
SPROUT_CONSTEXPR md5 const process_byte_impl(std::uint8_t byte, std::size_t index, std::size_t offset) const { SPROUT_CONSTEXPR md5 const process_byte_impl(std::uint8_t byte, std::size_t index, std::size_t offset) const {
@ -304,7 +304,7 @@ namespace sprout {
template<typename InputIterator> template<typename InputIterator>
SPROUT_CONSTEXPR md5 const process_block_impl(InputIterator first, InputIterator last) const { SPROUT_CONSTEXPR md5 const process_block_impl(InputIterator first, InputIterator last) const {
return first == last ? *this return first == last ? *this
: process_byte(*first).process_block_impl(sprout::next(first), last) : c_process_byte(*first).process_block_impl(sprout::next(first), last)
; ;
} }
SPROUT_CONSTEXPR std::uint64_t pad_size() const { SPROUT_CONSTEXPR std::uint64_t pad_size() const {
@ -312,18 +312,18 @@ namespace sprout {
} }
SPROUT_CONSTEXPR md5 const process_padding(std::uint64_t pad_size) const { SPROUT_CONSTEXPR md5 const process_padding(std::uint64_t pad_size) const {
return pad_size == 0 ? *this return pad_size == 0 ? *this
: process_bit(false).process_padding(pad_size - 1) : c_process_bit(false).process_padding(pad_size - 1)
; ;
} }
SPROUT_CONSTEXPR md5 const process_length(std::uint64_t bit_count) const { SPROUT_CONSTEXPR md5 const process_length(std::uint64_t bit_count) const {
return process_byte(static_cast<std::uint8_t>(bit_count & 0xFF)) return c_process_byte(static_cast<std::uint8_t>(bit_count & 0xFF))
.process_byte(static_cast<std::uint8_t>((bit_count >> 8) & 0xFF)) .c_process_byte(static_cast<std::uint8_t>((bit_count >> 8) & 0xFF))
.process_byte(static_cast<std::uint8_t>((bit_count >> 16) & 0xFF)) .c_process_byte(static_cast<std::uint8_t>((bit_count >> 16) & 0xFF))
.process_byte(static_cast<std::uint8_t>((bit_count >> 24) & 0xFF)) .c_process_byte(static_cast<std::uint8_t>((bit_count >> 24) & 0xFF))
.process_byte(static_cast<std::uint8_t>((bit_count >> 32) & 0xFF)) .c_process_byte(static_cast<std::uint8_t>((bit_count >> 32) & 0xFF))
.process_byte(static_cast<std::uint8_t>((bit_count >> 40) & 0xFF)) .c_process_byte(static_cast<std::uint8_t>((bit_count >> 40) & 0xFF))
.process_byte(static_cast<std::uint8_t>((bit_count >> 48) & 0xFF)) .c_process_byte(static_cast<std::uint8_t>((bit_count >> 48) & 0xFF))
.process_byte(static_cast<std::uint8_t>((bit_count >> 56) & 0xFF)) .c_process_byte(static_cast<std::uint8_t>((bit_count >> 56) & 0xFF))
; ;
} }
SPROUT_CONSTEXPR value_type make_value() const { SPROUT_CONSTEXPR value_type make_value() const {
@ -376,45 +376,66 @@ namespace sprout {
} }
SPROUT_CONSTEXPR md5 const process_bit(bool bit) const { SPROUT_CONSTEXPR md5 const process_bit(bool bit) const {
return c_process_bit(bit);
}
SPROUT_CONSTEXPR md5 const process_bits(std::uint8_t bits, std::size_t bit_count) const {
return c_process_bits(bits, bit_count);
}
SPROUT_CONSTEXPR md5 const process_byte(std::uint8_t byte) const {
return c_process_byte(byte);
}
template<typename InputIterator>
SPROUT_CONSTEXPR md5 const process_block(InputIterator bytes_begin, InputIterator bytes_end) const {
return c_process_block(bytes_begin, bytes_end);
}
template<typename InputIterator>
SPROUT_CONSTEXPR md5 const process_bytes(InputIterator buffer, std::size_t byte_count) const {
return c_process_bytes(buffer, byte_count);
}
template<typename InputRange>
SPROUT_CONSTEXPR md5 const process_range(InputRange const& bytes_range) const {
return c_process_range(bytes_range);
}
SPROUT_CONSTEXPR md5 const c_process_bit(bool bit) const {
return process_bit_impl( return process_bit_impl(
bit, bit,
static_cast<std::size_t>(bit_count_ % (64 * 8) / 32), static_cast<std::size_t>(bit_count_ % (64 * 8) / 32),
static_cast<std::size_t>(bit_count_ % 32) static_cast<std::size_t>(bit_count_ % 32)
); );
} }
SPROUT_CONSTEXPR md5 const process_bits(std::uint8_t bits, std::size_t bit_count) const { SPROUT_CONSTEXPR md5 const c_process_bits(std::uint8_t bits, std::size_t bit_count) const {
return process_bits_impl(bits, bit_count); return process_bits_impl(bits, bit_count);
} }
SPROUT_CONSTEXPR md5 const process_byte(std::uint8_t byte) const { SPROUT_CONSTEXPR md5 const c_process_byte(std::uint8_t byte) const {
return bit_count_ % 8 == 0 ? process_byte_impl( return bit_count_ % 8 == 0 ? process_byte_impl(
byte, byte,
static_cast<std::size_t>(bit_count_ % (64 * 8) / 32), static_cast<std::size_t>(bit_count_ % (64 * 8) / 32),
static_cast<std::size_t>(bit_count_ % 32) static_cast<std::size_t>(bit_count_ % 32)
) )
: process_bit(((byte >> 7) & 1) != 0) : c_process_bit(((byte >> 7) & 1) != 0)
.process_bit(((byte >> 6) & 1) != 0) .c_process_bit(((byte >> 6) & 1) != 0)
.process_bit(((byte >> 5) & 1) != 0) .c_process_bit(((byte >> 5) & 1) != 0)
.process_bit(((byte >> 4) & 1) != 0) .c_process_bit(((byte >> 4) & 1) != 0)
.process_bit(((byte >> 3) & 1) != 0) .c_process_bit(((byte >> 3) & 1) != 0)
.process_bit(((byte >> 2) & 1) != 0) .c_process_bit(((byte >> 2) & 1) != 0)
.process_bit(((byte >> 1) & 1) != 0) .c_process_bit(((byte >> 1) & 1) != 0)
.process_bit((byte & 1) != 0) .c_process_bit((byte & 1) != 0)
; ;
} }
template<typename InputIterator> template<typename InputIterator>
SPROUT_CONSTEXPR md5 const process_block(InputIterator bytes_begin, InputIterator bytes_end) const { SPROUT_CONSTEXPR md5 const c_process_block(InputIterator bytes_begin, InputIterator bytes_end) const {
return process_block_impl( return process_block_impl(
sprout::make_bytes_iterator(bytes_begin), sprout::make_bytes_iterator(bytes_begin),
sprout::make_bytes_iterator(bytes_end) sprout::make_bytes_iterator(bytes_end)
); );
} }
template<typename InputIterator> template<typename InputIterator>
SPROUT_CONSTEXPR md5 const process_bytes(InputIterator buffer, std::size_t byte_count) const { SPROUT_CONSTEXPR md5 const c_process_bytes(InputIterator buffer, std::size_t byte_count) const {
return process_block(buffer, sprout::next(buffer, byte_count)); return c_process_block(buffer, sprout::next(buffer, byte_count));
} }
template<typename InputRange> template<typename InputRange>
SPROUT_CONSTEXPR md5 const process_range(InputRange const& bytes_range) const { SPROUT_CONSTEXPR md5 const c_process_range(InputRange const& bytes_range) const {
return process_block(sprout::begin(bytes_range), sprout::end(bytes_range)); return c_process_block(sprout::begin(bytes_range), sprout::end(bytes_range));
} }
SPROUT_CXX14_CONSTEXPR void process_bit(bool bit) { SPROUT_CXX14_CONSTEXPR void process_bit(bool bit) {

View file

@ -263,7 +263,7 @@ namespace sprout {
; ;
} }
SPROUT_CONSTEXPR sha1 const process_block() const { SPROUT_CONSTEXPR sha1 const process_block() const {
return process_block_1(h_[0], h_[1], h_[2], h_[3], h_[4]); return c_process_block();
} }
SPROUT_CONSTEXPR sha1 const c_process_block() const { SPROUT_CONSTEXPR sha1 const c_process_block() const {
return process_block_1(h_[0], h_[1], h_[2], h_[3], h_[4]); return process_block_1(h_[0], h_[1], h_[2], h_[3], h_[4]);
@ -458,6 +458,21 @@ namespace sprout {
} }
SPROUT_CONSTEXPR sha1 const process_byte(std::uint8_t byte) const { SPROUT_CONSTEXPR sha1 const process_byte(std::uint8_t byte) const {
return c_process_byte(byte);
}
template<typename InputIterator>
SPROUT_CONSTEXPR sha1 const process_block(InputIterator bytes_begin, InputIterator bytes_end) const {
return c_process_block(bytes_begin, bytes_end);
}
template<typename InputIterator>
SPROUT_CONSTEXPR sha1 const process_bytes(InputIterator buffer, std::size_t byte_count) const {
return c_process_bytes(buffer, byte_count);
}
template<typename InputRange>
SPROUT_CONSTEXPR sha1 const process_range(InputRange const& bytes_range) const {
return c_process_range(bytes_range);
}
SPROUT_CONSTEXPR sha1 const c_process_byte(std::uint8_t byte) const {
return process( return process(
h_, h_,
sprout::fixed::set(block_, block_.begin() + block_byte_index_, byte), sprout::fixed::set(block_, block_.begin() + block_byte_index_, byte),
@ -466,19 +481,19 @@ namespace sprout {
); );
} }
template<typename InputIterator> template<typename InputIterator>
SPROUT_CONSTEXPR sha1 const process_block(InputIterator bytes_begin, InputIterator bytes_end) const { SPROUT_CONSTEXPR sha1 const c_process_block(InputIterator bytes_begin, InputIterator bytes_end) const {
return process_block_impl( return process_block_impl(
sprout::make_bytes_iterator(bytes_begin), sprout::make_bytes_iterator(bytes_begin),
sprout::make_bytes_iterator(bytes_end) sprout::make_bytes_iterator(bytes_end)
); );
} }
template<typename InputIterator> template<typename InputIterator>
SPROUT_CONSTEXPR sha1 const process_bytes(InputIterator buffer, std::size_t byte_count) const { SPROUT_CONSTEXPR sha1 const c_process_bytes(InputIterator buffer, std::size_t byte_count) const {
return process_block(buffer, sprout::next(buffer, byte_count)); return c_process_block(buffer, sprout::next(buffer, byte_count));
} }
template<typename InputRange> template<typename InputRange>
SPROUT_CONSTEXPR sha1 const process_range(InputRange const& bytes_range) const { SPROUT_CONSTEXPR sha1 const c_process_range(InputRange const& bytes_range) const {
return process_block(sprout::begin(bytes_range), sprout::end(bytes_range)); return c_process_block(sprout::begin(bytes_range), sprout::end(bytes_range));
} }
SPROUT_CXX14_CONSTEXPR void process_byte(std::uint8_t byte) { SPROUT_CXX14_CONSTEXPR void process_byte(std::uint8_t byte) {

View file

@ -59,19 +59,34 @@ namespace sprout {
} }
SPROUT_CONSTEXPR sum_basic const process_byte(std::uint8_t byte) const { SPROUT_CONSTEXPR sum_basic const process_byte(std::uint8_t byte) const {
return sum_basic(sum_ + byte); return c_process_byte(byte);
} }
template<typename InputIterator> template<typename InputIterator>
SPROUT_CONSTEXPR sum_basic const process_block(InputIterator bytes_begin, InputIterator bytes_end) const { SPROUT_CONSTEXPR sum_basic const process_block(InputIterator bytes_begin, InputIterator bytes_end) const {
return sum_basic(calc_sum(bytes_begin, bytes_end)); return c_process_block(bytes_begin, bytes_end);
} }
template<typename InputIterator> template<typename InputIterator>
SPROUT_CONSTEXPR sum_basic const process_bytes(InputIterator buffer, std::size_t byte_count) const { SPROUT_CONSTEXPR sum_basic const process_bytes(InputIterator buffer, std::size_t byte_count) const {
return process_block(buffer, sprout::next(buffer, byte_count)); return c_process_bytes(buffer, byte_count);
} }
template<typename InputRange> template<typename InputRange>
SPROUT_CONSTEXPR sum_basic const process_range(InputRange const& bytes_range) const { SPROUT_CONSTEXPR sum_basic const process_range(InputRange const& bytes_range) const {
return process_block(sprout::begin(bytes_range), sprout::end(bytes_range)); return c_process_range(bytes_range);
}
SPROUT_CONSTEXPR sum_basic const c_process_byte(std::uint8_t byte) const {
return sum_basic(sum_ + byte);
}
template<typename InputIterator>
SPROUT_CONSTEXPR sum_basic const c_process_block(InputIterator bytes_begin, InputIterator bytes_end) const {
return sum_basic(calc_sum(bytes_begin, bytes_end));
}
template<typename InputIterator>
SPROUT_CONSTEXPR sum_basic const c_process_bytes(InputIterator buffer, std::size_t byte_count) const {
return c_process_block(buffer, sprout::next(buffer, byte_count));
}
template<typename InputRange>
SPROUT_CONSTEXPR sum_basic const c_process_range(InputRange const& bytes_range) const {
return c_process_block(sprout::begin(bytes_range), sprout::end(bytes_range));
} }
SPROUT_CXX14_CONSTEXPR void process_byte(std::uint8_t byte) { SPROUT_CXX14_CONSTEXPR void process_byte(std::uint8_t byte) {

View file

@ -48,19 +48,34 @@ namespace sprout {
} }
SPROUT_CONSTEXPR xor8 const process_byte(std::uint8_t byte) const { SPROUT_CONSTEXPR xor8 const process_byte(std::uint8_t byte) const {
return xor8(sum_ ^ byte); return c_process_byte(byte);
} }
template<typename InputIterator> template<typename InputIterator>
SPROUT_CONSTEXPR xor8 const process_block(InputIterator bytes_begin, InputIterator bytes_end) const { SPROUT_CONSTEXPR xor8 const process_block(InputIterator bytes_begin, InputIterator bytes_end) const {
return xor8(calc_sum(bytes_begin, bytes_end)); return c_process_block(bytes_begin, bytes_end);
} }
template<typename InputIterator> template<typename InputIterator>
SPROUT_CONSTEXPR xor8 const process_bytes(InputIterator buffer, std::size_t byte_count) const { SPROUT_CONSTEXPR xor8 const process_bytes(InputIterator buffer, std::size_t byte_count) const {
return process_block(buffer, sprout::next(buffer, byte_count)); return c_process_bytes(buffer, byte_count);
} }
template<typename InputRange> template<typename InputRange>
SPROUT_CONSTEXPR xor8 const process_range(InputRange const& bytes_range) const { SPROUT_CONSTEXPR xor8 const process_range(InputRange const& bytes_range) const {
return process_block(sprout::begin(bytes_range), sprout::end(bytes_range)); return c_process_range(bytes_range);
}
SPROUT_CONSTEXPR xor8 const c_process_byte(std::uint8_t byte) const {
return xor8(sum_ ^ byte);
}
template<typename InputIterator>
SPROUT_CONSTEXPR xor8 const c_process_block(InputIterator bytes_begin, InputIterator bytes_end) const {
return xor8(calc_sum(bytes_begin, bytes_end));
}
template<typename InputIterator>
SPROUT_CONSTEXPR xor8 const c_process_bytes(InputIterator buffer, std::size_t byte_count) const {
return c_process_block(buffer, sprout::next(buffer, byte_count));
}
template<typename InputRange>
SPROUT_CONSTEXPR xor8 const c_process_range(InputRange const& bytes_range) const {
return c_process_block(sprout::begin(bytes_range), sprout::end(bytes_range));
} }
SPROUT_CXX14_CONSTEXPR void process_byte(std::uint8_t byte) { SPROUT_CXX14_CONSTEXPR void process_byte(std::uint8_t byte) {

View file

@ -207,7 +207,7 @@ namespace sprout {
struct result_type struct result_type
: public sprout::detail::mem_fn_const_or_non< : public sprout::detail::mem_fn_const_or_non<
Res, Res,
(sizeof(two) == sizeof(check_const<T>(get_ref<T>(), sprout::identity<T*>::type()))) (sizeof(two) == sizeof(check_const<T>(get_ref<T>(), typename sprout::identity<T*>::type())))
> >
{}; {};
template<typename Signature> template<typename Signature>

View file

@ -62,7 +62,7 @@
typename std::enable_if<SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_inherit_if_xxx_constant_def_impl_has_, CONSTANT), NUM)<T>::value>::type \ typename std::enable_if<SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_inherit_if_xxx_constant_def_impl_has_, CONSTANT), NUM)<T>::value>::type \
> { \ > { \
public: \ public: \
SPROUT_STATIC_CONSTEXPR std::size_t ALIAS = T::CONSTANT; \ SPROUT_STATIC_CONSTEXPR typename std::decay<decltype(T::CONSTANT)>::type/*std::size_t*/ ALIAS = T::CONSTANT; \
};/* \ };/* \
template<typename T> \ template<typename T> \
SPROUT_CONSTEXPR_OR_CONST std::size_t NAME< \ SPROUT_CONSTEXPR_OR_CONST std::size_t NAME< \

View file

@ -23,7 +23,7 @@ namespace sprout {
public: public:
typedef sprout::uuids::uuid result_type; typedef sprout::uuids::uuid result_type;
private: private:
typedef typename result_type::value_type value_type; typedef result_type::value_type value_type;
private: private:
sprout::md5 sum_; sprout::md5 sum_;
private: private:
@ -52,26 +52,26 @@ namespace sprout {
} }
public: public:
SPROUT_CONSTEXPR md5_name_generator() SPROUT_CONSTEXPR md5_name_generator()
: sum_(sprout::md5::const_type().process_range(sprout::uuids::uuid{{0}})) : sum_(sprout::md5().c_process_range(sprout::uuids::uuid{{0}}))
{} {}
explicit SPROUT_CONSTEXPR md5_name_generator(sprout::uuids::uuid const& namespace_uuid) explicit SPROUT_CONSTEXPR md5_name_generator(sprout::uuids::uuid const& namespace_uuid)
: sum_(sprout::md5::const_type().process_range(namespace_uuid)) : sum_(sprout::md5().c_process_range(namespace_uuid))
{} {}
template<typename Elem, std::size_t N, typename Traits> template<typename Elem, std::size_t N, typename Traits>
SPROUT_CONSTEXPR result_type operator()(sprout::basic_string<Elem, N, Traits> const& name) const { SPROUT_CONSTEXPR result_type operator()(sprout::basic_string<Elem, N, Traits> const& name) const {
return sha_to_uuid(sum_.process_range(name)); return sha_to_uuid(sum_.c_process_range(name));
} }
SPROUT_CONSTEXPR result_type operator()(char const* name) const { SPROUT_CONSTEXPR result_type operator()(char const* name) const {
return sha_to_uuid(sum_.process_bytes(name, sprout::char_traits<char>::length(name))); return sha_to_uuid(sum_.c_process_bytes(name, sprout::char_traits<char>::length(name)));
} }
SPROUT_CONSTEXPR result_type operator()(wchar_t const* name) const { SPROUT_CONSTEXPR result_type operator()(wchar_t const* name) const {
return sha_to_uuid(sum_.process_bytes(name, sprout::char_traits<wchar_t>::length(name))); return sha_to_uuid(sum_.c_process_bytes(name, sprout::char_traits<wchar_t>::length(name)));
} }
SPROUT_CONSTEXPR result_type operator()(char16_t const* name) const { SPROUT_CONSTEXPR result_type operator()(char16_t const* name) const {
return sha_to_uuid(sum_.process_bytes(name, sprout::char_traits<char16_t>::length(name))); return sha_to_uuid(sum_.c_process_bytes(name, sprout::char_traits<char16_t>::length(name)));
} }
SPROUT_CONSTEXPR result_type operator()(char32_t const* name) const { SPROUT_CONSTEXPR result_type operator()(char32_t const* name) const {
return sha_to_uuid(sum_.process_bytes(name, sprout::char_traits<char32_t>::length(name))); return sha_to_uuid(sum_.c_process_bytes(name, sprout::char_traits<char32_t>::length(name)));
} }
}; };

View file

@ -23,7 +23,7 @@ namespace sprout {
public: public:
typedef sprout::uuids::uuid result_type; typedef sprout::uuids::uuid result_type;
private: private:
typedef typename result_type::value_type value_type; typedef result_type::value_type value_type;
private: private:
sprout::sha1 sum_; sprout::sha1 sum_;
private: private:
@ -52,26 +52,26 @@ namespace sprout {
} }
public: public:
SPROUT_CONSTEXPR sha1_name_generator() SPROUT_CONSTEXPR sha1_name_generator()
: sum_(sprout::sha1::const_type().process_range(sprout::uuids::uuid{{0}})) : sum_(sprout::sha1().c_process_range(sprout::uuids::uuid{{0}}))
{} {}
explicit SPROUT_CONSTEXPR sha1_name_generator(sprout::uuids::uuid const& namespace_uuid) explicit SPROUT_CONSTEXPR sha1_name_generator(sprout::uuids::uuid const& namespace_uuid)
: sum_(sprout::sha1::const_type().process_range(namespace_uuid)) : sum_(sprout::sha1().c_process_range(namespace_uuid))
{} {}
template<typename Elem, std::size_t N, typename Traits> template<typename Elem, std::size_t N, typename Traits>
SPROUT_CONSTEXPR result_type operator()(sprout::basic_string<Elem, N, Traits> const& name) const { SPROUT_CONSTEXPR result_type operator()(sprout::basic_string<Elem, N, Traits> const& name) const {
return sha_to_uuid(sum_.process_range(name)); return sha_to_uuid(sum_.c_process_range(name));
} }
SPROUT_CONSTEXPR result_type operator()(char const* name) const { SPROUT_CONSTEXPR result_type operator()(char const* name) const {
return sha_to_uuid(sum_.process_bytes(name, sprout::char_traits<char>::length(name))); return sha_to_uuid(sum_.c_process_bytes(name, sprout::char_traits<char>::length(name)));
} }
SPROUT_CONSTEXPR result_type operator()(wchar_t const* name) const { SPROUT_CONSTEXPR result_type operator()(wchar_t const* name) const {
return sha_to_uuid(sum_.process_bytes(name, sprout::char_traits<wchar_t>::length(name))); return sha_to_uuid(sum_.c_process_bytes(name, sprout::char_traits<wchar_t>::length(name)));
} }
SPROUT_CONSTEXPR result_type operator()(char16_t const* name) const { SPROUT_CONSTEXPR result_type operator()(char16_t const* name) const {
return sha_to_uuid(sum_.process_bytes(name, sprout::char_traits<char16_t>::length(name))); return sha_to_uuid(sum_.c_process_bytes(name, sprout::char_traits<char16_t>::length(name)));
} }
SPROUT_CONSTEXPR result_type operator()(char32_t const* name) const { SPROUT_CONSTEXPR result_type operator()(char32_t const* name) const {
return sha_to_uuid(sum_.process_bytes(name, sprout::char_traits<char32_t>::length(name))); return sha_to_uuid(sum_.c_process_bytes(name, sprout::char_traits<char32_t>::length(name)));
} }
}; };