diff --git a/sprout/brainfuck/misa.hpp b/sprout/brainfuck/misa.hpp index a1e588fb..495f474c 100644 --- a/sprout/brainfuck/misa.hpp +++ b/sprout/brainfuck/misa.hpp @@ -31,21 +31,21 @@ namespace sprout { first, last, *sprout::weed::lim::static_size>( sprout::weed::replace('>') - [sprout::weed::lit('>') | "→" | "〜" | "ー"] + [sprout::weed::lit('>') | "\x81\xA8"/*"→"*/ | "\x81\x60"/*"〜"*/ | "\x81\5B"/*"ー"*/] | sprout::weed::replace('<') - [sprout::weed::lit('<') | "←" | "★" | "☆"] + [sprout::weed::lit('<') | "\x81\xA9"/*"←"*/ | "\x81\x9A"/*"★"*/ | "\x81\x99"/*"☆"*/] | sprout::weed::replace('+') - [sprout::weed::lit('+') | "あ" | "ぁ" | "お" | "ぉ"] + [sprout::weed::lit('+') | "\x82\xA0"/*"あ"*/ | "\x82\x9F"/*"ぁ"*/ | "\x82\xA8"/*"お"*/ | "\x82\xA7"/*"ぉ"*/] | sprout::weed::replace('-') - [sprout::weed::lit('-') | "っ" | "ッ"] + [sprout::weed::lit('-') | "\x82\xC1"/*"っ"*/ | "\x83\x62"/*"ッ"*/] | sprout::weed::replace('.') - [sprout::weed::lit('.') | "!"] + [sprout::weed::lit('.') | "\x81\x49"/*"!"*/] | sprout::weed::replace(',') - [sprout::weed::lit(',') | "?"] + [sprout::weed::lit(',') | "\x81\x48"/*"?"*/] | sprout::weed::replace('[') - [sprout::weed::lit('[') | "「" | "『"] + [sprout::weed::lit('[') | "\x81\x75"/*"「"*/ | "\x81\x77"/*"『"*/] | sprout::weed::replace(']') - [sprout::weed::lit(']') | "」" | "』"] + [sprout::weed::lit(']') | "\x81\x76"/*"」"*/ | "\x81\x78"/*"』"*/] | sprout::weed::replace(' ') [sprout::weed::char_] ) diff --git a/sprout/checksum/sha1.hpp b/sprout/checksum/sha1.hpp index 4d979316..c269b5c7 100644 --- a/sprout/checksum/sha1.hpp +++ b/sprout/checksum/sha1.hpp @@ -15,6 +15,9 @@ #include #include #include +#ifdef SPROUT_WORKAROUND_NOT_TERMINATE_RECURSIVE_CONSTEXPR_FUNCTION_TEMPLATE +# include +#endif namespace sprout { static_assert(CHAR_BIT == 8, "CHAR_BIT == 8"); @@ -55,6 +58,133 @@ namespace sprout { ) ; } +#ifdef SPROUT_WORKAROUND_NOT_TERMINATE_RECURSIVE_CONSTEXPR_FUNCTION_TEMPLATE + template + SPROUT_CONSTEXPR sha1 const process( + sprout::array const& h, + sprout::array const& block, + std::size_t block_byte_index, + std::uint64_t bit_count + ) const + { + return block_byte_index != 64 + ? const_type(h, block, block_byte_index, bit_count) + : const_type(h, block, 0, bit_count).process_block() + ; + } + template + SPROUT_CONSTEXPR sha1 const process( + sprout::array const& h, + sprout::array const& block, + std::size_t block_byte_index, + std::uint64_t bit_count + ) const + { + return sprout::throw_recursive_function_template_instantiation_exeeded(); + } + template + SPROUT_CONSTEXPR sha1 const process_block_2( + std::uint32_t a, std::uint32_t b, std::uint32_t c, std::uint32_t d, std::uint32_t e, + std::size_t i, std::uint32_t f, std::uint32_t k + ) const + { + return process_block_1( + sprout::left_rotate(a, 5) + f + e + k + calc_w(i), + a, + sprout::left_rotate(b, 30), + c, + d, + i + 1 + ); + } + template + SPROUT_CONSTEXPR sha1 const process_block_2( + std::uint32_t a, std::uint32_t b, std::uint32_t c, std::uint32_t d, std::uint32_t e, + std::size_t i, std::uint32_t f, std::uint32_t k + ) const + { + return sprout::throw_recursive_function_template_instantiation_exeeded(); + } + template + SPROUT_CONSTEXPR sha1 const process_block_1( + std::uint32_t a, std::uint32_t b, std::uint32_t c, std::uint32_t d, std::uint32_t e, + std::size_t i = 0 + ) const + { + return i < 80 + ? process_block_2( + a, b, c, d, e, + i, + i < 20 ? (b & c) | (~b & d) + : i < 40 ? b ^ c ^ d + : i < 60 ? (b & c) | (b & d) | (c & d) + : b ^ c ^ d + , + i < 20 ? 0x5A827999 + : i < 40 ? 0x6ED9EBA1 + : i < 60 ? 0x8F1BBCDC + : 0xCA62C1D6 + ) + : sha1( + sprout::array{{h_[0] + a, h_[1] + b, h_[2] + c, h_[3] + d, h_[4] + e}}, + block_, + block_byte_index_, + bit_count_ + ) + ; + } + template + SPROUT_CONSTEXPR sha1 const process_block_1( + std::uint32_t a, std::uint32_t b, std::uint32_t c, std::uint32_t d, std::uint32_t e, + std::size_t i = 0 + ) const + { + return sprout::throw_recursive_function_template_instantiation_exeeded(); + } + template + SPROUT_CONSTEXPR sha1 const process_block() const { + return process_block_1(h_[0], h_[1], h_[2], h_[3], h_[4]); + } + template + SPROUT_CONSTEXPR sha1 const process_block() const { + return sprout::throw_recursive_function_template_instantiation_exeeded(); + } + template + SPROUT_CONSTEXPR typename std::enable_if::type + process_block_impl(Iterator first, Iterator last, Args... args) const { + return first == last ? process( + h_, + sprout::make_array(args...), + 64, + bit_count_ + 64 * 8 + ) + : sprout::throw_recursive_function_template_instantiation_exeeded() + ; + } + template + SPROUT_CONSTEXPR typename std::enable_if::type + process_block_impl(Iterator first, Iterator last, Args... args) const { + return sprout::throw_recursive_function_template_instantiation_exeeded(); + } + template + SPROUT_CONSTEXPR typename std::enable_if::type + process_block_impl(Iterator first, Iterator last, Args... args) const { + return first == last ? process( + h_, + sprout::get_internal(sprout::range::fixed::copy(sprout::make_array(args...), sprout::sub(block_, block_byte_index_))), + block_byte_index_ + sizeof...(Args), + bit_count_ + sizeof...(Args) * 8 + ) + : block_byte_index_ + sizeof...(Args) == 64 ? sprout::throw_recursive_function_template_instantiation_exeeded() + : process_block_impl(sprout::next(first), last, args..., *first) + ; + } + template + SPROUT_CONSTEXPR typename std::enable_if::type + process_block_impl(Iterator first, Iterator last, Args... args) const { + return sprout::throw_recursive_function_template_instantiation_exeeded(); + } +#else SPROUT_CONSTEXPR sha1 const process( sprout::array const& h, sprout::array const& block, @@ -68,14 +198,8 @@ namespace sprout { ; } SPROUT_CONSTEXPR sha1 const process_block_2( - std::uint32_t a, - std::uint32_t b, - std::uint32_t c, - std::uint32_t d, - std::uint32_t e, - std::size_t i, - std::uint32_t f, - std::uint32_t k + std::uint32_t a, std::uint32_t b, std::uint32_t c, std::uint32_t d, std::uint32_t e, + std::size_t i, std::uint32_t f, std::uint32_t k ) const { return process_block_1( @@ -88,21 +212,13 @@ namespace sprout { ); } SPROUT_CONSTEXPR sha1 const process_block_1( - std::uint32_t a, - std::uint32_t b, - std::uint32_t c, - std::uint32_t d, - std::uint32_t e, + std::uint32_t a, std::uint32_t b, std::uint32_t c, std::uint32_t d, std::uint32_t e, std::size_t i = 0 ) const { return i < 80 ? process_block_2( - a, - b, - c, - d, - e, + a, b, c, d, e, i, i < 20 ? (b & c) | (~b & d) : i < 40 ? b ^ c ^ d @@ -126,15 +242,8 @@ namespace sprout { return process_block_1(h_[0], h_[1], h_[2], h_[3], h_[4]); } template - SPROUT_CONSTEXPR typename std::enable_if< - sizeof...(Args) == 64, - sha1 const - >::type process_block_impl( - Iterator first, - Iterator last, - Args... args - ) const - { + SPROUT_CONSTEXPR typename std::enable_if::type + process_block_impl(Iterator first, Iterator last, Args... args) const { return first == last ? process( h_, sprout::make_array(args...), @@ -150,15 +259,8 @@ namespace sprout { ; } template - SPROUT_CONSTEXPR typename std::enable_if< - sizeof...(Args) != 64, - sha1 const - >::type process_block_impl( - Iterator first, - Iterator last, - Args... args - ) const - { + SPROUT_CONSTEXPR typename std::enable_if::type + process_block_impl(Iterator first, Iterator last, Args... args) const { return first == last ? process( h_, sprout::get_internal(sprout::range::fixed::copy(sprout::make_array(args...), sprout::sub(block_, block_byte_index_))), @@ -174,6 +276,7 @@ namespace sprout { : process_block_impl(sprout::next(first), last, args..., *first) ; } +#endif SPROUT_CONSTEXPR sha1 const process_one() const { return process( h_, diff --git a/sprout/complex/complex.hpp b/sprout/complex/complex.hpp index 5065a32b..8b808aa4 100644 --- a/sprout/complex/complex.hpp +++ b/sprout/complex/complex.hpp @@ -26,79 +26,77 @@ namespace sprout { T re_; T im_; public: - SPROUT_CONSTEXPR complex(T const& re = T(), T const& im = T()) - : re_(re) - , im_(im) + SPROUT_CONSTEXPR complex(T const& re = T(), T const& im = T()) SPROUT_NOEXCEPT + : re_(re) , im_(im) {} SPROUT_CONSTEXPR complex(complex const&) = default; template - SPROUT_CONSTEXPR complex(complex const& other) - : re_(other.real()) - , im_(other.imag()) + SPROUT_CONSTEXPR complex(complex const& other) SPROUT_NOEXCEPT + : re_(other.real()) , im_(other.imag()) {} - SPROUT_CONSTEXPR T real() const { + SPROUT_CONSTEXPR T real() const SPROUT_NOEXCEPT { return re_; } - void real(T re) { + void real(T re) SPROUT_NOEXCEPT { re_ = re; } - SPROUT_CONSTEXPR T imag() const{ + SPROUT_CONSTEXPR T imag() const SPROUT_NOEXCEPT { return im_; } - void imag(T im) { + void imag(T im) SPROUT_NOEXCEPT { im_ = im; } - complex& operator=(T const& rhs) { + complex& operator=(T const& rhs) SPROUT_NOEXCEPT { re_ = rhs; im_ = T(); return *this; } - complex& operator+=(T const& rhs) { + complex& operator+=(T const& rhs) SPROUT_NOEXCEPT { re_ += rhs; return *this; } - complex& operator-=(T const& rhs) { + complex& operator-=(T const& rhs) SPROUT_NOEXCEPT { re_ -= rhs; return *this; } - complex& operator*=(T const& rhs) { + complex& operator*=(T const& rhs) SPROUT_NOEXCEPT { re_ *= rhs; im_ *= rhs; return *this; } - complex& operator/=(T const& rhs) { + complex& operator/=(T const& rhs) SPROUT_NOEXCEPT { re_ /= rhs; im_ /= rhs; return *this; } complex& operator=(complex const&) = default; template - complex& operator=(complex const& rhs) { + complex& operator=(complex const& rhs) SPROUT_NOEXCEPT { re_ = rhs.real(); im_ = rhs.imag(); return *this; } template - complex& operator+=(complex const& rhs) { + complex& operator+=(complex const& rhs) SPROUT_NOEXCEPT { re_ += rhs.real(); im_ += rhs.imag(); return *this; } template - complex& operator-=(complex const& rhs) { + complex& operator-=(complex const& rhs) SPROUT_NOEXCEPT { re_ -= rhs.real(); im_ -= rhs.imag(); return *this; } template - complex& operator*=(complex const& rhs) { + complex& operator*=(complex const& rhs) SPROUT_NOEXCEPT { return *this = complex( re_ * rhs.real() - im_ * rhs.imag(), re_ * rhs.imag() + im_ * rhs.real() ); } template - complex& operator/=(complex const& rhs) { + complex& operator/=(complex const& rhs) SPROUT_NOEXCEPT { T n = sprout::detail::complex_norm(rhs); return *this = complex( (re_ * rhs.real() + im_ * rhs.imag()) / n, diff --git a/sprout/container/container_traits.hpp b/sprout/container/container_traits.hpp index c01ee016..2bcde15a 100644 --- a/sprout/container/container_traits.hpp +++ b/sprout/container/container_traits.hpp @@ -395,7 +395,7 @@ namespace sprout { struct container_nosy_fixed_size_impl { public: static SPROUT_CONSTEXPR decltype(sprout::detail::container_nosy_static_size::static_size) - fixed_size() { + fixed_size() SPROUT_NOEXCEPT { return sprout::detail::container_nosy_static_size::static_size; } }; @@ -440,7 +440,7 @@ namespace sprout { SPROUT_STATIC_CONSTEXPR size_type static_size = N ; public: static SPROUT_CONSTEXPR size_type - fixed_size() { + fixed_size() SPROUT_NOEXCEPT { return static_size; } }; diff --git a/sprout/rational/rational.hpp b/sprout/rational/rational.hpp index b4963f86..85c23173 100644 --- a/sprout/rational/rational.hpp +++ b/sprout/rational/rational.hpp @@ -35,21 +35,17 @@ namespace sprout { IntType den_; protected: SPROUT_CONSTEXPR rational_impl() - : num_(0) - , den_(1) + : num_(0) , den_(1) {} rational_impl(rational_impl const&) = default; SPROUT_CONSTEXPR rational_impl(param_type n) - : num_(n) - , den_(1) + : num_(n) , den_(1) {} SPROUT_CONSTEXPR rational_impl(param_type n, param_type d) - : num_(n) - , den_(d) + : num_(n) , den_(d) {} SPROUT_CONSTEXPR rational_impl(param_type n, param_type d, param_type g) - : num_(n / g) - , den_(d / g) + : num_(n / g) , den_(d / g) {} }; } // namespace detail @@ -86,11 +82,11 @@ namespace sprout { : base_type(n, d) {} public: - SPROUT_CONSTEXPR rational() + SPROUT_CONSTEXPR rational() SPROUT_NOEXCEPT : base_type() {} rational(rational const&) = default; - SPROUT_CONSTEXPR rational(param_type n) + SPROUT_CONSTEXPR rational(param_type n) SPROUT_NOEXCEPT : base_type(n) {} SPROUT_CONSTEXPR rational(param_type n, param_type d) @@ -98,7 +94,7 @@ namespace sprout { {} rational& operator=(rational const&) = default; - rational& operator=(param_type n) { + rational& operator=(param_type n) SPROUT_NOEXCEPT { return assign(n, 1); } rational& assign(param_type n, param_type d) { @@ -107,10 +103,10 @@ namespace sprout { return *this; } - SPROUT_CONSTEXPR IntType numerator() const { + SPROUT_CONSTEXPR IntType numerator() const SPROUT_NOEXCEPT { return num_; } - SPROUT_CONSTEXPR IntType denominator() const { + SPROUT_CONSTEXPR IntType denominator() const SPROUT_NOEXCEPT { return den_; } @@ -169,29 +165,29 @@ namespace sprout { return *this /= rational(rhs); } - rational& operator++() { + rational& operator++() SPROUT_NOEXCEPT { num_ += den_; return *this; } - rational& operator--() { + rational& operator--() SPROUT_NOEXCEPT { num_ -= den_; return *this; } - rational operator++(int) { + rational operator++(int) SPROUT_NOEXCEPT { rational result(*this); ++*this; return result; } - rational operator--(int) { + rational operator--(int) SPROUT_NOEXCEPT { rational result(*this); --*this; return result; } - SPROUT_CONSTEXPR bool operator!() const { + SPROUT_CONSTEXPR bool operator!() const SPROUT_NOEXCEPT { return !num_; } - SPROUT_CONSTEXPR operator bool() const { + SPROUT_CONSTEXPR operator bool() const SPROUT_NOEXCEPT { return num_ != 0; } public: diff --git a/sprout/uuid/tuple.hpp b/sprout/uuid/tuple.hpp index aba7f2e8..99301db3 100644 --- a/sprout/uuid/tuple.hpp +++ b/sprout/uuid/tuple.hpp @@ -33,6 +33,10 @@ namespace sprout { } // namespace sprout namespace std { +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wmismatched-tags" +#endif // // tuple_size // @@ -52,6 +56,9 @@ namespace std { static_assert(I < 16, "tuple_element<>: index out of range"); typedef sprout::uuids::uuid::value_type type; }; +#if defined(__clang__) +# pragma clang diagnostic pop +#endif } // namespace std #endif // #ifndef SPROUT_UUID_TUPLE_HPP