fix rational: for clang

This commit is contained in:
bolero-MURAKAMI 2013-08-09 22:14:43 +09:00
parent c22735b212
commit 071217f1d4
13 changed files with 66 additions and 86 deletions

View file

@ -44,7 +44,7 @@ namespace sprout {
typedef typename std::iterator_traits<Iterator>::pointer pointer;
typedef typename std::iterator_traits<Iterator>::reference reference;
private:
struct private_constructor_tag {};
struct private_construct_t {};
private:
static SPROUT_CONSTEXPR iterator_type find_next(iterator_type first, iterator_type last, Predicate pred) {
return sprout::adjacent_find(first, last, pred);
@ -62,7 +62,7 @@ namespace sprout {
void satisfy_predicate() {
current = sprout::adjacent_find(current, last, pred);
}
SPROUT_CONSTEXPR adjacent_filter_iterator(Predicate pred, iterator_type it, iterator_type last, private_constructor_tag)
SPROUT_CONSTEXPR adjacent_filter_iterator(Predicate pred, iterator_type it, iterator_type last, private_construct_t)
: current(it)
, last(last)
, pred(pred)
@ -119,7 +119,7 @@ namespace sprout {
return result;
}
SPROUT_CONSTEXPR adjacent_filter_iterator next() const {
return adjacent_filter_iterator(pred, checked_next(find_next(current, last, pred), last), last, private_constructor_tag());
return adjacent_filter_iterator(pred, checked_next(find_next(current, last, pred), last), last, private_construct_t());
}
void swap(adjacent_filter_iterator& other)
SPROUT_NOEXCEPT_EXPR(

View file

@ -45,7 +45,7 @@ namespace sprout {
typedef typename std::iterator_traits<Iterator>::pointer pointer;
typedef typename std::iterator_traits<Iterator>::reference reference;
private:
struct private_constructor_tag {};
struct private_construct_t {};
private:
static SPROUT_CONSTEXPR iterator_type find_next(iterator_type first, iterator_type last, Predicate pred) {
return sprout::find_if(first, last, pred);
@ -68,7 +68,7 @@ namespace sprout {
--current;
}
}
SPROUT_CONSTEXPR filter_iterator(Predicate pred, iterator_type it, iterator_type last, private_constructor_tag)
SPROUT_CONSTEXPR filter_iterator(Predicate pred, iterator_type it, iterator_type last, private_construct_t)
: current(it)
, last(last)
, pred(pred)
@ -132,10 +132,10 @@ namespace sprout {
return temp;
}
SPROUT_CONSTEXPR filter_iterator next() const {
return filter_iterator(pred, find_next(sprout::next(current), last, pred), last, private_constructor_tag());
return filter_iterator(pred, find_next(sprout::next(current), last, pred), last, private_construct_t());
}
SPROUT_CONSTEXPR filter_iterator prev() const {
return filter_iterator(pred, find_prev(sprout::prev(current), pred), last, private_constructor_tag());
return filter_iterator(pred, find_prev(sprout::prev(current), pred), last, private_construct_t());
}
void swap(filter_iterator& other)
SPROUT_NOEXCEPT_EXPR(

View file

@ -47,7 +47,7 @@ namespace sprout {
typedef typename std::iterator_traits<Iterator>::pointer pointer;
typedef typename std::iterator_traits<Iterator>::reference reference;
private:
struct private_constructor_tag {};
struct private_construct_t {};
private:
static SPROUT_CONSTEXPR iterator_type find_next(iterator_type first, iterator_type last, Predicate pred) {
return first == last || pred(*first) ? first
@ -74,7 +74,7 @@ namespace sprout {
--current;
}
}
SPROUT_CONSTEXPR while_iterator(Predicate pred, iterator_type it, iterator_type last, private_constructor_tag)
SPROUT_CONSTEXPR while_iterator(Predicate pred, iterator_type it, iterator_type last, private_construct_t)
: current(it)
, last(last)
, pred(pred)
@ -138,10 +138,10 @@ namespace sprout {
return temp;
}
SPROUT_CONSTEXPR while_iterator next() const {
return while_iterator(pred, find_next(sprout::next(current), last, pred), last, private_constructor_tag());
return while_iterator(pred, find_next(sprout::next(current), last, pred), last, private_construct_t());
}
SPROUT_CONSTEXPR while_iterator prev() const {
return while_iterator(pred, find_prev(sprout::prev(current), pred), last, private_constructor_tag());
return while_iterator(pred, find_prev(sprout::prev(current), pred), last, private_construct_t());
}
void swap(while_iterator& other)
SPROUT_NOEXCEPT_EXPR(

View file

@ -36,7 +36,7 @@ namespace sprout {
return base1_type::modulus - 1;
}
public:
struct private_constructor_tag {};
struct private_construct_t {};
private:
base1_type mlcg1_;
base2_type mlcg2_;
@ -44,7 +44,7 @@ namespace sprout {
SPROUT_CONSTEXPR additive_combine_engine(
base1_type const& mlcg1,
base2_type const& mlcg2,
private_constructor_tag
private_construct_t
)
: mlcg1_(mlcg1)
, mlcg2_(mlcg2)
@ -59,7 +59,7 @@ namespace sprout {
additive_combine_engine(
rnd1.engine(),
rnd2.engine(),
private_constructor_tag()
private_construct_t()
)
);
}

View file

@ -28,7 +28,7 @@ namespace sprout {
public:
typedef IntType result_type;
private:
struct private_constructor_tag {};
struct private_construct_t {};
public:
SPROUT_STATIC_CONSTEXPR IntType multiplier = a;
SPROUT_STATIC_CONSTEXPR IntType increment = b;
@ -56,14 +56,14 @@ namespace sprout {
private:
IntType x_;
private:
SPROUT_CONSTEXPR inversive_congruential_engine(IntType const& x, private_constructor_tag)
SPROUT_CONSTEXPR inversive_congruential_engine(IntType const& x, private_construct_t)
: x_(x)
{}
SPROUT_CONSTEXPR sprout::random::random_result<inversive_congruential_engine>
generate(result_type result) const {
return sprout::random::random_result<inversive_congruential_engine>(
result,
inversive_congruential_engine(result, private_constructor_tag())
inversive_congruential_engine(result, private_construct_t())
);
}
public:

View file

@ -31,7 +31,7 @@ namespace sprout {
public:
typedef UIntType result_type;
private:
struct private_constructor_tag {};
struct private_construct_t {};
public:
SPROUT_STATIC_CONSTEXPR UIntType multiplier = a;
SPROUT_STATIC_CONSTEXPR UIntType increment = c;
@ -60,13 +60,13 @@ namespace sprout {
private:
UIntType x_;
private:
SPROUT_CONSTEXPR linear_congruential_engine(UIntType const& x, private_constructor_tag)
SPROUT_CONSTEXPR linear_congruential_engine(UIntType const& x, private_construct_t)
: x_(x)
{}
SPROUT_CONSTEXPR sprout::random::random_result<linear_congruential_engine> generate(result_type result) const {
return sprout::random::random_result<linear_congruential_engine>(
result,
linear_congruential_engine(result, private_constructor_tag())
linear_congruential_engine(result, private_construct_t())
);
}
public:
@ -141,7 +141,7 @@ namespace sprout {
public:
typedef std::uint32_t result_type;
private:
struct private_constructor_tag {};
struct private_construct_t {};
typedef sprout::random::linear_congruential_engine<
std::uint64_t,
std::uint64_t(0xDEECE66DUL) | (std::uint64_t(0x5) << 32),
@ -161,7 +161,7 @@ namespace sprout {
private:
lcf_type lcf_;
private:
SPROUT_CONSTEXPR rand48(lcf_type const& lcf, private_constructor_tag)
SPROUT_CONSTEXPR rand48(lcf_type const& lcf, private_construct_t)
: lcf_(lcf)
{}
SPROUT_CONSTEXPR sprout::random::random_result<rand48> generate(
@ -170,7 +170,7 @@ namespace sprout {
{
return sprout::random::random_result<rand48>(
lcf_result.result() >> 17,
rand48(lcf_result.engine(), private_constructor_tag())
rand48(lcf_result.engine(), private_construct_t())
);
}
public:

View file

@ -23,7 +23,7 @@ namespace sprout {
public:
typedef UIntType result_type;
private:
struct private_constructor_tag {};
struct private_construct_t {};
public:
SPROUT_STATIC_CONSTEXPR int word_size = w;
SPROUT_STATIC_CONSTEXPR int exponent1 = k;
@ -56,13 +56,13 @@ namespace sprout {
private:
UIntType x_;
private:
SPROUT_CONSTEXPR linear_feedback_shift_engine(UIntType const& x, private_constructor_tag)
SPROUT_CONSTEXPR linear_feedback_shift_engine(UIntType const& x, private_construct_t)
: x_(x)
{}
SPROUT_CONSTEXPR sprout::random::random_result<linear_feedback_shift_engine> generate(result_type result) const {
return sprout::random::random_result<linear_feedback_shift_engine>(
result,
linear_feedback_shift_engine(result, private_constructor_tag())
linear_feedback_shift_engine(result, private_construct_t())
);
}
public:

View file

@ -31,7 +31,7 @@ namespace sprout {
public:
typedef UIntType result_type;
private:
struct private_constructor_tag {};
struct private_construct_t {};
public:
SPROUT_STATIC_CONSTEXPR std::size_t word_size = w;
SPROUT_STATIC_CONSTEXPR std::size_t state_size = n;
@ -86,7 +86,7 @@ namespace sprout {
sprout::array<UIntType, n> x_;
std::size_t i_;
private:
SPROUT_CONSTEXPR mersenne_twister_engine(sprout::array<UIntType, n> const& x, std::size_t i, private_constructor_tag)
SPROUT_CONSTEXPR mersenne_twister_engine(sprout::array<UIntType, n> const& x, std::size_t i, private_construct_t)
: x_(x)
, i_(i)
{}
@ -290,7 +290,7 @@ namespace sprout {
mersenne_twister_engine(
x_,
i_ + 1,
private_constructor_tag()
private_construct_t()
)
);
}
@ -301,7 +301,7 @@ namespace sprout {
args..., x_[m - 1] ^ ((x_[n - 1] & upper_mask) | (x_[0] & lower_mask) >> 1) ^ ((x_[0] & 1) * a)
}},
0,
private_constructor_tag()
private_construct_t()
);
}
template<typename... Args>

View file

@ -32,7 +32,7 @@ namespace sprout {
typedef RealType input_type;
typedef RealType result_type;
private:
struct private_constructor_tag {};
struct private_construct_t {};
public:
//
// param_type
@ -105,7 +105,7 @@ namespace sprout {
SPROUT_CONSTEXPR normal_distribution(
RealType mean, RealType sigma, RealType r1, RealType r2,
RealType cached_rho, bool valid,
private_constructor_tag
private_construct_t
)
: mean_(mean)
, sigma_(sigma)
@ -132,7 +132,7 @@ namespace sprout {
r2,
cached_rho,
valid,
private_constructor_tag()
private_construct_t()
)
);
}

View file

@ -55,7 +55,7 @@ namespace sprout {
typedef UniformRandomNumberGenerator base_type;
typedef typename base_type::result_type result_type;
private:
struct private_constructor_tag {};
struct private_construct_t {};
public:
SPROUT_STATIC_CONSTEXPR std::size_t buffer_size = k;
SPROUT_STATIC_CONSTEXPR std::size_t table_size = k;
@ -97,7 +97,7 @@ namespace sprout {
base_type const& rng,
sprout::array<result_type, k> const& v,
result_type const& y,
private_constructor_tag
private_construct_t
)
: member_type{rng, v, y}
{}
@ -110,7 +110,7 @@ namespace sprout {
rnd.engine(),
sprout::fixed::set(v_, j, rnd.result()),
v_[j],
private_constructor_tag()
private_construct_t()
)
);
}

View file

@ -26,9 +26,8 @@ namespace sprout {
template<typename IntType>
inline SPROUT_CONSTEXPR sprout::rational<IntType>
operator-(rational<IntType> const& r) {
return sprout::detail::make_rational<IntType>(
-r.numerator(), r.denominator(),
sprout::detail::rational_private_constructor_tag()
return sprout::detail::rational_construct_access<IntType>::raw_construct(
-r.numerator(), r.denominator()
);
}
@ -46,9 +45,8 @@ namespace sprout {
IntType g, IntType den, IntType num
)
{
return sprout::detail::make_rational<IntType>(
num / g, den * (rhs.denominator() / g),
sprout::detail::rational_private_constructor_tag()
return sprout::detail::rational_construct_access<IntType>::raw_construct(
num / g, den * (rhs.denominator() / g)
);
}
template<typename IntType>
@ -115,9 +113,8 @@ namespace sprout {
IntType g, IntType den, IntType num
)
{
return sprout::detail::make_rational<IntType>(
num / g, den * (rhs.denominator() / g),
sprout::detail::rational_private_constructor_tag()
return sprout::detail::rational_construct_access<IntType>::raw_construct(
num / g, den * (rhs.denominator() / g)
);
}
template<typename IntType>
@ -184,10 +181,9 @@ namespace sprout {
IntType gcd1, IntType gcd2
)
{
return sprout::detail::make_rational<IntType>(
return sprout::detail::rational_construct_access<IntType>::raw_construct(
(lhs.numerator() / gcd1) * (rhs.numerator() / gcd2),
(lhs.denominator() / gcd2) * (rhs.denominator() / gcd1),
sprout::detail::rational_private_constructor_tag()
(lhs.denominator() / gcd2) * (rhs.denominator() / gcd1)
);
}
} // namespace detail
@ -215,14 +211,8 @@ namespace sprout {
template<typename IntType>
inline SPROUT_CONSTEXPR sprout::rational<IntType>
rational_div_impl_1(IntType num, IntType den) {
return den < IntType(0) ? sprout::detail::make_rational<IntType>(
-num, -den,
sprout::detail::rational_private_constructor_tag()
)
: sprout::detail::make_rational<IntType>(
num, den,
sprout::detail::rational_private_constructor_tag()
)
return den < IntType(0) ? sprout::detail::rational_construct_access<IntType>::raw_construct(-num, -den)
: sprout::detail::rational_construct_access<IntType>::raw_construct(num, den)
;
}
template<typename IntType>

View file

@ -21,15 +21,10 @@ namespace sprout {
class rational;
namespace detail {
struct rational_private_constructor_tag {};
struct rational_private_construct_t {};
template<typename IntType>
inline SPROUT_CONSTEXPR sprout::rational<IntType>
make_rational(
typename sprout::detail::call_traits<IntType>::param_type n,
typename sprout::detail::call_traits<IntType>::param_type d,
sprout::detail::rational_private_constructor_tag
);
class rational_construct_access;
} // namespace detail
namespace detail {
@ -66,11 +61,11 @@ namespace sprout {
: private sprout::detail::rational_impl<IntType>
{
static_assert(sprout::numeric_limits<IntType>::is_specialized, "sprout::numeric_limits<IntType>::is_specialized");
friend class sprout::detail::rational_construct_access<IntType>;
public:
typedef IntType int_type;
typedef typename sprout::detail::call_traits<IntType>::param_type param_type;
private:
struct private_constructor_tag {};
typedef sprout::detail::rational_impl<IntType> base_type;
private:
static SPROUT_CONSTEXPR IntType normalize_g_1(IntType den, IntType g) {
@ -86,7 +81,7 @@ namespace sprout {
using base_type::num_;
using base_type::den_;
private:
SPROUT_CONSTEXPR rational(param_type n, param_type d, private_constructor_tag)
SPROUT_CONSTEXPR rational(sprout::detail::rational_private_construct_t, param_type n, param_type d)
: base_type(n, d)
{}
public:
@ -198,28 +193,24 @@ namespace sprout {
SPROUT_CONSTEXPR operator bool() const SPROUT_NOEXCEPT {
return num_ != 0;
}
public:
friend sprout::rational<IntType> sprout::detail::make_rational<IntType>(
typename sprout::detail::call_traits<IntType>::param_type n,
typename sprout::detail::call_traits<IntType>::param_type d,
sprout::detail::rational_private_constructor_tag
);
};
namespace detail {
template<typename IntType>
inline SPROUT_CONSTEXPR sprout::rational<IntType>
make_rational(
typename sprout::detail::call_traits<IntType>::param_type n,
typename sprout::detail::call_traits<IntType>::param_type d,
sprout::detail::rational_private_constructor_tag
)
{
return sprout::rational<IntType>(
n, d,
typename sprout::rational<IntType>::private_constructor_tag()
);
}
class rational_construct_access {
public:
static SPROUT_CONSTEXPR sprout::rational<IntType>
raw_construct(
typename sprout::detail::call_traits<IntType>::param_type n,
typename sprout::detail::call_traits<IntType>::param_type d
)
{
return sprout::rational<IntType>(
sprout::detail::rational_private_construct_t(),
n, d
);
}
};
} // namespace detail
} // namespace sprout

View file

@ -20,9 +20,8 @@ namespace sprout {
inline SPROUT_CONSTEXPR sprout::rational<IntType>
abs(sprout::rational<IntType> const& x) {
return x.numerator() >= IntType(0) ? x
: sprout::detail::make_rational<IntType>(
-x.numerator(), x.denominator(),
sprout::detail::rational_private_constructor_tag()
: sprout::detail::rational_construct_access<IntType>::raw_construct(
-x.numerator(), x.denominator()
)
;
}