mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +00:00
fix rational: for clang
This commit is contained in:
parent
c22735b212
commit
071217f1d4
13 changed files with 66 additions and 86 deletions
|
@ -44,7 +44,7 @@ namespace sprout {
|
||||||
typedef typename std::iterator_traits<Iterator>::pointer pointer;
|
typedef typename std::iterator_traits<Iterator>::pointer pointer;
|
||||||
typedef typename std::iterator_traits<Iterator>::reference reference;
|
typedef typename std::iterator_traits<Iterator>::reference reference;
|
||||||
private:
|
private:
|
||||||
struct private_constructor_tag {};
|
struct private_construct_t {};
|
||||||
private:
|
private:
|
||||||
static SPROUT_CONSTEXPR iterator_type find_next(iterator_type first, iterator_type last, Predicate pred) {
|
static SPROUT_CONSTEXPR iterator_type find_next(iterator_type first, iterator_type last, Predicate pred) {
|
||||||
return sprout::adjacent_find(first, last, pred);
|
return sprout::adjacent_find(first, last, pred);
|
||||||
|
@ -62,7 +62,7 @@ namespace sprout {
|
||||||
void satisfy_predicate() {
|
void satisfy_predicate() {
|
||||||
current = sprout::adjacent_find(current, last, pred);
|
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)
|
: current(it)
|
||||||
, last(last)
|
, last(last)
|
||||||
, pred(pred)
|
, pred(pred)
|
||||||
|
@ -119,7 +119,7 @@ namespace sprout {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
SPROUT_CONSTEXPR adjacent_filter_iterator next() const {
|
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)
|
void swap(adjacent_filter_iterator& other)
|
||||||
SPROUT_NOEXCEPT_EXPR(
|
SPROUT_NOEXCEPT_EXPR(
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace sprout {
|
||||||
typedef typename std::iterator_traits<Iterator>::pointer pointer;
|
typedef typename std::iterator_traits<Iterator>::pointer pointer;
|
||||||
typedef typename std::iterator_traits<Iterator>::reference reference;
|
typedef typename std::iterator_traits<Iterator>::reference reference;
|
||||||
private:
|
private:
|
||||||
struct private_constructor_tag {};
|
struct private_construct_t {};
|
||||||
private:
|
private:
|
||||||
static SPROUT_CONSTEXPR iterator_type find_next(iterator_type first, iterator_type last, Predicate pred) {
|
static SPROUT_CONSTEXPR iterator_type find_next(iterator_type first, iterator_type last, Predicate pred) {
|
||||||
return sprout::find_if(first, last, pred);
|
return sprout::find_if(first, last, pred);
|
||||||
|
@ -68,7 +68,7 @@ namespace sprout {
|
||||||
--current;
|
--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)
|
: current(it)
|
||||||
, last(last)
|
, last(last)
|
||||||
, pred(pred)
|
, pred(pred)
|
||||||
|
@ -132,10 +132,10 @@ namespace sprout {
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
SPROUT_CONSTEXPR filter_iterator next() const {
|
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 {
|
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)
|
void swap(filter_iterator& other)
|
||||||
SPROUT_NOEXCEPT_EXPR(
|
SPROUT_NOEXCEPT_EXPR(
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace sprout {
|
||||||
typedef typename std::iterator_traits<Iterator>::pointer pointer;
|
typedef typename std::iterator_traits<Iterator>::pointer pointer;
|
||||||
typedef typename std::iterator_traits<Iterator>::reference reference;
|
typedef typename std::iterator_traits<Iterator>::reference reference;
|
||||||
private:
|
private:
|
||||||
struct private_constructor_tag {};
|
struct private_construct_t {};
|
||||||
private:
|
private:
|
||||||
static SPROUT_CONSTEXPR iterator_type find_next(iterator_type first, iterator_type last, Predicate pred) {
|
static SPROUT_CONSTEXPR iterator_type find_next(iterator_type first, iterator_type last, Predicate pred) {
|
||||||
return first == last || pred(*first) ? first
|
return first == last || pred(*first) ? first
|
||||||
|
@ -74,7 +74,7 @@ namespace sprout {
|
||||||
--current;
|
--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)
|
: current(it)
|
||||||
, last(last)
|
, last(last)
|
||||||
, pred(pred)
|
, pred(pred)
|
||||||
|
@ -138,10 +138,10 @@ namespace sprout {
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
SPROUT_CONSTEXPR while_iterator next() const {
|
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 {
|
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)
|
void swap(while_iterator& other)
|
||||||
SPROUT_NOEXCEPT_EXPR(
|
SPROUT_NOEXCEPT_EXPR(
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace sprout {
|
||||||
return base1_type::modulus - 1;
|
return base1_type::modulus - 1;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
struct private_constructor_tag {};
|
struct private_construct_t {};
|
||||||
private:
|
private:
|
||||||
base1_type mlcg1_;
|
base1_type mlcg1_;
|
||||||
base2_type mlcg2_;
|
base2_type mlcg2_;
|
||||||
|
@ -44,7 +44,7 @@ namespace sprout {
|
||||||
SPROUT_CONSTEXPR additive_combine_engine(
|
SPROUT_CONSTEXPR additive_combine_engine(
|
||||||
base1_type const& mlcg1,
|
base1_type const& mlcg1,
|
||||||
base2_type const& mlcg2,
|
base2_type const& mlcg2,
|
||||||
private_constructor_tag
|
private_construct_t
|
||||||
)
|
)
|
||||||
: mlcg1_(mlcg1)
|
: mlcg1_(mlcg1)
|
||||||
, mlcg2_(mlcg2)
|
, mlcg2_(mlcg2)
|
||||||
|
@ -59,7 +59,7 @@ namespace sprout {
|
||||||
additive_combine_engine(
|
additive_combine_engine(
|
||||||
rnd1.engine(),
|
rnd1.engine(),
|
||||||
rnd2.engine(),
|
rnd2.engine(),
|
||||||
private_constructor_tag()
|
private_construct_t()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace sprout {
|
||||||
public:
|
public:
|
||||||
typedef IntType result_type;
|
typedef IntType result_type;
|
||||||
private:
|
private:
|
||||||
struct private_constructor_tag {};
|
struct private_construct_t {};
|
||||||
public:
|
public:
|
||||||
SPROUT_STATIC_CONSTEXPR IntType multiplier = a;
|
SPROUT_STATIC_CONSTEXPR IntType multiplier = a;
|
||||||
SPROUT_STATIC_CONSTEXPR IntType increment = b;
|
SPROUT_STATIC_CONSTEXPR IntType increment = b;
|
||||||
|
@ -56,14 +56,14 @@ namespace sprout {
|
||||||
private:
|
private:
|
||||||
IntType x_;
|
IntType x_;
|
||||||
private:
|
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)
|
: x_(x)
|
||||||
{}
|
{}
|
||||||
SPROUT_CONSTEXPR sprout::random::random_result<inversive_congruential_engine>
|
SPROUT_CONSTEXPR sprout::random::random_result<inversive_congruential_engine>
|
||||||
generate(result_type result) const {
|
generate(result_type result) const {
|
||||||
return sprout::random::random_result<inversive_congruential_engine>(
|
return sprout::random::random_result<inversive_congruential_engine>(
|
||||||
result,
|
result,
|
||||||
inversive_congruential_engine(result, private_constructor_tag())
|
inversive_congruential_engine(result, private_construct_t())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace sprout {
|
||||||
public:
|
public:
|
||||||
typedef UIntType result_type;
|
typedef UIntType result_type;
|
||||||
private:
|
private:
|
||||||
struct private_constructor_tag {};
|
struct private_construct_t {};
|
||||||
public:
|
public:
|
||||||
SPROUT_STATIC_CONSTEXPR UIntType multiplier = a;
|
SPROUT_STATIC_CONSTEXPR UIntType multiplier = a;
|
||||||
SPROUT_STATIC_CONSTEXPR UIntType increment = c;
|
SPROUT_STATIC_CONSTEXPR UIntType increment = c;
|
||||||
|
@ -60,13 +60,13 @@ namespace sprout {
|
||||||
private:
|
private:
|
||||||
UIntType x_;
|
UIntType x_;
|
||||||
private:
|
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)
|
: x_(x)
|
||||||
{}
|
{}
|
||||||
SPROUT_CONSTEXPR sprout::random::random_result<linear_congruential_engine> generate(result_type result) const {
|
SPROUT_CONSTEXPR sprout::random::random_result<linear_congruential_engine> generate(result_type result) const {
|
||||||
return sprout::random::random_result<linear_congruential_engine>(
|
return sprout::random::random_result<linear_congruential_engine>(
|
||||||
result,
|
result,
|
||||||
linear_congruential_engine(result, private_constructor_tag())
|
linear_congruential_engine(result, private_construct_t())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
@ -141,7 +141,7 @@ namespace sprout {
|
||||||
public:
|
public:
|
||||||
typedef std::uint32_t result_type;
|
typedef std::uint32_t result_type;
|
||||||
private:
|
private:
|
||||||
struct private_constructor_tag {};
|
struct private_construct_t {};
|
||||||
typedef sprout::random::linear_congruential_engine<
|
typedef sprout::random::linear_congruential_engine<
|
||||||
std::uint64_t,
|
std::uint64_t,
|
||||||
std::uint64_t(0xDEECE66DUL) | (std::uint64_t(0x5) << 32),
|
std::uint64_t(0xDEECE66DUL) | (std::uint64_t(0x5) << 32),
|
||||||
|
@ -161,7 +161,7 @@ namespace sprout {
|
||||||
private:
|
private:
|
||||||
lcf_type lcf_;
|
lcf_type lcf_;
|
||||||
private:
|
private:
|
||||||
SPROUT_CONSTEXPR rand48(lcf_type const& lcf, private_constructor_tag)
|
SPROUT_CONSTEXPR rand48(lcf_type const& lcf, private_construct_t)
|
||||||
: lcf_(lcf)
|
: lcf_(lcf)
|
||||||
{}
|
{}
|
||||||
SPROUT_CONSTEXPR sprout::random::random_result<rand48> generate(
|
SPROUT_CONSTEXPR sprout::random::random_result<rand48> generate(
|
||||||
|
@ -170,7 +170,7 @@ namespace sprout {
|
||||||
{
|
{
|
||||||
return sprout::random::random_result<rand48>(
|
return sprout::random::random_result<rand48>(
|
||||||
lcf_result.result() >> 17,
|
lcf_result.result() >> 17,
|
||||||
rand48(lcf_result.engine(), private_constructor_tag())
|
rand48(lcf_result.engine(), private_construct_t())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace sprout {
|
||||||
public:
|
public:
|
||||||
typedef UIntType result_type;
|
typedef UIntType result_type;
|
||||||
private:
|
private:
|
||||||
struct private_constructor_tag {};
|
struct private_construct_t {};
|
||||||
public:
|
public:
|
||||||
SPROUT_STATIC_CONSTEXPR int word_size = w;
|
SPROUT_STATIC_CONSTEXPR int word_size = w;
|
||||||
SPROUT_STATIC_CONSTEXPR int exponent1 = k;
|
SPROUT_STATIC_CONSTEXPR int exponent1 = k;
|
||||||
|
@ -56,13 +56,13 @@ namespace sprout {
|
||||||
private:
|
private:
|
||||||
UIntType x_;
|
UIntType x_;
|
||||||
private:
|
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)
|
: x_(x)
|
||||||
{}
|
{}
|
||||||
SPROUT_CONSTEXPR sprout::random::random_result<linear_feedback_shift_engine> generate(result_type result) const {
|
SPROUT_CONSTEXPR sprout::random::random_result<linear_feedback_shift_engine> generate(result_type result) const {
|
||||||
return sprout::random::random_result<linear_feedback_shift_engine>(
|
return sprout::random::random_result<linear_feedback_shift_engine>(
|
||||||
result,
|
result,
|
||||||
linear_feedback_shift_engine(result, private_constructor_tag())
|
linear_feedback_shift_engine(result, private_construct_t())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace sprout {
|
||||||
public:
|
public:
|
||||||
typedef UIntType result_type;
|
typedef UIntType result_type;
|
||||||
private:
|
private:
|
||||||
struct private_constructor_tag {};
|
struct private_construct_t {};
|
||||||
public:
|
public:
|
||||||
SPROUT_STATIC_CONSTEXPR std::size_t word_size = w;
|
SPROUT_STATIC_CONSTEXPR std::size_t word_size = w;
|
||||||
SPROUT_STATIC_CONSTEXPR std::size_t state_size = n;
|
SPROUT_STATIC_CONSTEXPR std::size_t state_size = n;
|
||||||
|
@ -86,7 +86,7 @@ namespace sprout {
|
||||||
sprout::array<UIntType, n> x_;
|
sprout::array<UIntType, n> x_;
|
||||||
std::size_t i_;
|
std::size_t i_;
|
||||||
private:
|
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)
|
: x_(x)
|
||||||
, i_(i)
|
, i_(i)
|
||||||
{}
|
{}
|
||||||
|
@ -290,7 +290,7 @@ namespace sprout {
|
||||||
mersenne_twister_engine(
|
mersenne_twister_engine(
|
||||||
x_,
|
x_,
|
||||||
i_ + 1,
|
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)
|
args..., x_[m - 1] ^ ((x_[n - 1] & upper_mask) | (x_[0] & lower_mask) >> 1) ^ ((x_[0] & 1) * a)
|
||||||
}},
|
}},
|
||||||
0,
|
0,
|
||||||
private_constructor_tag()
|
private_construct_t()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace sprout {
|
||||||
typedef RealType input_type;
|
typedef RealType input_type;
|
||||||
typedef RealType result_type;
|
typedef RealType result_type;
|
||||||
private:
|
private:
|
||||||
struct private_constructor_tag {};
|
struct private_construct_t {};
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// param_type
|
// param_type
|
||||||
|
@ -105,7 +105,7 @@ namespace sprout {
|
||||||
SPROUT_CONSTEXPR normal_distribution(
|
SPROUT_CONSTEXPR normal_distribution(
|
||||||
RealType mean, RealType sigma, RealType r1, RealType r2,
|
RealType mean, RealType sigma, RealType r1, RealType r2,
|
||||||
RealType cached_rho, bool valid,
|
RealType cached_rho, bool valid,
|
||||||
private_constructor_tag
|
private_construct_t
|
||||||
)
|
)
|
||||||
: mean_(mean)
|
: mean_(mean)
|
||||||
, sigma_(sigma)
|
, sigma_(sigma)
|
||||||
|
@ -132,7 +132,7 @@ namespace sprout {
|
||||||
r2,
|
r2,
|
||||||
cached_rho,
|
cached_rho,
|
||||||
valid,
|
valid,
|
||||||
private_constructor_tag()
|
private_construct_t()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace sprout {
|
||||||
typedef UniformRandomNumberGenerator base_type;
|
typedef UniformRandomNumberGenerator base_type;
|
||||||
typedef typename base_type::result_type result_type;
|
typedef typename base_type::result_type result_type;
|
||||||
private:
|
private:
|
||||||
struct private_constructor_tag {};
|
struct private_construct_t {};
|
||||||
public:
|
public:
|
||||||
SPROUT_STATIC_CONSTEXPR std::size_t buffer_size = k;
|
SPROUT_STATIC_CONSTEXPR std::size_t buffer_size = k;
|
||||||
SPROUT_STATIC_CONSTEXPR std::size_t table_size = k;
|
SPROUT_STATIC_CONSTEXPR std::size_t table_size = k;
|
||||||
|
@ -97,7 +97,7 @@ namespace sprout {
|
||||||
base_type const& rng,
|
base_type const& rng,
|
||||||
sprout::array<result_type, k> const& v,
|
sprout::array<result_type, k> const& v,
|
||||||
result_type const& y,
|
result_type const& y,
|
||||||
private_constructor_tag
|
private_construct_t
|
||||||
)
|
)
|
||||||
: member_type{rng, v, y}
|
: member_type{rng, v, y}
|
||||||
{}
|
{}
|
||||||
|
@ -110,7 +110,7 @@ namespace sprout {
|
||||||
rnd.engine(),
|
rnd.engine(),
|
||||||
sprout::fixed::set(v_, j, rnd.result()),
|
sprout::fixed::set(v_, j, rnd.result()),
|
||||||
v_[j],
|
v_[j],
|
||||||
private_constructor_tag()
|
private_construct_t()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,8 @@ namespace sprout {
|
||||||
template<typename IntType>
|
template<typename IntType>
|
||||||
inline SPROUT_CONSTEXPR sprout::rational<IntType>
|
inline SPROUT_CONSTEXPR sprout::rational<IntType>
|
||||||
operator-(rational<IntType> const& r) {
|
operator-(rational<IntType> const& r) {
|
||||||
return sprout::detail::make_rational<IntType>(
|
return sprout::detail::rational_construct_access<IntType>::raw_construct(
|
||||||
-r.numerator(), r.denominator(),
|
-r.numerator(), r.denominator()
|
||||||
sprout::detail::rational_private_constructor_tag()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,9 +45,8 @@ namespace sprout {
|
||||||
IntType g, IntType den, IntType num
|
IntType g, IntType den, IntType num
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return sprout::detail::make_rational<IntType>(
|
return sprout::detail::rational_construct_access<IntType>::raw_construct(
|
||||||
num / g, den * (rhs.denominator() / g),
|
num / g, den * (rhs.denominator() / g)
|
||||||
sprout::detail::rational_private_constructor_tag()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
template<typename IntType>
|
template<typename IntType>
|
||||||
|
@ -115,9 +113,8 @@ namespace sprout {
|
||||||
IntType g, IntType den, IntType num
|
IntType g, IntType den, IntType num
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return sprout::detail::make_rational<IntType>(
|
return sprout::detail::rational_construct_access<IntType>::raw_construct(
|
||||||
num / g, den * (rhs.denominator() / g),
|
num / g, den * (rhs.denominator() / g)
|
||||||
sprout::detail::rational_private_constructor_tag()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
template<typename IntType>
|
template<typename IntType>
|
||||||
|
@ -184,10 +181,9 @@ namespace sprout {
|
||||||
IntType gcd1, IntType gcd2
|
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.numerator() / gcd1) * (rhs.numerator() / gcd2),
|
||||||
(lhs.denominator() / gcd2) * (rhs.denominator() / gcd1),
|
(lhs.denominator() / gcd2) * (rhs.denominator() / gcd1)
|
||||||
sprout::detail::rational_private_constructor_tag()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
@ -215,14 +211,8 @@ namespace sprout {
|
||||||
template<typename IntType>
|
template<typename IntType>
|
||||||
inline SPROUT_CONSTEXPR sprout::rational<IntType>
|
inline SPROUT_CONSTEXPR sprout::rational<IntType>
|
||||||
rational_div_impl_1(IntType num, IntType den) {
|
rational_div_impl_1(IntType num, IntType den) {
|
||||||
return den < IntType(0) ? sprout::detail::make_rational<IntType>(
|
return den < IntType(0) ? sprout::detail::rational_construct_access<IntType>::raw_construct(-num, -den)
|
||||||
-num, -den,
|
: sprout::detail::rational_construct_access<IntType>::raw_construct(num, den)
|
||||||
sprout::detail::rational_private_constructor_tag()
|
|
||||||
)
|
|
||||||
: sprout::detail::make_rational<IntType>(
|
|
||||||
num, den,
|
|
||||||
sprout::detail::rational_private_constructor_tag()
|
|
||||||
)
|
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
template<typename IntType>
|
template<typename IntType>
|
||||||
|
|
|
@ -21,15 +21,10 @@ namespace sprout {
|
||||||
class rational;
|
class rational;
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
struct rational_private_constructor_tag {};
|
struct rational_private_construct_t {};
|
||||||
|
|
||||||
template<typename IntType>
|
template<typename IntType>
|
||||||
inline SPROUT_CONSTEXPR sprout::rational<IntType>
|
class rational_construct_access;
|
||||||
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
|
|
||||||
);
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
@ -66,11 +61,11 @@ namespace sprout {
|
||||||
: private sprout::detail::rational_impl<IntType>
|
: private sprout::detail::rational_impl<IntType>
|
||||||
{
|
{
|
||||||
static_assert(sprout::numeric_limits<IntType>::is_specialized, "sprout::numeric_limits<IntType>::is_specialized");
|
static_assert(sprout::numeric_limits<IntType>::is_specialized, "sprout::numeric_limits<IntType>::is_specialized");
|
||||||
|
friend class sprout::detail::rational_construct_access<IntType>;
|
||||||
public:
|
public:
|
||||||
typedef IntType int_type;
|
typedef IntType int_type;
|
||||||
typedef typename sprout::detail::call_traits<IntType>::param_type param_type;
|
typedef typename sprout::detail::call_traits<IntType>::param_type param_type;
|
||||||
private:
|
private:
|
||||||
struct private_constructor_tag {};
|
|
||||||
typedef sprout::detail::rational_impl<IntType> base_type;
|
typedef sprout::detail::rational_impl<IntType> base_type;
|
||||||
private:
|
private:
|
||||||
static SPROUT_CONSTEXPR IntType normalize_g_1(IntType den, IntType g) {
|
static SPROUT_CONSTEXPR IntType normalize_g_1(IntType den, IntType g) {
|
||||||
|
@ -86,7 +81,7 @@ namespace sprout {
|
||||||
using base_type::num_;
|
using base_type::num_;
|
||||||
using base_type::den_;
|
using base_type::den_;
|
||||||
private:
|
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)
|
: base_type(n, d)
|
||||||
{}
|
{}
|
||||||
public:
|
public:
|
||||||
|
@ -198,28 +193,24 @@ namespace sprout {
|
||||||
SPROUT_CONSTEXPR operator bool() const SPROUT_NOEXCEPT {
|
SPROUT_CONSTEXPR operator bool() const SPROUT_NOEXCEPT {
|
||||||
return num_ != 0;
|
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 {
|
namespace detail {
|
||||||
template<typename IntType>
|
template<typename IntType>
|
||||||
inline SPROUT_CONSTEXPR sprout::rational<IntType>
|
class rational_construct_access {
|
||||||
make_rational(
|
public:
|
||||||
typename sprout::detail::call_traits<IntType>::param_type n,
|
static SPROUT_CONSTEXPR sprout::rational<IntType>
|
||||||
typename sprout::detail::call_traits<IntType>::param_type d,
|
raw_construct(
|
||||||
sprout::detail::rational_private_constructor_tag
|
typename sprout::detail::call_traits<IntType>::param_type n,
|
||||||
)
|
typename sprout::detail::call_traits<IntType>::param_type d
|
||||||
{
|
)
|
||||||
return sprout::rational<IntType>(
|
{
|
||||||
n, d,
|
return sprout::rational<IntType>(
|
||||||
typename sprout::rational<IntType>::private_constructor_tag()
|
sprout::detail::rational_private_construct_t(),
|
||||||
);
|
n, d
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace sprout
|
} // namespace sprout
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,8 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR sprout::rational<IntType>
|
inline SPROUT_CONSTEXPR sprout::rational<IntType>
|
||||||
abs(sprout::rational<IntType> const& x) {
|
abs(sprout::rational<IntType> const& x) {
|
||||||
return x.numerator() >= IntType(0) ? x
|
return x.numerator() >= IntType(0) ? x
|
||||||
: sprout::detail::make_rational<IntType>(
|
: sprout::detail::rational_construct_access<IntType>::raw_construct(
|
||||||
-x.numerator(), x.denominator(),
|
-x.numerator(), x.denominator()
|
||||||
sprout::detail::rational_private_constructor_tag()
|
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue