2009-02-21 01:45:21 +01:00
|
|
|
// ratio -*- C++ -*-
|
2008-07-04 20:45:09 +02:00
|
|
|
|
2020-01-01 12:51:42 +01:00
|
|
|
// Copyright (C) 2008-2020 Free Software Foundation, Inc.
|
2008-07-04 20:45:09 +02:00
|
|
|
//
|
|
|
|
// This file is part of the GNU ISO C++ Library. This library is free
|
2016-06-16 15:47:35 +02:00
|
|
|
// software; you can redistribute it and/or modify it under the
|
|
|
|
// terms of the GNU General Public License as published by the
|
2009-04-09 17:00:19 +02:00
|
|
|
// Free Software Foundation; either version 3, or (at your option)
|
2008-07-04 20:45:09 +02:00
|
|
|
// any later version.
|
|
|
|
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2016-06-16 15:47:35 +02:00
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2008-07-04 20:45:09 +02:00
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
2009-04-09 17:00:19 +02:00
|
|
|
// Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
// permissions described in the GCC Runtime Library Exception, version
|
|
|
|
// 3.1, as published by the Free Software Foundation.
|
2008-07-04 20:45:09 +02:00
|
|
|
|
2009-04-09 17:00:19 +02:00
|
|
|
// You should have received a copy of the GNU General Public License and
|
|
|
|
// a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
// <http://www.gnu.org/licenses/>.
|
2008-07-04 20:45:09 +02:00
|
|
|
|
2010-12-19 10:21:16 +01:00
|
|
|
/** @file include/ratio
|
2008-07-04 20:45:09 +02:00
|
|
|
* This is a Standard C++ Library header.
|
2019-05-08 00:46:53 +02:00
|
|
|
* @ingroup ratio
|
2008-07-04 20:45:09 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _GLIBCXX_RATIO
|
|
|
|
#define _GLIBCXX_RATIO 1
|
|
|
|
|
|
|
|
#pragma GCC system_header
|
|
|
|
|
2012-11-10 18:27:22 +01:00
|
|
|
#if __cplusplus < 201103L
|
2010-02-10 20:14:33 +01:00
|
|
|
# include <bits/c++0x_warning.h>
|
2008-07-04 20:45:09 +02:00
|
|
|
#else
|
|
|
|
|
|
|
|
#include <type_traits>
|
Remove <chrono> dependency on _GLIBCXX_USE_C99_STDINT_TR1
By adding fallback definitions of std::intmax_t and std::uintmax_t it's
possible to define <ratio> without _GLIBCXX_USE_C99_STDINT_TR1. This in
turn allows most of <chrono> to be defined, which removes the dependency
on _GLIBCXX_USE_C99_STDINT_TR1 for all of the C++11 concurrency features.
The compiler defines __INTMAX_TYPE__ and __UINTMAX_TYPE__
unconditionally so it should be safe to rely on them.
* include/bits/atomic_futex.h [!_GLIBCXX_USE_C99_STDINT_TR1]
(__atomic_futex_unsigned_base): Remove dependency on
_GLIBCXX_USE_C99_STDINT_TR1 macro.
* include/bits/unique_lock.h [!_GLIBCXX_USE_C99_STDINT_TR1]
(unique_lock): Remove dependency on _GLIBCXX_USE_C99_STDINT_TR1.
* include/c_global/cstdint [!_GLIBCXX_USE_C99_STDINT_TR1] (intmax_t)
(uintmax_t): Define using predefined macros.
* include/std/chrono [!_GLIBCXX_USE_C99_STDINT_TR1] (duration)
(time_point, system_clock, high_resolution_clock, steady_clock): Remove
dependency on _GLIBCXX_USE_C99_STDINT_TR1 macro.
(nanoseconds, microseconds, milliseconds, seconds, minutes, hours):
[!_GLIBCXX_USE_C99_STDINT_TR1]: Define using __INT64_TYPE__ or
long long when <stdint.h> is not usable.
* include/std/condition_variable [!_GLIBCXX_USE_C99_STDINT_TR1]
(condition_variable, condition_variable_any): Remove dependency on
_GLIBCXX_USE_C99_STDINT_TR1.
* include/std/future [!_GLIBCXX_USE_C99_STDINT_TR1] (future, promise)
(packaged_task, async): Likewise.
* include/std/mutex [!_GLIBCXX_USE_C99_STDINT_TR1] (recursive_mutex)
(timed_mutex, recursive_timed_mutex, try_lock, lock, scoped_lock)
(once_flag, call_once): Likewise.
* include/std/ratio [!_GLIBCXX_USE_C99_STDINT_TR1] (ratio): Likewise.
* include/std/shared_mutex [!_GLIBCXX_USE_C99_STDINT_TR1]
(shared_mutex, shared_timed_mutex, shared_lock): Likewise.
* include/std/thread [!_GLIBCXX_USE_C99_STDINT_TR1] (thread)
(this_thread::get_id, this_thread::yield, this_thread::sleep_for)
(this_thread::sleep_until): Likewise.
* src/c++11/chrono.cc: Remove dependency on
_GLIBCXX_USE_C99_STDINT_TR1 macro.
* src/c++11/condition_variable.cc: Likewise.
* src/c++11/futex.cc: Likewise.
* src/c++11/future.cc: Likewise.
* src/c++11/mutex.cc: Likewise.
* src/c++11/thread.cc: Likewise.
* testsuite/20_util/duration/literals/range_neg.cc: Adjust dg-error.
* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Likewise.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Likewise.
* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Likewise.
* testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Likewise.
* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Likewise.
From-SVN: r263001
2018-07-26 16:01:55 +02:00
|
|
|
#include <cstdint> // intmax_t, uintmax_t
|
2008-07-04 20:45:09 +02:00
|
|
|
|
PR libstdc++/36104 part four
2011-01-30 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/36104 part four
* include/bits/c++config (_GLIBCXX_STD): Remove.
(_GLIBCXX_STD_D, _GLIBCXX_PR): Now _GLIBCXX_STD_C.
(_GLIBCXX_P): Now _GLIBCXX_STD_A.
(_GLIBCXX_NAMESPACE_DEBUG, _GLIBCXX_NAMESPACE_PARALLEL,
_GLIBCXX_NAMESPACE_PROFILE, _GLIBCXX_NAMESPACE_VERSION): Remove.
(_GLIBCXX_INLINE_DEBUG, _GLIBCXX_INLINE_PARALLEL,
_GLIBCXX_INLINE_PROFILE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE(X)): Remove.
(_GLIBCXX_END_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NESTED_NAMESPACE(X, Y)): Remove.
(_GLIBCXX_END_NESTED_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE_ALGO): Add.
(_GLIBCXX_END_NAMESPACE_ALGO): Add.
(_GLIBCXX_BEGIN_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_END_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_BEGIN_NAMESPACE_VERSION): Add.
(_GLIBCXX_END_NAMESPACE_VERSION): Add.
(_GLIBCXX_BEGIN_LDBL_NAMESPACE): To _GLIBCXX_BEGIN_NAMESPACE_LDBL.
(_GLIBCXX_END_LDBL_NAMESPACE): To _GLIBCXX_END_NAMESPACE_LDBL.
(_GLIBCXX_VISIBILITY_ATTR): Revert to _GLIBCXX_VISIBILITY.
* include/*: Use new macros for namespace scope.
* config/*: Same.
* src/*: Same.
* src/Makefile.am (sources): Remove debug_list.cc, add
compatibility-debug_list-2.cc.
(parallel_sources): Remove parallel_list.cc, add
compatibility-parallel_list-2.cc.
(compatibility-parallel_list-2.[o,lo]): New rule.
* src/Makefile.in: Regenerate.
* src/debug_list.cc: Remove.
* src/parallel_list.cc: Remove.
* src/compatibility-list-2.cc: New.
* src/compatibility-debug_list-2.cc: New.
* src/compatibility-parallel_list-2.cc: New.
* doc/doxygen/user.cfg.in: Adjust macros.
* testsuite/20_util/auto_ptr/assign_neg.cc: Adjust line numbers, macros.
* testsuite/20_util/declval/requirements/1_neg.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Same.
* testsuite/20_util/forward/c_neg.cc: Same.
* testsuite/20_util/forward/f_neg.cc: Same.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Same.
* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Same.
* testsuite/20_util/shared_ptr/cons/43820_neg.cc: Same.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/forward_list/capacity/1.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
assign_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
insert_neg.cc: Same.
* testsuite/23_containers/list/capacity/29134.cc: Same.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/vector/bool/capacity/29134.cc: Same.
* testsuite/23_containers/vector/bool/modifiers/insert/31370.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc: Same.
* testsuite/25_algorithms/sort/35588.cc: Same.
* testsuite/27_io/ios_base/cons/assign_neg.cc: Same.
* testsuite/27_io/ios_base/cons/copy_neg.cc: Same.
* testsuite/ext/profile/mutex_extensions_neg.cc: Same.
* testsuite/ext/profile/profiler_algos.cc: Same.
* testsuite/ext/type_traits/add_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/add_unsigned_integer_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_integer_neg.cc: Same.
* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc: Same.
From-SVN: r169421
2011-01-30 23:39:36 +01:00
|
|
|
namespace std _GLIBCXX_VISIBILITY(default)
|
|
|
|
{
|
|
|
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
2010-11-02 19:51:23 +01:00
|
|
|
|
2009-02-21 01:45:21 +01:00
|
|
|
/**
|
|
|
|
* @defgroup ratio Rational Arithmetic
|
|
|
|
* @ingroup utilities
|
|
|
|
*
|
2009-06-23 19:51:48 +02:00
|
|
|
* Compile time representation of finite rational numbers.
|
2009-02-21 01:45:21 +01:00
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2019-05-08 00:46:53 +02:00
|
|
|
/// @cond undocumented
|
|
|
|
|
2008-07-04 20:45:09 +02:00
|
|
|
template<intmax_t _Pn>
|
|
|
|
struct __static_sign
|
|
|
|
: integral_constant<intmax_t, (_Pn < 0) ? -1 : 1>
|
|
|
|
{ };
|
|
|
|
|
|
|
|
template<intmax_t _Pn>
|
|
|
|
struct __static_abs
|
|
|
|
: integral_constant<intmax_t, _Pn * __static_sign<_Pn>::value>
|
|
|
|
{ };
|
|
|
|
|
|
|
|
template<intmax_t _Pn, intmax_t _Qn>
|
|
|
|
struct __static_gcd
|
|
|
|
: __static_gcd<_Qn, (_Pn % _Qn)>
|
|
|
|
{ };
|
|
|
|
|
|
|
|
template<intmax_t _Pn>
|
|
|
|
struct __static_gcd<_Pn, 0>
|
|
|
|
: integral_constant<intmax_t, __static_abs<_Pn>::value>
|
|
|
|
{ };
|
|
|
|
|
|
|
|
template<intmax_t _Qn>
|
|
|
|
struct __static_gcd<0, _Qn>
|
|
|
|
: integral_constant<intmax_t, __static_abs<_Qn>::value>
|
|
|
|
{ };
|
|
|
|
|
|
|
|
// Let c = 2^(half # of bits in an intmax_t)
|
|
|
|
// then we find a1, a0, b1, b0 s.t. N = a1*c + a0, M = b1*c + b0
|
|
|
|
// The multiplication of N and M becomes,
|
|
|
|
// N * M = (a1 * b1)c^2 + (a0 * b1 + b0 * a1)c + a0 * b0
|
|
|
|
// Multiplication is safe if each term and the sum of the terms
|
|
|
|
// is representable by intmax_t.
|
|
|
|
template<intmax_t _Pn, intmax_t _Qn>
|
|
|
|
struct __safe_multiply
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
static const uintmax_t __c = uintmax_t(1) << (sizeof(intmax_t) * 4);
|
|
|
|
|
|
|
|
static const uintmax_t __a0 = __static_abs<_Pn>::value % __c;
|
|
|
|
static const uintmax_t __a1 = __static_abs<_Pn>::value / __c;
|
|
|
|
static const uintmax_t __b0 = __static_abs<_Qn>::value % __c;
|
|
|
|
static const uintmax_t __b1 = __static_abs<_Qn>::value / __c;
|
|
|
|
|
2016-06-16 15:47:35 +02:00
|
|
|
static_assert(__a1 == 0 || __b1 == 0,
|
2011-05-05 01:23:54 +02:00
|
|
|
"overflow in multiplication");
|
2016-06-16 15:47:35 +02:00
|
|
|
static_assert(__a0 * __b1 + __b0 * __a1 < (__c >> 1),
|
2011-05-05 01:23:54 +02:00
|
|
|
"overflow in multiplication");
|
2016-06-16 15:47:35 +02:00
|
|
|
static_assert(__b0 * __a0 <= __INTMAX_MAX__,
|
2011-05-05 01:23:54 +02:00
|
|
|
"overflow in multiplication");
|
|
|
|
static_assert((__a0 * __b1 + __b0 * __a1) * __c
|
|
|
|
<= __INTMAX_MAX__ - __b0 * __a0,
|
|
|
|
"overflow in multiplication");
|
2008-07-04 20:45:09 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
static const intmax_t value = _Pn * _Qn;
|
|
|
|
};
|
|
|
|
|
2011-05-05 01:23:54 +02:00
|
|
|
// Some double-precision utilities, where numbers are represented as
|
|
|
|
// __hi*2^(8*sizeof(uintmax_t)) + __lo.
|
|
|
|
template<uintmax_t __hi1, uintmax_t __lo1, uintmax_t __hi2, uintmax_t __lo2>
|
|
|
|
struct __big_less
|
|
|
|
: integral_constant<bool, (__hi1 < __hi2
|
|
|
|
|| (__hi1 == __hi2 && __lo1 < __lo2))>
|
2008-07-04 20:45:09 +02:00
|
|
|
{ };
|
|
|
|
|
2011-05-05 01:23:54 +02:00
|
|
|
template<uintmax_t __hi1, uintmax_t __lo1, uintmax_t __hi2, uintmax_t __lo2>
|
|
|
|
struct __big_add
|
|
|
|
{
|
|
|
|
static constexpr uintmax_t __lo = __lo1 + __lo2;
|
|
|
|
static constexpr uintmax_t __hi = (__hi1 + __hi2 +
|
|
|
|
(__lo1 + __lo2 < __lo1)); // carry
|
|
|
|
};
|
2008-07-04 20:45:09 +02:00
|
|
|
|
2011-05-05 01:23:54 +02:00
|
|
|
// Subtract a number from a bigger one.
|
|
|
|
template<uintmax_t __hi1, uintmax_t __lo1, uintmax_t __hi2, uintmax_t __lo2>
|
|
|
|
struct __big_sub
|
|
|
|
{
|
|
|
|
static_assert(!__big_less<__hi1, __lo1, __hi2, __lo2>::value,
|
|
|
|
"Internal library error");
|
|
|
|
static constexpr uintmax_t __lo = __lo1 - __lo2;
|
|
|
|
static constexpr uintmax_t __hi = (__hi1 - __hi2 -
|
|
|
|
(__lo1 < __lo2)); // carry
|
|
|
|
};
|
2008-07-04 20:45:09 +02:00
|
|
|
|
2011-05-05 01:23:54 +02:00
|
|
|
// Same principle as __safe_multiply.
|
|
|
|
template<uintmax_t __x, uintmax_t __y>
|
|
|
|
struct __big_mul
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
static constexpr uintmax_t __c = uintmax_t(1) << (sizeof(intmax_t) * 4);
|
|
|
|
static constexpr uintmax_t __x0 = __x % __c;
|
|
|
|
static constexpr uintmax_t __x1 = __x / __c;
|
|
|
|
static constexpr uintmax_t __y0 = __y % __c;
|
|
|
|
static constexpr uintmax_t __y1 = __y / __c;
|
|
|
|
static constexpr uintmax_t __x0y0 = __x0 * __y0;
|
|
|
|
static constexpr uintmax_t __x0y1 = __x0 * __y1;
|
|
|
|
static constexpr uintmax_t __x1y0 = __x1 * __y0;
|
|
|
|
static constexpr uintmax_t __x1y1 = __x1 * __y1;
|
|
|
|
static constexpr uintmax_t __mix = __x0y1 + __x1y0; // possible carry...
|
|
|
|
static constexpr uintmax_t __mix_lo = __mix * __c;
|
|
|
|
static constexpr uintmax_t __mix_hi
|
|
|
|
= __mix / __c + ((__mix < __x0y1) ? __c : 0); // ... added here
|
|
|
|
typedef __big_add<__mix_hi, __mix_lo, __x1y1, __x0y0> _Res;
|
|
|
|
public:
|
|
|
|
static constexpr uintmax_t __hi = _Res::__hi;
|
|
|
|
static constexpr uintmax_t __lo = _Res::__lo;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Adapted from __udiv_qrnnd_c in longlong.h
|
|
|
|
// This version assumes that the high bit of __d is 1.
|
|
|
|
template<uintmax_t __n1, uintmax_t __n0, uintmax_t __d>
|
|
|
|
struct __big_div_impl
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
static_assert(__d >= (uintmax_t(1) << (sizeof(intmax_t) * 8 - 1)),
|
|
|
|
"Internal library error");
|
|
|
|
static_assert(__n1 < __d, "Internal library error");
|
|
|
|
static constexpr uintmax_t __c = uintmax_t(1) << (sizeof(intmax_t) * 4);
|
|
|
|
static constexpr uintmax_t __d1 = __d / __c;
|
|
|
|
static constexpr uintmax_t __d0 = __d % __c;
|
|
|
|
|
|
|
|
static constexpr uintmax_t __q1x = __n1 / __d1;
|
|
|
|
static constexpr uintmax_t __r1x = __n1 % __d1;
|
|
|
|
static constexpr uintmax_t __m = __q1x * __d0;
|
|
|
|
static constexpr uintmax_t __r1y = __r1x * __c + __n0 / __c;
|
|
|
|
static constexpr uintmax_t __r1z = __r1y + __d;
|
|
|
|
static constexpr uintmax_t __r1
|
|
|
|
= ((__r1y < __m) ? ((__r1z >= __d) && (__r1z < __m))
|
|
|
|
? (__r1z + __d) : __r1z : __r1y) - __m;
|
|
|
|
static constexpr uintmax_t __q1
|
|
|
|
= __q1x - ((__r1y < __m)
|
|
|
|
? ((__r1z >= __d) && (__r1z < __m)) ? 2 : 1 : 0);
|
|
|
|
static constexpr uintmax_t __q0x = __r1 / __d1;
|
|
|
|
static constexpr uintmax_t __r0x = __r1 % __d1;
|
|
|
|
static constexpr uintmax_t __n = __q0x * __d0;
|
|
|
|
static constexpr uintmax_t __r0y = __r0x * __c + __n0 % __c;
|
|
|
|
static constexpr uintmax_t __r0z = __r0y + __d;
|
|
|
|
static constexpr uintmax_t __r0
|
|
|
|
= ((__r0y < __n) ? ((__r0z >= __d) && (__r0z < __n))
|
|
|
|
? (__r0z + __d) : __r0z : __r0y) - __n;
|
|
|
|
static constexpr uintmax_t __q0
|
|
|
|
= __q0x - ((__r0y < __n) ? ((__r0z >= __d)
|
|
|
|
&& (__r0z < __n)) ? 2 : 1 : 0);
|
|
|
|
|
|
|
|
public:
|
|
|
|
static constexpr uintmax_t __quot = __q1 * __c + __q0;
|
|
|
|
static constexpr uintmax_t __rem = __r0;
|
|
|
|
|
|
|
|
private:
|
|
|
|
typedef __big_mul<__quot, __d> _Prod;
|
|
|
|
typedef __big_add<_Prod::__hi, _Prod::__lo, 0, __rem> _Sum;
|
|
|
|
static_assert(_Sum::__hi == __n1 && _Sum::__lo == __n0,
|
|
|
|
"Internal library error");
|
|
|
|
};
|
|
|
|
|
|
|
|
template<uintmax_t __n1, uintmax_t __n0, uintmax_t __d>
|
|
|
|
struct __big_div
|
2008-07-04 20:45:09 +02:00
|
|
|
{
|
2011-05-05 01:23:54 +02:00
|
|
|
private:
|
|
|
|
static_assert(__d != 0, "Internal library error");
|
|
|
|
static_assert(sizeof (uintmax_t) == sizeof (unsigned long long),
|
|
|
|
"This library calls __builtin_clzll on uintmax_t, which "
|
|
|
|
"is unsafe on your platform. Please complain to "
|
|
|
|
"http://gcc.gnu.org/bugzilla/");
|
|
|
|
static constexpr int __shift = __builtin_clzll(__d);
|
|
|
|
static constexpr int __coshift_ = sizeof(uintmax_t) * 8 - __shift;
|
|
|
|
static constexpr int __coshift = (__shift != 0) ? __coshift_ : 0;
|
|
|
|
static constexpr uintmax_t __c1 = uintmax_t(1) << __shift;
|
|
|
|
static constexpr uintmax_t __c2 = uintmax_t(1) << __coshift;
|
|
|
|
static constexpr uintmax_t __new_d = __d * __c1;
|
|
|
|
static constexpr uintmax_t __new_n0 = __n0 * __c1;
|
|
|
|
static constexpr uintmax_t __n1_shifted = (__n1 % __d) * __c1;
|
|
|
|
static constexpr uintmax_t __n0_top = (__shift != 0) ? (__n0 / __c2) : 0;
|
|
|
|
static constexpr uintmax_t __new_n1 = __n1_shifted + __n0_top;
|
|
|
|
typedef __big_div_impl<__new_n1, __new_n0, __new_d> _Res;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static constexpr uintmax_t __quot_hi = __n1 / __d;
|
|
|
|
static constexpr uintmax_t __quot_lo = _Res::__quot;
|
|
|
|
static constexpr uintmax_t __rem = _Res::__rem / __c1;
|
2008-07-04 20:45:09 +02:00
|
|
|
|
2011-05-05 01:23:54 +02:00
|
|
|
private:
|
|
|
|
typedef __big_mul<__quot_lo, __d> _P0;
|
|
|
|
typedef __big_mul<__quot_hi, __d> _P1;
|
|
|
|
typedef __big_add<_P0::__hi, _P0::__lo, _P1::__lo, __rem> _Sum;
|
|
|
|
// No overflow.
|
|
|
|
static_assert(_P1::__hi == 0, "Internal library error");
|
|
|
|
static_assert(_Sum::__hi >= _P0::__hi, "Internal library error");
|
|
|
|
// Matches the input data.
|
|
|
|
static_assert(_Sum::__hi == __n1 && _Sum::__lo == __n0,
|
|
|
|
"Internal library error");
|
|
|
|
static_assert(__rem < __d, "Internal library error");
|
2008-07-04 20:45:09 +02:00
|
|
|
};
|
|
|
|
|
2019-05-08 00:46:53 +02:00
|
|
|
/// @endcond
|
|
|
|
|
2008-07-05 12:24:08 +02:00
|
|
|
/**
|
|
|
|
* @brief Provides compile-time rational arithmetic.
|
2009-02-21 01:45:21 +01:00
|
|
|
*
|
2008-07-05 12:24:08 +02:00
|
|
|
* This class template represents any finite rational number with a
|
|
|
|
* numerator and denominator representable by compile-time constants of
|
|
|
|
* type intmax_t. The ratio is simplified when instantiated.
|
|
|
|
*
|
|
|
|
* For example:
|
|
|
|
* @code
|
|
|
|
* std::ratio<7,-21>::num == -1;
|
|
|
|
* std::ratio<7,-21>::den == 3;
|
|
|
|
* @endcode
|
2016-06-16 15:47:35 +02:00
|
|
|
*
|
2008-07-05 12:24:08 +02:00
|
|
|
*/
|
2008-07-04 20:45:09 +02:00
|
|
|
template<intmax_t _Num, intmax_t _Den = 1>
|
|
|
|
struct ratio
|
|
|
|
{
|
|
|
|
static_assert(_Den != 0, "denominator cannot be zero");
|
2008-07-05 12:24:08 +02:00
|
|
|
static_assert(_Num >= -__INTMAX_MAX__ && _Den >= -__INTMAX_MAX__,
|
|
|
|
"out of range");
|
|
|
|
|
2008-07-04 20:45:09 +02:00
|
|
|
// Note: sign(N) * abs(N) == N
|
2010-11-02 03:35:28 +01:00
|
|
|
static constexpr intmax_t num =
|
2008-07-04 20:45:09 +02:00
|
|
|
_Num * __static_sign<_Den>::value / __static_gcd<_Num, _Den>::value;
|
|
|
|
|
2010-11-02 03:35:28 +01:00
|
|
|
static constexpr intmax_t den =
|
2008-07-04 20:45:09 +02:00
|
|
|
__static_abs<_Den>::value / __static_gcd<_Num, _Den>::value;
|
re PR libstdc++/45866 ([C++0x] std::ratio_add, ratio_sub, ratio_multiply, ratio_divide do not have num and den members.)
2010-10-18 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/45866
* include/std/ratio (ratio<>::type): Add.
(ratio_add<>::num, ratio_add<>::den,
ratio_subtract<>::num, ratio_subtract<>::den,
ratio_multiply<>::num, ratio_multiply<>::den,
ratio_divide<>::num, ratio_divide<>::den): Likewise.
* testsuite/20_util/ratio/operations/45866.cc: New.
From-SVN: r165649
2010-10-18 19:28:15 +02:00
|
|
|
|
|
|
|
typedef ratio<num, den> type;
|
2008-07-04 20:45:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
template<intmax_t _Num, intmax_t _Den>
|
2010-11-02 03:35:28 +01:00
|
|
|
constexpr intmax_t ratio<_Num, _Den>::num;
|
2008-07-04 20:45:09 +02:00
|
|
|
|
|
|
|
template<intmax_t _Num, intmax_t _Den>
|
2010-11-02 03:35:28 +01:00
|
|
|
constexpr intmax_t ratio<_Num, _Den>::den;
|
2008-07-04 20:45:09 +02:00
|
|
|
|
2019-05-08 00:46:53 +02:00
|
|
|
/// @cond undocumented
|
|
|
|
|
2008-07-04 20:45:09 +02:00
|
|
|
template<typename _R1, typename _R2>
|
2012-07-03 21:24:07 +02:00
|
|
|
struct __ratio_multiply
|
2008-07-04 20:45:09 +02:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
static const intmax_t __gcd1 =
|
|
|
|
__static_gcd<_R1::num, _R2::den>::value;
|
|
|
|
static const intmax_t __gcd2 =
|
|
|
|
__static_gcd<_R2::num, _R1::den>::value;
|
|
|
|
|
|
|
|
public:
|
|
|
|
typedef ratio<
|
|
|
|
__safe_multiply<(_R1::num / __gcd1),
|
|
|
|
(_R2::num / __gcd2)>::value,
|
|
|
|
__safe_multiply<(_R1::den / __gcd2),
|
|
|
|
(_R2::den / __gcd1)>::value> type;
|
re PR libstdc++/45866 ([C++0x] std::ratio_add, ratio_sub, ratio_multiply, ratio_divide do not have num and den members.)
2010-10-18 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/45866
* include/std/ratio (ratio<>::type): Add.
(ratio_add<>::num, ratio_add<>::den,
ratio_subtract<>::num, ratio_subtract<>::den,
ratio_multiply<>::num, ratio_multiply<>::den,
ratio_divide<>::num, ratio_divide<>::den): Likewise.
* testsuite/20_util/ratio/operations/45866.cc: New.
From-SVN: r165649
2010-10-18 19:28:15 +02:00
|
|
|
|
2010-11-04 18:02:25 +01:00
|
|
|
static constexpr intmax_t num = type::num;
|
|
|
|
static constexpr intmax_t den = type::den;
|
2008-07-04 20:45:09 +02:00
|
|
|
};
|
|
|
|
|
re PR libstdc++/45866 ([C++0x] std::ratio_add, ratio_sub, ratio_multiply, ratio_divide do not have num and den members.)
2010-10-18 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/45866
* include/std/ratio (ratio<>::type): Add.
(ratio_add<>::num, ratio_add<>::den,
ratio_subtract<>::num, ratio_subtract<>::den,
ratio_multiply<>::num, ratio_multiply<>::den,
ratio_divide<>::num, ratio_divide<>::den): Likewise.
* testsuite/20_util/ratio/operations/45866.cc: New.
From-SVN: r165649
2010-10-18 19:28:15 +02:00
|
|
|
template<typename _R1, typename _R2>
|
2012-07-03 21:24:07 +02:00
|
|
|
constexpr intmax_t __ratio_multiply<_R1, _R2>::num;
|
re PR libstdc++/45866 ([C++0x] std::ratio_add, ratio_sub, ratio_multiply, ratio_divide do not have num and den members.)
2010-10-18 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/45866
* include/std/ratio (ratio<>::type): Add.
(ratio_add<>::num, ratio_add<>::den,
ratio_subtract<>::num, ratio_subtract<>::den,
ratio_multiply<>::num, ratio_multiply<>::den,
ratio_divide<>::num, ratio_divide<>::den): Likewise.
* testsuite/20_util/ratio/operations/45866.cc: New.
From-SVN: r165649
2010-10-18 19:28:15 +02:00
|
|
|
|
|
|
|
template<typename _R1, typename _R2>
|
2012-07-03 21:24:07 +02:00
|
|
|
constexpr intmax_t __ratio_multiply<_R1, _R2>::den;
|
|
|
|
|
2019-05-08 00:46:53 +02:00
|
|
|
/// @endcond
|
|
|
|
|
2012-07-03 21:24:07 +02:00
|
|
|
/// ratio_multiply
|
|
|
|
template<typename _R1, typename _R2>
|
|
|
|
using ratio_multiply = typename __ratio_multiply<_R1, _R2>::type;
|
re PR libstdc++/45866 ([C++0x] std::ratio_add, ratio_sub, ratio_multiply, ratio_divide do not have num and den members.)
2010-10-18 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/45866
* include/std/ratio (ratio<>::type): Add.
(ratio_add<>::num, ratio_add<>::den,
ratio_subtract<>::num, ratio_subtract<>::den,
ratio_multiply<>::num, ratio_multiply<>::den,
ratio_divide<>::num, ratio_divide<>::den): Likewise.
* testsuite/20_util/ratio/operations/45866.cc: New.
From-SVN: r165649
2010-10-18 19:28:15 +02:00
|
|
|
|
2019-05-08 00:46:53 +02:00
|
|
|
/// @cond undocumented
|
|
|
|
|
2008-07-04 20:45:09 +02:00
|
|
|
template<typename _R1, typename _R2>
|
2012-07-03 21:24:07 +02:00
|
|
|
struct __ratio_divide
|
2008-07-04 20:45:09 +02:00
|
|
|
{
|
|
|
|
static_assert(_R2::num != 0, "division by 0");
|
|
|
|
|
2012-07-03 21:24:07 +02:00
|
|
|
typedef typename __ratio_multiply<
|
2008-07-04 20:45:09 +02:00
|
|
|
_R1,
|
|
|
|
ratio<_R2::den, _R2::num>>::type type;
|
re PR libstdc++/45866 ([C++0x] std::ratio_add, ratio_sub, ratio_multiply, ratio_divide do not have num and den members.)
2010-10-18 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/45866
* include/std/ratio (ratio<>::type): Add.
(ratio_add<>::num, ratio_add<>::den,
ratio_subtract<>::num, ratio_subtract<>::den,
ratio_multiply<>::num, ratio_multiply<>::den,
ratio_divide<>::num, ratio_divide<>::den): Likewise.
* testsuite/20_util/ratio/operations/45866.cc: New.
From-SVN: r165649
2010-10-18 19:28:15 +02:00
|
|
|
|
2010-11-04 18:02:25 +01:00
|
|
|
static constexpr intmax_t num = type::num;
|
|
|
|
static constexpr intmax_t den = type::den;
|
2008-07-04 20:45:09 +02:00
|
|
|
};
|
|
|
|
|
re PR libstdc++/45866 ([C++0x] std::ratio_add, ratio_sub, ratio_multiply, ratio_divide do not have num and den members.)
2010-10-18 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/45866
* include/std/ratio (ratio<>::type): Add.
(ratio_add<>::num, ratio_add<>::den,
ratio_subtract<>::num, ratio_subtract<>::den,
ratio_multiply<>::num, ratio_multiply<>::den,
ratio_divide<>::num, ratio_divide<>::den): Likewise.
* testsuite/20_util/ratio/operations/45866.cc: New.
From-SVN: r165649
2010-10-18 19:28:15 +02:00
|
|
|
template<typename _R1, typename _R2>
|
2012-07-03 21:24:07 +02:00
|
|
|
constexpr intmax_t __ratio_divide<_R1, _R2>::num;
|
|
|
|
|
|
|
|
template<typename _R1, typename _R2>
|
|
|
|
constexpr intmax_t __ratio_divide<_R1, _R2>::den;
|
re PR libstdc++/45866 ([C++0x] std::ratio_add, ratio_sub, ratio_multiply, ratio_divide do not have num and den members.)
2010-10-18 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/45866
* include/std/ratio (ratio<>::type): Add.
(ratio_add<>::num, ratio_add<>::den,
ratio_subtract<>::num, ratio_subtract<>::den,
ratio_multiply<>::num, ratio_multiply<>::den,
ratio_divide<>::num, ratio_divide<>::den): Likewise.
* testsuite/20_util/ratio/operations/45866.cc: New.
From-SVN: r165649
2010-10-18 19:28:15 +02:00
|
|
|
|
2019-05-08 00:46:53 +02:00
|
|
|
/// @endcond
|
|
|
|
|
2012-07-03 21:24:07 +02:00
|
|
|
/// ratio_divide
|
re PR libstdc++/45866 ([C++0x] std::ratio_add, ratio_sub, ratio_multiply, ratio_divide do not have num and den members.)
2010-10-18 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/45866
* include/std/ratio (ratio<>::type): Add.
(ratio_add<>::num, ratio_add<>::den,
ratio_subtract<>::num, ratio_subtract<>::den,
ratio_multiply<>::num, ratio_multiply<>::den,
ratio_divide<>::num, ratio_divide<>::den): Likewise.
* testsuite/20_util/ratio/operations/45866.cc: New.
From-SVN: r165649
2010-10-18 19:28:15 +02:00
|
|
|
template<typename _R1, typename _R2>
|
2012-07-03 21:24:07 +02:00
|
|
|
using ratio_divide = typename __ratio_divide<_R1, _R2>::type;
|
re PR libstdc++/45866 ([C++0x] std::ratio_add, ratio_sub, ratio_multiply, ratio_divide do not have num and den members.)
2010-10-18 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/45866
* include/std/ratio (ratio<>::type): Add.
(ratio_add<>::num, ratio_add<>::den,
ratio_subtract<>::num, ratio_subtract<>::den,
ratio_multiply<>::num, ratio_multiply<>::den,
ratio_divide<>::num, ratio_divide<>::den): Likewise.
* testsuite/20_util/ratio/operations/45866.cc: New.
From-SVN: r165649
2010-10-18 19:28:15 +02:00
|
|
|
|
2008-07-16 09:01:23 +02:00
|
|
|
/// ratio_equal
|
2008-07-04 20:45:09 +02:00
|
|
|
template<typename _R1, typename _R2>
|
|
|
|
struct ratio_equal
|
|
|
|
: integral_constant<bool, _R1::num == _R2::num && _R1::den == _R2::den>
|
|
|
|
{ };
|
2016-06-16 15:47:35 +02:00
|
|
|
|
2008-07-16 09:01:23 +02:00
|
|
|
/// ratio_not_equal
|
2008-07-04 20:45:09 +02:00
|
|
|
template<typename _R1, typename _R2>
|
|
|
|
struct ratio_not_equal
|
|
|
|
: integral_constant<bool, !ratio_equal<_R1, _R2>::value>
|
|
|
|
{ };
|
2010-08-06 10:58:27 +02:00
|
|
|
|
2019-05-08 00:46:53 +02:00
|
|
|
/// @cond undocumented
|
|
|
|
|
2011-05-05 01:23:54 +02:00
|
|
|
// Both numbers are positive.
|
|
|
|
template<typename _R1, typename _R2,
|
|
|
|
typename _Left = __big_mul<_R1::num,_R2::den>,
|
|
|
|
typename _Right = __big_mul<_R2::num,_R1::den> >
|
2010-08-06 10:58:27 +02:00
|
|
|
struct __ratio_less_impl_1
|
2011-05-05 01:23:54 +02:00
|
|
|
: integral_constant<bool, __big_less<_Left::__hi, _Left::__lo,
|
|
|
|
_Right::__hi, _Right::__lo>::value>
|
2016-06-16 15:47:35 +02:00
|
|
|
{ };
|
2010-08-06 10:58:27 +02:00
|
|
|
|
|
|
|
template<typename _R1, typename _R2,
|
|
|
|
bool = (_R1::num == 0 || _R2::num == 0
|
|
|
|
|| (__static_sign<_R1::num>::value
|
|
|
|
!= __static_sign<_R2::num>::value)),
|
|
|
|
bool = (__static_sign<_R1::num>::value == -1
|
|
|
|
&& __static_sign<_R2::num>::value == -1)>
|
|
|
|
struct __ratio_less_impl
|
2011-02-28 17:46:23 +01:00
|
|
|
: __ratio_less_impl_1<_R1, _R2>::type
|
2010-08-06 10:58:27 +02:00
|
|
|
{ };
|
|
|
|
|
2008-07-04 20:45:09 +02:00
|
|
|
template<typename _R1, typename _R2>
|
2010-08-06 10:58:27 +02:00
|
|
|
struct __ratio_less_impl<_R1, _R2, true, false>
|
|
|
|
: integral_constant<bool, _R1::num < _R2::num>
|
2008-07-05 12:24:08 +02:00
|
|
|
{ };
|
|
|
|
|
|
|
|
template<typename _R1, typename _R2>
|
2010-08-06 10:58:27 +02:00
|
|
|
struct __ratio_less_impl<_R1, _R2, false, true>
|
2011-02-28 17:46:23 +01:00
|
|
|
: __ratio_less_impl_1<ratio<-_R2::num, _R2::den>,
|
|
|
|
ratio<-_R1::num, _R1::den> >::type
|
2008-07-05 12:24:08 +02:00
|
|
|
{ };
|
|
|
|
|
2019-05-08 00:46:53 +02:00
|
|
|
/// @endcond
|
|
|
|
|
2008-07-16 09:01:23 +02:00
|
|
|
/// ratio_less
|
2008-07-05 12:24:08 +02:00
|
|
|
template<typename _R1, typename _R2>
|
|
|
|
struct ratio_less
|
|
|
|
: __ratio_less_impl<_R1, _R2>::type
|
2008-07-04 20:45:09 +02:00
|
|
|
{ };
|
2016-06-16 15:47:35 +02:00
|
|
|
|
2008-07-16 09:01:23 +02:00
|
|
|
/// ratio_less_equal
|
2008-07-04 20:45:09 +02:00
|
|
|
template<typename _R1, typename _R2>
|
|
|
|
struct ratio_less_equal
|
|
|
|
: integral_constant<bool, !ratio_less<_R2, _R1>::value>
|
|
|
|
{ };
|
2016-06-16 15:47:35 +02:00
|
|
|
|
2008-07-16 09:01:23 +02:00
|
|
|
/// ratio_greater
|
2008-07-04 20:45:09 +02:00
|
|
|
template<typename _R1, typename _R2>
|
|
|
|
struct ratio_greater
|
|
|
|
: integral_constant<bool, ratio_less<_R2, _R1>::value>
|
|
|
|
{ };
|
|
|
|
|
2008-07-16 09:01:23 +02:00
|
|
|
/// ratio_greater_equal
|
2008-07-04 20:45:09 +02:00
|
|
|
template<typename _R1, typename _R2>
|
|
|
|
struct ratio_greater_equal
|
|
|
|
: integral_constant<bool, !ratio_less<_R1, _R2>::value>
|
|
|
|
{ };
|
|
|
|
|
Implement C++17 variable templates for type traits.
* include/std/chrono (treat_as_floating_point_v): New.
* include/std/ratio (ratio_equal_v, ratio_not_equal_v)
(ratio_less_v, ratio_less_equal_v, ratio_greater_v)
(ratio_greater_equal_v): Likewise.
* include/std/system_error (is_error_code_enum_v)
(is_error_condition_enum_v): Likewise.
* include/std/tuple (tuple_size_v): Likewise.
* type_traits (conjunction_v, disjunction_v, negation_v)
(is_void_v, is_null_pointer_v, is_integral_v, is_floating_point_v)
(is_array_v, is_pointer_v, is_lvalue_reference_v)
(is_rvalue_reference_v, is_member_object_pointer_v)
(is_member_function_pointer_v, is_enum_v, is_union_v)
(is_class_v, is_function_v, is_reference_v, is_arithmetic_v)
(is_fundamental_v, is_object_v, is_scalar_v, is_compound_v)
(is_member_pointer_v, is_const_v, is_volatile_v, is_trivial_v)
(is_trivially_copyable_v, is_standard_layout_v)
(is_pod_v, is_literal_type_v, is_empty_v, is_polymorphic_v)
(is_abstract_v, is_final_v, is_signed_v, is_unsigned_v)
(is_constructible_v, is_default_constructible_v)
(is_copy_constructible_v, is_move_constructible_v)
(is_assignable_v, is_copy_assignable_v, is_move_assignable_v)
(is_destructible_v, is_trivially_constructible_v)
(is_trivially_default_constructible_v)
(is_trivially_copy_constructible_v, is_trivially_move_constructible_v)
(is_trivially_assignable_v, is_trivially_copy_assignable_v)
(is_trivially_move_assignable_v, is_trivially_destructible_v)
(is_nothrow_constructible_v, is_nothrow_default_constructible_v)
(is_nothrow_copy_constructible_v, is_nothrow_move_constructible_v)
(is_nothrow_assignable_v, is_nothrow_copy_assignable_v)
(is_nothrow_move_assignable_v, is_nothrow_destructible_v)
(has_virtual_destructor_v, alignment_of_v, rank_v, extent_v)
(is_same_v, is_base_of_v, is_convertible_v): Likewise.
* testsuite/19_diagnostics/error_code/is_error_code_v.cc: Likewise.
* testsuite/20_util/duration/requirements/treat_as_floating_point_v.cc:
Likewise.
* testsuite/20_util/ratio/requirements/ratio_equal_v.cc: Likewise.
* testsuite/20_util/tuple/tuple_size_v.cc: Likewise.
* testsuite/20_util/variable_templates_for_traits.cc: Likewise.
From-SVN: r238892
2016-07-29 21:01:39 +02:00
|
|
|
#if __cplusplus > 201402L
|
|
|
|
template <typename _R1, typename _R2>
|
Implement P0607R0 "Inline Variables for Standard Library" for C++17
2017-03-23 Daniel Kruegler <daniel.kruegler@gmail.com>
* include/bits/c++config (_GLIBCXX17_INLINE): Define.
* include/bits/regex_constants.h (All std::regex_constants constants):
Add _GLIBCXX17_INLINE as per P0607R0.
* include/bits/std_mutex.h (defer_lock, try_to_lock, adopt_lock):
Likewise.
* include/bits/stl_pair.h (piecewise_construct): Likewise.
* include/bits/uses_allocator.h (allocator_arg, uses_allocator_v)
(__is_uses_allocator_constructible_v)
(__is_nothrow_uses_allocator_constructible_v): Likewise.
* include/std/chrono (treat_as_floating_point_v): Likewise.
* include/std/functional (is_bind_expression_v, is_placeholder_v):
Likewise.
* include/std/optional (nullopt): Likewise.
* include/std/ratio (ratio_equal_v, ratio_not_equal_v, ratio_less_v)
ratio_less_equal_v, ratio_greater_v, ratio_greater_equal_v): Likewise.
* include/std/system_error (is_error_code_enum_v)
(is_error_condition_enum_v): Likewise.
* include/std/tuple (tuple_size_v, ignore): Likewise.
(ignore): Declare ignore constexpr as per LWG 2773, declare assignment
constexpr as per LWG 2933.
* include/std/type_traits (All variable templates): Add
_GLIBCXX17_INLINE as per P0607R0.
* include/std/variant (variant_size_v, variant_npos, __index_of_v)
(__tuple_count_v, __exactly_once): Likewise.
* testsuite/18_support/headers/new/synopsis.cc
(hardware_destructive_interference_size)
(hardware_constructive_interference_size): Likewise for commented-out
variables.
* testsuite/20_util/tuple/creation_functions/constexpr.cc: Add new
test function for constexpr std::ignore (LWG 2773).
* testsuite/20_util/tuple/creation_functions/constexpr_cpp14.cc: New
test for LWG 2933.
From-SVN: r246423
2017-03-23 20:40:07 +01:00
|
|
|
inline constexpr bool ratio_equal_v = ratio_equal<_R1, _R2>::value;
|
Implement C++17 variable templates for type traits.
* include/std/chrono (treat_as_floating_point_v): New.
* include/std/ratio (ratio_equal_v, ratio_not_equal_v)
(ratio_less_v, ratio_less_equal_v, ratio_greater_v)
(ratio_greater_equal_v): Likewise.
* include/std/system_error (is_error_code_enum_v)
(is_error_condition_enum_v): Likewise.
* include/std/tuple (tuple_size_v): Likewise.
* type_traits (conjunction_v, disjunction_v, negation_v)
(is_void_v, is_null_pointer_v, is_integral_v, is_floating_point_v)
(is_array_v, is_pointer_v, is_lvalue_reference_v)
(is_rvalue_reference_v, is_member_object_pointer_v)
(is_member_function_pointer_v, is_enum_v, is_union_v)
(is_class_v, is_function_v, is_reference_v, is_arithmetic_v)
(is_fundamental_v, is_object_v, is_scalar_v, is_compound_v)
(is_member_pointer_v, is_const_v, is_volatile_v, is_trivial_v)
(is_trivially_copyable_v, is_standard_layout_v)
(is_pod_v, is_literal_type_v, is_empty_v, is_polymorphic_v)
(is_abstract_v, is_final_v, is_signed_v, is_unsigned_v)
(is_constructible_v, is_default_constructible_v)
(is_copy_constructible_v, is_move_constructible_v)
(is_assignable_v, is_copy_assignable_v, is_move_assignable_v)
(is_destructible_v, is_trivially_constructible_v)
(is_trivially_default_constructible_v)
(is_trivially_copy_constructible_v, is_trivially_move_constructible_v)
(is_trivially_assignable_v, is_trivially_copy_assignable_v)
(is_trivially_move_assignable_v, is_trivially_destructible_v)
(is_nothrow_constructible_v, is_nothrow_default_constructible_v)
(is_nothrow_copy_constructible_v, is_nothrow_move_constructible_v)
(is_nothrow_assignable_v, is_nothrow_copy_assignable_v)
(is_nothrow_move_assignable_v, is_nothrow_destructible_v)
(has_virtual_destructor_v, alignment_of_v, rank_v, extent_v)
(is_same_v, is_base_of_v, is_convertible_v): Likewise.
* testsuite/19_diagnostics/error_code/is_error_code_v.cc: Likewise.
* testsuite/20_util/duration/requirements/treat_as_floating_point_v.cc:
Likewise.
* testsuite/20_util/ratio/requirements/ratio_equal_v.cc: Likewise.
* testsuite/20_util/tuple/tuple_size_v.cc: Likewise.
* testsuite/20_util/variable_templates_for_traits.cc: Likewise.
From-SVN: r238892
2016-07-29 21:01:39 +02:00
|
|
|
template <typename _R1, typename _R2>
|
Implement P0607R0 "Inline Variables for Standard Library" for C++17
2017-03-23 Daniel Kruegler <daniel.kruegler@gmail.com>
* include/bits/c++config (_GLIBCXX17_INLINE): Define.
* include/bits/regex_constants.h (All std::regex_constants constants):
Add _GLIBCXX17_INLINE as per P0607R0.
* include/bits/std_mutex.h (defer_lock, try_to_lock, adopt_lock):
Likewise.
* include/bits/stl_pair.h (piecewise_construct): Likewise.
* include/bits/uses_allocator.h (allocator_arg, uses_allocator_v)
(__is_uses_allocator_constructible_v)
(__is_nothrow_uses_allocator_constructible_v): Likewise.
* include/std/chrono (treat_as_floating_point_v): Likewise.
* include/std/functional (is_bind_expression_v, is_placeholder_v):
Likewise.
* include/std/optional (nullopt): Likewise.
* include/std/ratio (ratio_equal_v, ratio_not_equal_v, ratio_less_v)
ratio_less_equal_v, ratio_greater_v, ratio_greater_equal_v): Likewise.
* include/std/system_error (is_error_code_enum_v)
(is_error_condition_enum_v): Likewise.
* include/std/tuple (tuple_size_v, ignore): Likewise.
(ignore): Declare ignore constexpr as per LWG 2773, declare assignment
constexpr as per LWG 2933.
* include/std/type_traits (All variable templates): Add
_GLIBCXX17_INLINE as per P0607R0.
* include/std/variant (variant_size_v, variant_npos, __index_of_v)
(__tuple_count_v, __exactly_once): Likewise.
* testsuite/18_support/headers/new/synopsis.cc
(hardware_destructive_interference_size)
(hardware_constructive_interference_size): Likewise for commented-out
variables.
* testsuite/20_util/tuple/creation_functions/constexpr.cc: Add new
test function for constexpr std::ignore (LWG 2773).
* testsuite/20_util/tuple/creation_functions/constexpr_cpp14.cc: New
test for LWG 2933.
From-SVN: r246423
2017-03-23 20:40:07 +01:00
|
|
|
inline constexpr bool ratio_not_equal_v = ratio_not_equal<_R1, _R2>::value;
|
Implement C++17 variable templates for type traits.
* include/std/chrono (treat_as_floating_point_v): New.
* include/std/ratio (ratio_equal_v, ratio_not_equal_v)
(ratio_less_v, ratio_less_equal_v, ratio_greater_v)
(ratio_greater_equal_v): Likewise.
* include/std/system_error (is_error_code_enum_v)
(is_error_condition_enum_v): Likewise.
* include/std/tuple (tuple_size_v): Likewise.
* type_traits (conjunction_v, disjunction_v, negation_v)
(is_void_v, is_null_pointer_v, is_integral_v, is_floating_point_v)
(is_array_v, is_pointer_v, is_lvalue_reference_v)
(is_rvalue_reference_v, is_member_object_pointer_v)
(is_member_function_pointer_v, is_enum_v, is_union_v)
(is_class_v, is_function_v, is_reference_v, is_arithmetic_v)
(is_fundamental_v, is_object_v, is_scalar_v, is_compound_v)
(is_member_pointer_v, is_const_v, is_volatile_v, is_trivial_v)
(is_trivially_copyable_v, is_standard_layout_v)
(is_pod_v, is_literal_type_v, is_empty_v, is_polymorphic_v)
(is_abstract_v, is_final_v, is_signed_v, is_unsigned_v)
(is_constructible_v, is_default_constructible_v)
(is_copy_constructible_v, is_move_constructible_v)
(is_assignable_v, is_copy_assignable_v, is_move_assignable_v)
(is_destructible_v, is_trivially_constructible_v)
(is_trivially_default_constructible_v)
(is_trivially_copy_constructible_v, is_trivially_move_constructible_v)
(is_trivially_assignable_v, is_trivially_copy_assignable_v)
(is_trivially_move_assignable_v, is_trivially_destructible_v)
(is_nothrow_constructible_v, is_nothrow_default_constructible_v)
(is_nothrow_copy_constructible_v, is_nothrow_move_constructible_v)
(is_nothrow_assignable_v, is_nothrow_copy_assignable_v)
(is_nothrow_move_assignable_v, is_nothrow_destructible_v)
(has_virtual_destructor_v, alignment_of_v, rank_v, extent_v)
(is_same_v, is_base_of_v, is_convertible_v): Likewise.
* testsuite/19_diagnostics/error_code/is_error_code_v.cc: Likewise.
* testsuite/20_util/duration/requirements/treat_as_floating_point_v.cc:
Likewise.
* testsuite/20_util/ratio/requirements/ratio_equal_v.cc: Likewise.
* testsuite/20_util/tuple/tuple_size_v.cc: Likewise.
* testsuite/20_util/variable_templates_for_traits.cc: Likewise.
From-SVN: r238892
2016-07-29 21:01:39 +02:00
|
|
|
template <typename _R1, typename _R2>
|
Implement P0607R0 "Inline Variables for Standard Library" for C++17
2017-03-23 Daniel Kruegler <daniel.kruegler@gmail.com>
* include/bits/c++config (_GLIBCXX17_INLINE): Define.
* include/bits/regex_constants.h (All std::regex_constants constants):
Add _GLIBCXX17_INLINE as per P0607R0.
* include/bits/std_mutex.h (defer_lock, try_to_lock, adopt_lock):
Likewise.
* include/bits/stl_pair.h (piecewise_construct): Likewise.
* include/bits/uses_allocator.h (allocator_arg, uses_allocator_v)
(__is_uses_allocator_constructible_v)
(__is_nothrow_uses_allocator_constructible_v): Likewise.
* include/std/chrono (treat_as_floating_point_v): Likewise.
* include/std/functional (is_bind_expression_v, is_placeholder_v):
Likewise.
* include/std/optional (nullopt): Likewise.
* include/std/ratio (ratio_equal_v, ratio_not_equal_v, ratio_less_v)
ratio_less_equal_v, ratio_greater_v, ratio_greater_equal_v): Likewise.
* include/std/system_error (is_error_code_enum_v)
(is_error_condition_enum_v): Likewise.
* include/std/tuple (tuple_size_v, ignore): Likewise.
(ignore): Declare ignore constexpr as per LWG 2773, declare assignment
constexpr as per LWG 2933.
* include/std/type_traits (All variable templates): Add
_GLIBCXX17_INLINE as per P0607R0.
* include/std/variant (variant_size_v, variant_npos, __index_of_v)
(__tuple_count_v, __exactly_once): Likewise.
* testsuite/18_support/headers/new/synopsis.cc
(hardware_destructive_interference_size)
(hardware_constructive_interference_size): Likewise for commented-out
variables.
* testsuite/20_util/tuple/creation_functions/constexpr.cc: Add new
test function for constexpr std::ignore (LWG 2773).
* testsuite/20_util/tuple/creation_functions/constexpr_cpp14.cc: New
test for LWG 2933.
From-SVN: r246423
2017-03-23 20:40:07 +01:00
|
|
|
inline constexpr bool ratio_less_v = ratio_less<_R1, _R2>::value;
|
Implement C++17 variable templates for type traits.
* include/std/chrono (treat_as_floating_point_v): New.
* include/std/ratio (ratio_equal_v, ratio_not_equal_v)
(ratio_less_v, ratio_less_equal_v, ratio_greater_v)
(ratio_greater_equal_v): Likewise.
* include/std/system_error (is_error_code_enum_v)
(is_error_condition_enum_v): Likewise.
* include/std/tuple (tuple_size_v): Likewise.
* type_traits (conjunction_v, disjunction_v, negation_v)
(is_void_v, is_null_pointer_v, is_integral_v, is_floating_point_v)
(is_array_v, is_pointer_v, is_lvalue_reference_v)
(is_rvalue_reference_v, is_member_object_pointer_v)
(is_member_function_pointer_v, is_enum_v, is_union_v)
(is_class_v, is_function_v, is_reference_v, is_arithmetic_v)
(is_fundamental_v, is_object_v, is_scalar_v, is_compound_v)
(is_member_pointer_v, is_const_v, is_volatile_v, is_trivial_v)
(is_trivially_copyable_v, is_standard_layout_v)
(is_pod_v, is_literal_type_v, is_empty_v, is_polymorphic_v)
(is_abstract_v, is_final_v, is_signed_v, is_unsigned_v)
(is_constructible_v, is_default_constructible_v)
(is_copy_constructible_v, is_move_constructible_v)
(is_assignable_v, is_copy_assignable_v, is_move_assignable_v)
(is_destructible_v, is_trivially_constructible_v)
(is_trivially_default_constructible_v)
(is_trivially_copy_constructible_v, is_trivially_move_constructible_v)
(is_trivially_assignable_v, is_trivially_copy_assignable_v)
(is_trivially_move_assignable_v, is_trivially_destructible_v)
(is_nothrow_constructible_v, is_nothrow_default_constructible_v)
(is_nothrow_copy_constructible_v, is_nothrow_move_constructible_v)
(is_nothrow_assignable_v, is_nothrow_copy_assignable_v)
(is_nothrow_move_assignable_v, is_nothrow_destructible_v)
(has_virtual_destructor_v, alignment_of_v, rank_v, extent_v)
(is_same_v, is_base_of_v, is_convertible_v): Likewise.
* testsuite/19_diagnostics/error_code/is_error_code_v.cc: Likewise.
* testsuite/20_util/duration/requirements/treat_as_floating_point_v.cc:
Likewise.
* testsuite/20_util/ratio/requirements/ratio_equal_v.cc: Likewise.
* testsuite/20_util/tuple/tuple_size_v.cc: Likewise.
* testsuite/20_util/variable_templates_for_traits.cc: Likewise.
From-SVN: r238892
2016-07-29 21:01:39 +02:00
|
|
|
template <typename _R1, typename _R2>
|
Implement P0607R0 "Inline Variables for Standard Library" for C++17
2017-03-23 Daniel Kruegler <daniel.kruegler@gmail.com>
* include/bits/c++config (_GLIBCXX17_INLINE): Define.
* include/bits/regex_constants.h (All std::regex_constants constants):
Add _GLIBCXX17_INLINE as per P0607R0.
* include/bits/std_mutex.h (defer_lock, try_to_lock, adopt_lock):
Likewise.
* include/bits/stl_pair.h (piecewise_construct): Likewise.
* include/bits/uses_allocator.h (allocator_arg, uses_allocator_v)
(__is_uses_allocator_constructible_v)
(__is_nothrow_uses_allocator_constructible_v): Likewise.
* include/std/chrono (treat_as_floating_point_v): Likewise.
* include/std/functional (is_bind_expression_v, is_placeholder_v):
Likewise.
* include/std/optional (nullopt): Likewise.
* include/std/ratio (ratio_equal_v, ratio_not_equal_v, ratio_less_v)
ratio_less_equal_v, ratio_greater_v, ratio_greater_equal_v): Likewise.
* include/std/system_error (is_error_code_enum_v)
(is_error_condition_enum_v): Likewise.
* include/std/tuple (tuple_size_v, ignore): Likewise.
(ignore): Declare ignore constexpr as per LWG 2773, declare assignment
constexpr as per LWG 2933.
* include/std/type_traits (All variable templates): Add
_GLIBCXX17_INLINE as per P0607R0.
* include/std/variant (variant_size_v, variant_npos, __index_of_v)
(__tuple_count_v, __exactly_once): Likewise.
* testsuite/18_support/headers/new/synopsis.cc
(hardware_destructive_interference_size)
(hardware_constructive_interference_size): Likewise for commented-out
variables.
* testsuite/20_util/tuple/creation_functions/constexpr.cc: Add new
test function for constexpr std::ignore (LWG 2773).
* testsuite/20_util/tuple/creation_functions/constexpr_cpp14.cc: New
test for LWG 2933.
From-SVN: r246423
2017-03-23 20:40:07 +01:00
|
|
|
inline constexpr bool ratio_less_equal_v =
|
|
|
|
ratio_less_equal<_R1, _R2>::value;
|
Implement C++17 variable templates for type traits.
* include/std/chrono (treat_as_floating_point_v): New.
* include/std/ratio (ratio_equal_v, ratio_not_equal_v)
(ratio_less_v, ratio_less_equal_v, ratio_greater_v)
(ratio_greater_equal_v): Likewise.
* include/std/system_error (is_error_code_enum_v)
(is_error_condition_enum_v): Likewise.
* include/std/tuple (tuple_size_v): Likewise.
* type_traits (conjunction_v, disjunction_v, negation_v)
(is_void_v, is_null_pointer_v, is_integral_v, is_floating_point_v)
(is_array_v, is_pointer_v, is_lvalue_reference_v)
(is_rvalue_reference_v, is_member_object_pointer_v)
(is_member_function_pointer_v, is_enum_v, is_union_v)
(is_class_v, is_function_v, is_reference_v, is_arithmetic_v)
(is_fundamental_v, is_object_v, is_scalar_v, is_compound_v)
(is_member_pointer_v, is_const_v, is_volatile_v, is_trivial_v)
(is_trivially_copyable_v, is_standard_layout_v)
(is_pod_v, is_literal_type_v, is_empty_v, is_polymorphic_v)
(is_abstract_v, is_final_v, is_signed_v, is_unsigned_v)
(is_constructible_v, is_default_constructible_v)
(is_copy_constructible_v, is_move_constructible_v)
(is_assignable_v, is_copy_assignable_v, is_move_assignable_v)
(is_destructible_v, is_trivially_constructible_v)
(is_trivially_default_constructible_v)
(is_trivially_copy_constructible_v, is_trivially_move_constructible_v)
(is_trivially_assignable_v, is_trivially_copy_assignable_v)
(is_trivially_move_assignable_v, is_trivially_destructible_v)
(is_nothrow_constructible_v, is_nothrow_default_constructible_v)
(is_nothrow_copy_constructible_v, is_nothrow_move_constructible_v)
(is_nothrow_assignable_v, is_nothrow_copy_assignable_v)
(is_nothrow_move_assignable_v, is_nothrow_destructible_v)
(has_virtual_destructor_v, alignment_of_v, rank_v, extent_v)
(is_same_v, is_base_of_v, is_convertible_v): Likewise.
* testsuite/19_diagnostics/error_code/is_error_code_v.cc: Likewise.
* testsuite/20_util/duration/requirements/treat_as_floating_point_v.cc:
Likewise.
* testsuite/20_util/ratio/requirements/ratio_equal_v.cc: Likewise.
* testsuite/20_util/tuple/tuple_size_v.cc: Likewise.
* testsuite/20_util/variable_templates_for_traits.cc: Likewise.
From-SVN: r238892
2016-07-29 21:01:39 +02:00
|
|
|
template <typename _R1, typename _R2>
|
Implement P0607R0 "Inline Variables for Standard Library" for C++17
2017-03-23 Daniel Kruegler <daniel.kruegler@gmail.com>
* include/bits/c++config (_GLIBCXX17_INLINE): Define.
* include/bits/regex_constants.h (All std::regex_constants constants):
Add _GLIBCXX17_INLINE as per P0607R0.
* include/bits/std_mutex.h (defer_lock, try_to_lock, adopt_lock):
Likewise.
* include/bits/stl_pair.h (piecewise_construct): Likewise.
* include/bits/uses_allocator.h (allocator_arg, uses_allocator_v)
(__is_uses_allocator_constructible_v)
(__is_nothrow_uses_allocator_constructible_v): Likewise.
* include/std/chrono (treat_as_floating_point_v): Likewise.
* include/std/functional (is_bind_expression_v, is_placeholder_v):
Likewise.
* include/std/optional (nullopt): Likewise.
* include/std/ratio (ratio_equal_v, ratio_not_equal_v, ratio_less_v)
ratio_less_equal_v, ratio_greater_v, ratio_greater_equal_v): Likewise.
* include/std/system_error (is_error_code_enum_v)
(is_error_condition_enum_v): Likewise.
* include/std/tuple (tuple_size_v, ignore): Likewise.
(ignore): Declare ignore constexpr as per LWG 2773, declare assignment
constexpr as per LWG 2933.
* include/std/type_traits (All variable templates): Add
_GLIBCXX17_INLINE as per P0607R0.
* include/std/variant (variant_size_v, variant_npos, __index_of_v)
(__tuple_count_v, __exactly_once): Likewise.
* testsuite/18_support/headers/new/synopsis.cc
(hardware_destructive_interference_size)
(hardware_constructive_interference_size): Likewise for commented-out
variables.
* testsuite/20_util/tuple/creation_functions/constexpr.cc: Add new
test function for constexpr std::ignore (LWG 2773).
* testsuite/20_util/tuple/creation_functions/constexpr_cpp14.cc: New
test for LWG 2933.
From-SVN: r246423
2017-03-23 20:40:07 +01:00
|
|
|
inline constexpr bool ratio_greater_v = ratio_greater<_R1, _R2>::value;
|
Implement C++17 variable templates for type traits.
* include/std/chrono (treat_as_floating_point_v): New.
* include/std/ratio (ratio_equal_v, ratio_not_equal_v)
(ratio_less_v, ratio_less_equal_v, ratio_greater_v)
(ratio_greater_equal_v): Likewise.
* include/std/system_error (is_error_code_enum_v)
(is_error_condition_enum_v): Likewise.
* include/std/tuple (tuple_size_v): Likewise.
* type_traits (conjunction_v, disjunction_v, negation_v)
(is_void_v, is_null_pointer_v, is_integral_v, is_floating_point_v)
(is_array_v, is_pointer_v, is_lvalue_reference_v)
(is_rvalue_reference_v, is_member_object_pointer_v)
(is_member_function_pointer_v, is_enum_v, is_union_v)
(is_class_v, is_function_v, is_reference_v, is_arithmetic_v)
(is_fundamental_v, is_object_v, is_scalar_v, is_compound_v)
(is_member_pointer_v, is_const_v, is_volatile_v, is_trivial_v)
(is_trivially_copyable_v, is_standard_layout_v)
(is_pod_v, is_literal_type_v, is_empty_v, is_polymorphic_v)
(is_abstract_v, is_final_v, is_signed_v, is_unsigned_v)
(is_constructible_v, is_default_constructible_v)
(is_copy_constructible_v, is_move_constructible_v)
(is_assignable_v, is_copy_assignable_v, is_move_assignable_v)
(is_destructible_v, is_trivially_constructible_v)
(is_trivially_default_constructible_v)
(is_trivially_copy_constructible_v, is_trivially_move_constructible_v)
(is_trivially_assignable_v, is_trivially_copy_assignable_v)
(is_trivially_move_assignable_v, is_trivially_destructible_v)
(is_nothrow_constructible_v, is_nothrow_default_constructible_v)
(is_nothrow_copy_constructible_v, is_nothrow_move_constructible_v)
(is_nothrow_assignable_v, is_nothrow_copy_assignable_v)
(is_nothrow_move_assignable_v, is_nothrow_destructible_v)
(has_virtual_destructor_v, alignment_of_v, rank_v, extent_v)
(is_same_v, is_base_of_v, is_convertible_v): Likewise.
* testsuite/19_diagnostics/error_code/is_error_code_v.cc: Likewise.
* testsuite/20_util/duration/requirements/treat_as_floating_point_v.cc:
Likewise.
* testsuite/20_util/ratio/requirements/ratio_equal_v.cc: Likewise.
* testsuite/20_util/tuple/tuple_size_v.cc: Likewise.
* testsuite/20_util/variable_templates_for_traits.cc: Likewise.
From-SVN: r238892
2016-07-29 21:01:39 +02:00
|
|
|
template <typename _R1, typename _R2>
|
Implement P0607R0 "Inline Variables for Standard Library" for C++17
2017-03-23 Daniel Kruegler <daniel.kruegler@gmail.com>
* include/bits/c++config (_GLIBCXX17_INLINE): Define.
* include/bits/regex_constants.h (All std::regex_constants constants):
Add _GLIBCXX17_INLINE as per P0607R0.
* include/bits/std_mutex.h (defer_lock, try_to_lock, adopt_lock):
Likewise.
* include/bits/stl_pair.h (piecewise_construct): Likewise.
* include/bits/uses_allocator.h (allocator_arg, uses_allocator_v)
(__is_uses_allocator_constructible_v)
(__is_nothrow_uses_allocator_constructible_v): Likewise.
* include/std/chrono (treat_as_floating_point_v): Likewise.
* include/std/functional (is_bind_expression_v, is_placeholder_v):
Likewise.
* include/std/optional (nullopt): Likewise.
* include/std/ratio (ratio_equal_v, ratio_not_equal_v, ratio_less_v)
ratio_less_equal_v, ratio_greater_v, ratio_greater_equal_v): Likewise.
* include/std/system_error (is_error_code_enum_v)
(is_error_condition_enum_v): Likewise.
* include/std/tuple (tuple_size_v, ignore): Likewise.
(ignore): Declare ignore constexpr as per LWG 2773, declare assignment
constexpr as per LWG 2933.
* include/std/type_traits (All variable templates): Add
_GLIBCXX17_INLINE as per P0607R0.
* include/std/variant (variant_size_v, variant_npos, __index_of_v)
(__tuple_count_v, __exactly_once): Likewise.
* testsuite/18_support/headers/new/synopsis.cc
(hardware_destructive_interference_size)
(hardware_constructive_interference_size): Likewise for commented-out
variables.
* testsuite/20_util/tuple/creation_functions/constexpr.cc: Add new
test function for constexpr std::ignore (LWG 2773).
* testsuite/20_util/tuple/creation_functions/constexpr_cpp14.cc: New
test for LWG 2933.
From-SVN: r246423
2017-03-23 20:40:07 +01:00
|
|
|
inline constexpr bool ratio_greater_equal_v
|
Implement C++17 variable templates for type traits.
* include/std/chrono (treat_as_floating_point_v): New.
* include/std/ratio (ratio_equal_v, ratio_not_equal_v)
(ratio_less_v, ratio_less_equal_v, ratio_greater_v)
(ratio_greater_equal_v): Likewise.
* include/std/system_error (is_error_code_enum_v)
(is_error_condition_enum_v): Likewise.
* include/std/tuple (tuple_size_v): Likewise.
* type_traits (conjunction_v, disjunction_v, negation_v)
(is_void_v, is_null_pointer_v, is_integral_v, is_floating_point_v)
(is_array_v, is_pointer_v, is_lvalue_reference_v)
(is_rvalue_reference_v, is_member_object_pointer_v)
(is_member_function_pointer_v, is_enum_v, is_union_v)
(is_class_v, is_function_v, is_reference_v, is_arithmetic_v)
(is_fundamental_v, is_object_v, is_scalar_v, is_compound_v)
(is_member_pointer_v, is_const_v, is_volatile_v, is_trivial_v)
(is_trivially_copyable_v, is_standard_layout_v)
(is_pod_v, is_literal_type_v, is_empty_v, is_polymorphic_v)
(is_abstract_v, is_final_v, is_signed_v, is_unsigned_v)
(is_constructible_v, is_default_constructible_v)
(is_copy_constructible_v, is_move_constructible_v)
(is_assignable_v, is_copy_assignable_v, is_move_assignable_v)
(is_destructible_v, is_trivially_constructible_v)
(is_trivially_default_constructible_v)
(is_trivially_copy_constructible_v, is_trivially_move_constructible_v)
(is_trivially_assignable_v, is_trivially_copy_assignable_v)
(is_trivially_move_assignable_v, is_trivially_destructible_v)
(is_nothrow_constructible_v, is_nothrow_default_constructible_v)
(is_nothrow_copy_constructible_v, is_nothrow_move_constructible_v)
(is_nothrow_assignable_v, is_nothrow_copy_assignable_v)
(is_nothrow_move_assignable_v, is_nothrow_destructible_v)
(has_virtual_destructor_v, alignment_of_v, rank_v, extent_v)
(is_same_v, is_base_of_v, is_convertible_v): Likewise.
* testsuite/19_diagnostics/error_code/is_error_code_v.cc: Likewise.
* testsuite/20_util/duration/requirements/treat_as_floating_point_v.cc:
Likewise.
* testsuite/20_util/ratio/requirements/ratio_equal_v.cc: Likewise.
* testsuite/20_util/tuple/tuple_size_v.cc: Likewise.
* testsuite/20_util/variable_templates_for_traits.cc: Likewise.
From-SVN: r238892
2016-07-29 21:01:39 +02:00
|
|
|
= ratio_greater_equal<_R1, _R2>::value;
|
|
|
|
#endif // C++17
|
|
|
|
|
2019-05-08 00:46:53 +02:00
|
|
|
/// @cond undocumented
|
|
|
|
|
2011-05-05 01:23:54 +02:00
|
|
|
template<typename _R1, typename _R2,
|
|
|
|
bool = (_R1::num >= 0),
|
|
|
|
bool = (_R2::num >= 0),
|
|
|
|
bool = ratio_less<ratio<__static_abs<_R1::num>::value, _R1::den>,
|
|
|
|
ratio<__static_abs<_R2::num>::value, _R2::den> >::value>
|
|
|
|
struct __ratio_add_impl
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
typedef typename __ratio_add_impl<
|
|
|
|
ratio<-_R1::num, _R1::den>,
|
|
|
|
ratio<-_R2::num, _R2::den> >::type __t;
|
|
|
|
public:
|
|
|
|
typedef ratio<-__t::num, __t::den> type;
|
|
|
|
};
|
|
|
|
|
|
|
|
// True addition of nonnegative numbers.
|
|
|
|
template<typename _R1, typename _R2, bool __b>
|
|
|
|
struct __ratio_add_impl<_R1, _R2, true, true, __b>
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
static constexpr uintmax_t __g = __static_gcd<_R1::den, _R2::den>::value;
|
|
|
|
static constexpr uintmax_t __d2 = _R2::den / __g;
|
|
|
|
typedef __big_mul<_R1::den, __d2> __d;
|
|
|
|
typedef __big_mul<_R1::num, _R2::den / __g> __x;
|
|
|
|
typedef __big_mul<_R2::num, _R1::den / __g> __y;
|
|
|
|
typedef __big_add<__x::__hi, __x::__lo, __y::__hi, __y::__lo> __n;
|
|
|
|
static_assert(__n::__hi >= __x::__hi, "Internal library error");
|
|
|
|
typedef __big_div<__n::__hi, __n::__lo, __g> __ng;
|
|
|
|
static constexpr uintmax_t __g2 = __static_gcd<__ng::__rem, __g>::value;
|
|
|
|
typedef __big_div<__n::__hi, __n::__lo, __g2> __n_final;
|
|
|
|
static_assert(__n_final::__rem == 0, "Internal library error");
|
|
|
|
static_assert(__n_final::__quot_hi == 0 &&
|
|
|
|
__n_final::__quot_lo <= __INTMAX_MAX__, "overflow in addition");
|
|
|
|
typedef __big_mul<_R1::den / __g2, __d2> __d_final;
|
|
|
|
static_assert(__d_final::__hi == 0 &&
|
|
|
|
__d_final::__lo <= __INTMAX_MAX__, "overflow in addition");
|
|
|
|
public:
|
|
|
|
typedef ratio<__n_final::__quot_lo, __d_final::__lo> type;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename _R1, typename _R2>
|
|
|
|
struct __ratio_add_impl<_R1, _R2, false, true, true>
|
|
|
|
: __ratio_add_impl<_R2, _R1>
|
|
|
|
{ };
|
|
|
|
|
|
|
|
// True subtraction of nonnegative numbers yielding a nonnegative result.
|
|
|
|
template<typename _R1, typename _R2>
|
|
|
|
struct __ratio_add_impl<_R1, _R2, true, false, false>
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
static constexpr uintmax_t __g = __static_gcd<_R1::den, _R2::den>::value;
|
|
|
|
static constexpr uintmax_t __d2 = _R2::den / __g;
|
|
|
|
typedef __big_mul<_R1::den, __d2> __d;
|
|
|
|
typedef __big_mul<_R1::num, _R2::den / __g> __x;
|
|
|
|
typedef __big_mul<-_R2::num, _R1::den / __g> __y;
|
|
|
|
typedef __big_sub<__x::__hi, __x::__lo, __y::__hi, __y::__lo> __n;
|
|
|
|
typedef __big_div<__n::__hi, __n::__lo, __g> __ng;
|
|
|
|
static constexpr uintmax_t __g2 = __static_gcd<__ng::__rem, __g>::value;
|
|
|
|
typedef __big_div<__n::__hi, __n::__lo, __g2> __n_final;
|
|
|
|
static_assert(__n_final::__rem == 0, "Internal library error");
|
|
|
|
static_assert(__n_final::__quot_hi == 0 &&
|
|
|
|
__n_final::__quot_lo <= __INTMAX_MAX__, "overflow in addition");
|
|
|
|
typedef __big_mul<_R1::den / __g2, __d2> __d_final;
|
|
|
|
static_assert(__d_final::__hi == 0 &&
|
|
|
|
__d_final::__lo <= __INTMAX_MAX__, "overflow in addition");
|
|
|
|
public:
|
|
|
|
typedef ratio<__n_final::__quot_lo, __d_final::__lo> type;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename _R1, typename _R2>
|
2012-07-03 21:24:07 +02:00
|
|
|
struct __ratio_add
|
2011-05-05 01:23:54 +02:00
|
|
|
{
|
|
|
|
typedef typename __ratio_add_impl<_R1, _R2>::type type;
|
|
|
|
static constexpr intmax_t num = type::num;
|
|
|
|
static constexpr intmax_t den = type::den;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename _R1, typename _R2>
|
2012-07-03 21:24:07 +02:00
|
|
|
constexpr intmax_t __ratio_add<_R1, _R2>::num;
|
2011-05-05 01:23:54 +02:00
|
|
|
|
|
|
|
template<typename _R1, typename _R2>
|
2012-07-03 21:24:07 +02:00
|
|
|
constexpr intmax_t __ratio_add<_R1, _R2>::den;
|
2011-05-05 01:23:54 +02:00
|
|
|
|
2019-05-08 00:46:53 +02:00
|
|
|
/// @endcond
|
|
|
|
|
2012-07-03 21:24:07 +02:00
|
|
|
/// ratio_add
|
2011-05-05 01:23:54 +02:00
|
|
|
template<typename _R1, typename _R2>
|
2012-07-03 21:24:07 +02:00
|
|
|
using ratio_add = typename __ratio_add<_R1, _R2>::type;
|
|
|
|
|
2019-05-08 00:46:53 +02:00
|
|
|
/// @cond undocumented
|
|
|
|
|
2012-07-03 21:24:07 +02:00
|
|
|
template<typename _R1, typename _R2>
|
|
|
|
struct __ratio_subtract
|
2011-05-05 01:23:54 +02:00
|
|
|
{
|
2012-07-03 21:24:07 +02:00
|
|
|
typedef typename __ratio_add<
|
2011-05-05 01:23:54 +02:00
|
|
|
_R1,
|
|
|
|
ratio<-_R2::num, _R2::den>>::type type;
|
|
|
|
|
|
|
|
static constexpr intmax_t num = type::num;
|
|
|
|
static constexpr intmax_t den = type::den;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename _R1, typename _R2>
|
2012-07-03 21:24:07 +02:00
|
|
|
constexpr intmax_t __ratio_subtract<_R1, _R2>::num;
|
2011-05-05 01:23:54 +02:00
|
|
|
|
|
|
|
template<typename _R1, typename _R2>
|
2012-07-03 21:24:07 +02:00
|
|
|
constexpr intmax_t __ratio_subtract<_R1, _R2>::den;
|
2011-05-05 01:23:54 +02:00
|
|
|
|
2019-05-08 00:46:53 +02:00
|
|
|
/// @endcond
|
|
|
|
|
2012-07-03 21:24:07 +02:00
|
|
|
/// ratio_subtract
|
|
|
|
template<typename _R1, typename _R2>
|
|
|
|
using ratio_subtract = typename __ratio_subtract<_R1, _R2>::type;
|
2011-05-05 01:23:54 +02:00
|
|
|
|
|
|
|
|
2008-07-04 20:45:09 +02:00
|
|
|
typedef ratio<1, 1000000000000000000> atto;
|
|
|
|
typedef ratio<1, 1000000000000000> femto;
|
|
|
|
typedef ratio<1, 1000000000000> pico;
|
|
|
|
typedef ratio<1, 1000000000> nano;
|
|
|
|
typedef ratio<1, 1000000> micro;
|
|
|
|
typedef ratio<1, 1000> milli;
|
|
|
|
typedef ratio<1, 100> centi;
|
|
|
|
typedef ratio<1, 10> deci;
|
|
|
|
typedef ratio< 10, 1> deca;
|
|
|
|
typedef ratio< 100, 1> hecto;
|
|
|
|
typedef ratio< 1000, 1> kilo;
|
|
|
|
typedef ratio< 1000000, 1> mega;
|
|
|
|
typedef ratio< 1000000000, 1> giga;
|
|
|
|
typedef ratio< 1000000000000, 1> tera;
|
|
|
|
typedef ratio< 1000000000000000, 1> peta;
|
|
|
|
typedef ratio< 1000000000000000000, 1> exa;
|
2009-02-21 01:45:21 +01:00
|
|
|
|
|
|
|
// @} group ratio
|
PR libstdc++/36104 part four
2011-01-30 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/36104 part four
* include/bits/c++config (_GLIBCXX_STD): Remove.
(_GLIBCXX_STD_D, _GLIBCXX_PR): Now _GLIBCXX_STD_C.
(_GLIBCXX_P): Now _GLIBCXX_STD_A.
(_GLIBCXX_NAMESPACE_DEBUG, _GLIBCXX_NAMESPACE_PARALLEL,
_GLIBCXX_NAMESPACE_PROFILE, _GLIBCXX_NAMESPACE_VERSION): Remove.
(_GLIBCXX_INLINE_DEBUG, _GLIBCXX_INLINE_PARALLEL,
_GLIBCXX_INLINE_PROFILE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE(X)): Remove.
(_GLIBCXX_END_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NESTED_NAMESPACE(X, Y)): Remove.
(_GLIBCXX_END_NESTED_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE_ALGO): Add.
(_GLIBCXX_END_NAMESPACE_ALGO): Add.
(_GLIBCXX_BEGIN_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_END_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_BEGIN_NAMESPACE_VERSION): Add.
(_GLIBCXX_END_NAMESPACE_VERSION): Add.
(_GLIBCXX_BEGIN_LDBL_NAMESPACE): To _GLIBCXX_BEGIN_NAMESPACE_LDBL.
(_GLIBCXX_END_LDBL_NAMESPACE): To _GLIBCXX_END_NAMESPACE_LDBL.
(_GLIBCXX_VISIBILITY_ATTR): Revert to _GLIBCXX_VISIBILITY.
* include/*: Use new macros for namespace scope.
* config/*: Same.
* src/*: Same.
* src/Makefile.am (sources): Remove debug_list.cc, add
compatibility-debug_list-2.cc.
(parallel_sources): Remove parallel_list.cc, add
compatibility-parallel_list-2.cc.
(compatibility-parallel_list-2.[o,lo]): New rule.
* src/Makefile.in: Regenerate.
* src/debug_list.cc: Remove.
* src/parallel_list.cc: Remove.
* src/compatibility-list-2.cc: New.
* src/compatibility-debug_list-2.cc: New.
* src/compatibility-parallel_list-2.cc: New.
* doc/doxygen/user.cfg.in: Adjust macros.
* testsuite/20_util/auto_ptr/assign_neg.cc: Adjust line numbers, macros.
* testsuite/20_util/declval/requirements/1_neg.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Same.
* testsuite/20_util/forward/c_neg.cc: Same.
* testsuite/20_util/forward/f_neg.cc: Same.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Same.
* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Same.
* testsuite/20_util/shared_ptr/cons/43820_neg.cc: Same.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/forward_list/capacity/1.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
assign_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
insert_neg.cc: Same.
* testsuite/23_containers/list/capacity/29134.cc: Same.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/vector/bool/capacity/29134.cc: Same.
* testsuite/23_containers/vector/bool/modifiers/insert/31370.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc: Same.
* testsuite/25_algorithms/sort/35588.cc: Same.
* testsuite/27_io/ios_base/cons/assign_neg.cc: Same.
* testsuite/27_io/ios_base/cons/copy_neg.cc: Same.
* testsuite/ext/profile/mutex_extensions_neg.cc: Same.
* testsuite/ext/profile/profiler_algos.cc: Same.
* testsuite/ext/type_traits/add_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/add_unsigned_integer_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_integer_neg.cc: Same.
* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc: Same.
From-SVN: r169421
2011-01-30 23:39:36 +01:00
|
|
|
_GLIBCXX_END_NAMESPACE_VERSION
|
|
|
|
} // namespace
|
2008-07-04 20:45:09 +02:00
|
|
|
|
2012-11-10 18:27:22 +01:00
|
|
|
#endif // C++11
|
2008-07-04 20:45:09 +02:00
|
|
|
|
|
|
|
#endif //_GLIBCXX_RATIO
|