workaround for clang3.2(sha1)

This commit is contained in:
bolero-MURAKAMI 2012-11-18 23:32:36 +09:00
parent 3fd2451163
commit 5c9a8153de
6 changed files with 189 additions and 85 deletions

View file

@ -31,21 +31,21 @@ namespace sprout {
first, last,
*sprout::weed::lim<sprout::container_traits<Result>::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_]
)

View file

@ -15,6 +15,9 @@
#include <sprout/range/algorithm/fixed/copy.hpp>
#include <sprout/operation/fixed/set.hpp>
#include <sprout/bit/rotate.hpp>
#ifdef SPROUT_WORKAROUND_NOT_TERMINATE_RECURSIVE_CONSTEXPR_FUNCTION_TEMPLATE
# include <sprout/workaround/recursive_function_template.hpp>
#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<int D = 16, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
SPROUT_CONSTEXPR sha1 const process(
sprout::array<std::uint32_t, 5> const& h,
sprout::array<std::uint8_t, 64> 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<D + 1>()
;
}
template<int D = 16, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
SPROUT_CONSTEXPR sha1 const process(
sprout::array<std::uint32_t, 5> const& h,
sprout::array<std::uint8_t, 64> const& block,
std::size_t block_byte_index,
std::uint64_t bit_count
) const
{
return sprout::throw_recursive_function_template_instantiation_exeeded();
}
template<int D, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
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<D + 1>(
sprout::left_rotate(a, 5) + f + e + k + calc_w(i),
a,
sprout::left_rotate(b, 30),
c,
d,
i + 1
);
}
template<int D, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
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<int D, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
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<D + 1>(
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<std::uint32_t, 5>{{h_[0] + a, h_[1] + b, h_[2] + c, h_[3] + d, h_[4] + e}},
block_,
block_byte_index_,
bit_count_
)
;
}
template<int D, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
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<int D, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
SPROUT_CONSTEXPR sha1 const process_block() const {
return process_block_1<D + 1>(h_[0], h_[1], h_[2], h_[3], h_[4]);
}
template<int D, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
SPROUT_CONSTEXPR sha1 const process_block() const {
return sprout::throw_recursive_function_template_instantiation_exeeded();
}
template<int D = 16, typename Iterator, typename... Args, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
SPROUT_CONSTEXPR typename std::enable_if<sizeof...(Args) == 64, sha1 const>::type
process_block_impl(Iterator first, Iterator last, Args... args) const {
return first == last ? process<D + 1>(
h_,
sprout::make_array<std::uint8_t>(args...),
64,
bit_count_ + 64 * 8
)
: sprout::throw_recursive_function_template_instantiation_exeeded()
;
}
template<int D = 16, typename Iterator, typename... Args, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
SPROUT_CONSTEXPR typename std::enable_if<sizeof...(Args) == 64, sha1 const>::type
process_block_impl(Iterator first, Iterator last, Args... args) const {
return sprout::throw_recursive_function_template_instantiation_exeeded();
}
template<int D = 16, typename Iterator, typename... Args, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
SPROUT_CONSTEXPR typename std::enable_if<sizeof...(Args) != 64, sha1 const>::type
process_block_impl(Iterator first, Iterator last, Args... args) const {
return first == last ? process<D + 1>(
h_,
sprout::get_internal(sprout::range::fixed::copy(sprout::make_array<std::uint8_t>(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<D + 1>(sprout::next(first), last, args..., *first)
;
}
template<int D = 16, typename Iterator, typename... Args, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
SPROUT_CONSTEXPR typename std::enable_if<sizeof...(Args) != 64, sha1 const>::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<std::uint32_t, 5> const& h,
sprout::array<std::uint8_t, 64> 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<typename Iterator, typename... Args>
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<sizeof...(Args) == 64, sha1 const>::type
process_block_impl(Iterator first, Iterator last, Args... args) const {
return first == last ? process(
h_,
sprout::make_array<std::uint8_t>(args...),
@ -150,15 +259,8 @@ namespace sprout {
;
}
template<typename Iterator, typename... Args>
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<sizeof...(Args) != 64, sha1 const>::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<std::uint8_t>(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_,

View file

@ -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<typename X>
SPROUT_CONSTEXPR complex(complex<X> const& other)
: re_(other.real())
, im_(other.imag())
SPROUT_CONSTEXPR complex(complex<X> 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<typename X>
complex& operator=(complex<X> const& rhs) {
complex& operator=(complex<X> const& rhs) SPROUT_NOEXCEPT {
re_ = rhs.real();
im_ = rhs.imag();
return *this;
}
template<typename X>
complex& operator+=(complex<X> const& rhs) {
complex& operator+=(complex<X> const& rhs) SPROUT_NOEXCEPT {
re_ += rhs.real();
im_ += rhs.imag();
return *this;
}
template<typename X>
complex& operator-=(complex<X> const& rhs) {
complex& operator-=(complex<X> const& rhs) SPROUT_NOEXCEPT {
re_ -= rhs.real();
im_ -= rhs.imag();
return *this;
}
template<typename X>
complex& operator*=(complex<X> const& rhs) {
complex& operator*=(complex<X> const& rhs) SPROUT_NOEXCEPT {
return *this = complex(
re_ * rhs.real() - im_ * rhs.imag(),
re_ * rhs.imag() + im_ * rhs.real()
);
}
template<typename X>
complex& operator/=(complex<X> const& rhs) {
complex& operator/=(complex<X> const& rhs) SPROUT_NOEXCEPT {
T n = sprout::detail::complex_norm(rhs);
return *this = complex(
(re_ * rhs.real() + im_ * rhs.imag()) / n,

View file

@ -395,7 +395,7 @@ namespace sprout {
struct container_nosy_fixed_size_impl<Container, true> {
public:
static SPROUT_CONSTEXPR decltype(sprout::detail::container_nosy_static_size<Container>::static_size)
fixed_size() {
fixed_size() SPROUT_NOEXCEPT {
return sprout::detail::container_nosy_static_size<Container>::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;
}
};

View file

@ -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:

View file

@ -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