aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/tr1/random
diff options
context:
space:
mode:
authorBenjamin Kosnik <bkoz@redhat.com>2006-09-18 13:30:56 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2006-09-18 13:30:56 +0000
commit105c6331b2b4a1e573bf237eaf9c572e18f8147c (patch)
tree45a99e66079ad8c76c24028341e6552ea91cf361 /libstdc++-v3/include/tr1/random
parentbcc4a44f6b929d0640370f1dd6aafccba481527c (diff)
downloadgcc-105c6331b2b4a1e573bf237eaf9c572e18f8147c.zip
gcc-105c6331b2b4a1e573bf237eaf9c572e18f8147c.tar.gz
gcc-105c6331b2b4a1e573bf237eaf9c572e18f8147c.tar.bz2
type_traits.h: New.
2006-09-18 Benjamin Kosnik <bkoz@redhat.com> Peter Doerfler <gcc@pdoerfler.com> Paolo Carlini <pcarlini@suse.de> * include/ext/type_traits.h: New. (__conditional_type): New. (__numeric_traits): New. (__add_unsigned): New. (__remove_unsigned): New. (__enable_if): New. * include/Makefile.am: Add. * include/Makefile.in: Regenerate. * include/ext/pb_ds/detail/type_utils.hpp: Use ext include, remove duplicates. * include/tr1/hashtable_policy.h (IF): Use __conditional_type. (_Max_digits10): Same. (identity): Use _Identity. (extract1st): Use _Select1st. * include/tr1/random (_Select): Use __conditional_type. (_To_Unsigned_Type): Use __add_unsigned. Linebreak fixups. * include/bits/locale_facets.tcc (__to_unsigned_type): Remove, use __add_unsigned. * include/tr1/random.tcc: Fixups as above. * include/tr1/unordered_map: Same. * include/tr1/hashtable: Same. * include/tr1/unordered_set: Same. * include/ext/pb_ds/detail/gp_hash_table_map_/ standard_policies.hpp: Same. * include/ext/pb_ds/detail/standard_policies.hpp: Same. * include/ext/pb_ds/detail/typelist/typelist_filter.hpp: Same. * include/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp: Same. * include/ext/pb_ds/detail/type_utils.hpp: Same. * include/ext/pb_ds/trie_policy.hpp: Same. * docs/html/ext/pb_ds/string_trie_e_access_traits.html: Same. * include/bits/cpp_type_traits.h (__enable_if): Move to ext, make boolean argument first. * include/bits/locale_facets.h: Fixups for __enable_if argument and namespace switch. * include/bits/stl_algobase.h: Same. * include/bits/stl_algo.h: Same. * include/bits/stl_iterator.h: Same. * include/bits/streambuf_iterator.h: Same. * include/debug/safe_iterator.h: Same. * include/tr1/hashtable_policy.h: Same. * include/tr1/cmath: Same. * include/tr1/functional: Same. * include/tr1/functional_iterate.h: Same. * include/std/std_streambuf.h: Same. * include/c_std/std_cmath.h: Same. * testsuite/util/testsuite_tr1.h: Same. * testsuite/util/performance/assoc/multimap_common_type.hpp: Same. Co-Authored-By: Paolo Carlini <pcarlini@suse.de> Co-Authored-By: Peter Doerfler <gcc@pdoerfler.com> From-SVN: r117024
Diffstat (limited to 'libstdc++-v3/include/tr1/random')
-rw-r--r--libstdc++-v3/include/tr1/random87
1 files changed, 39 insertions, 48 deletions
diff --git a/libstdc++-v3/include/tr1/random b/libstdc++-v3/include/tr1/random
index 8ffdf16..b926c5b 100644
--- a/libstdc++-v3/include/tr1/random
+++ b/libstdc++-v3/include/tr1/random
@@ -37,7 +37,6 @@
#include <algorithm>
#include <bits/concept_check.h>
-#include <bits/cpp_type_traits.h>
#include <cmath>
#include <debug/debug.h>
#include <iterator>
@@ -46,6 +45,7 @@
#include <tr1/type_traits>
#include <tr1/cmath>
#include <fstream>
+#include <ext/type_traits.h>
namespace std
{
@@ -64,17 +64,8 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
*/
namespace
{
- // Type selectors -- are these already implemented elsewhere?
- template<bool, typename _TpTrue, typename _TpFalse>
- struct _Select
- { typedef _TpTrue _Type; };
-
- template<typename _TpTrue, typename _TpFalse>
- struct _Select<false, _TpTrue, _TpFalse>
- { typedef _TpFalse _Type; };
-
- template<typename _UIntType, int __w, bool =
- __w < std::numeric_limits<_UIntType>::digits>
+ template<typename _UIntType, int __w,
+ bool = __w < std::numeric_limits<_UIntType>::digits>
struct _Shift
{ static const _UIntType __value = 0; };
@@ -92,11 +83,8 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
__mod(_Tp __x)
{ return _Mod<_Tp, __a, __c, __m, __m == 0>::__calc(__x); }
- template<typename _ValueT>
- struct _To_Unsigned_Type;
-
- typedef _Select<(sizeof(unsigned) == 4),
- unsigned, unsigned long>::_Type _UInt32Type;
+ typedef __gnu_cxx::__conditional_type<(sizeof(unsigned) == 4),
+ unsigned, unsigned long>::__type _UInt32Type;
} // anonymous namespace
/*
@@ -193,9 +181,8 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
typedef typename _Dist::result_type result_type;
// tr1:5.1.1 table 5.1 requirement
- typedef typename std::__enable_if<result_type,
- is_arithmetic<result_type>::value
- >::__type _IsValidType;
+ typedef typename __gnu_cxx::__enable_if<
+ is_arithmetic<result_type>::value, result_type>::__type _IsValidType;
public:
/**
@@ -277,20 +264,19 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
* @addtogroup tr1_random_generators Random Number Generators
* @ingroup tr1_random
*
- * These classes define objects which provide random or pseudorandom numbers,
- * either from a discrete or a continuous interval. The random number
- * generator supplied as a part of this library are all uniform random number
- * generators which provide a sequence of random number uniformly distributed
- * over their range.
+ * These classes define objects which provide random or pseudorandom
+ * numbers, either from a discrete or a continuous interval. The
+ * random number generator supplied as a part of this library are
+ * all uniform random number generators which provide a sequence of
+ * random number uniformly distributed over their range.
*
- * A number generator is a function object with an operator() that takes zero
- * arguments and returns a number.
+ * A number generator is a function object with an operator() that
+ * takes zero arguments and returns a number.
*
- * A compliant random number generator must satisy the following requirements.
- * <table border=1 cellpadding=10 cellspacing=0>
+ * A compliant random number generator must satisy the following
+ * requirements. <table border=1 cellpadding=10 cellspacing=0>
* <caption align=top>Random Number Generator Requirements</caption>
- * <tr><td>To be documented.</td></tr>
- * </table>
+ * <tr><td>To be documented.</td></tr> </table>
*
* @{
*/
@@ -704,8 +690,9 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
* This is a model of a Generalized Fibonacci discrete random number
* generator, sometimes referred to as the SWC generator.
*
- * A discrete random number generator that produces pseudorandom numbers using
- * @f$x_{i}\leftarrow(x_{i - s} - x_{i - r} - carry_{i-1}) \bmod m @f$.
+ * A discrete random number generator that produces pseudorandom
+ * numbers using @f$x_{i}\leftarrow(x_{i - s} - x_{i - r} -
+ * carry_{i-1}) \bmod m @f$.
*
* The size of the state is @f$ r @f$
* and the maximum period of the generator is @f$ m^r - m^s -1 @f$.
@@ -777,13 +764,13 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
/**
* Seeds the initial state @f$ x_0 @f$ of the random number generator.
*
- * N1688[4.19] modifies this as follows.
- * If @p __value == 0, sets value to 19780503. In any case, with a linear
+ * N1688[4.19] modifies this as follows. If @p __value == 0,
+ * sets value to 19780503. In any case, with a linear
* congruential generator lcg(i) having parameters @f$ m_{lcg} =
- * 2147483563, a_{lcg} = 40014, c_{lcg} = 0, and lcg(0) = value @f$, sets
- * @f$ x_{-r} \dots x_{-1} @f$ to
- * @f$ lcg(1) \bmod m \dots lcg(r) \bmod m @f$ respectively.
- * If @f$ x_{-1} = 0 @f$ set carry to 1, otherwise sets carry to 0.
+ * 2147483563, a_{lcg} = 40014, c_{lcg} = 0, and lcg(0) = value
+ * @f$, sets @f$ x_{-r} \dots x_{-1} @f$ to @f$ lcg(1) \bmod m
+ * \dots lcg(r) \bmod m @f$ respectively. If @f$ x_{-1} = 0 @f$
+ * set carry to 1, otherwise sets carry to 0.
*/
void
seed(unsigned long __value = 19780503);
@@ -893,7 +880,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
seed(_Gen& __g, false_type);
private:
- typedef typename _To_Unsigned_Type<_IntType>::_Type _UIntType;
+ typedef typename __gnu_cxx::__add_unsigned<_IntType>::__type _UIntType;
_UIntType _M_x[long_lag];
_UIntType _M_carry;
@@ -1014,7 +1001,8 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
* Compares two % subtract_with_carry_01 random number generator objects
* of the same type for equality.
*
- * @param __lhs A % subtract_with_carry_01 random number generator object.
+ * @param __lhs A % subtract_with_carry_01 random number
+ * generator object.
* @param __rhs Another % subtract_with_carry_01 random number generator
* object.
*
@@ -1035,7 +1023,9 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
* Compares two % subtract_with_carry_01 random number generator objects
* of the same type for inequality.
*
- * @param __lhs A % subtract_with_carry_01 random number generator object.
+ * @param __lhs A % subtract_with_carry_01 random number
+ * generator object.
+ *
* @param __rhs Another % subtract_with_carry_01 random number generator
* object.
*
@@ -1376,8 +1366,8 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
public:
/** The type of the generated random value. */
- typedef typename _Select<(sizeof(_Result_type1) > sizeof(_Result_type2)),
- _Result_type1, _Result_type2>::_Type result_type;
+ typedef typename __gnu_cxx::__conditional_type<(sizeof(_Result_type1) > sizeof(_Result_type2)),
+ _Result_type1, _Result_type2>::__type result_type;
// parameter values
static const int shift1 = __s1;
@@ -1518,8 +1508,8 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
/**
- * A standard interface to a platform-specific non-deterministic random number
- * generator (if any are available).
+ * A standard interface to a platform-specific non-deterministic
+ * random number generator (if any are available).
*/
class random_device
{
@@ -2091,7 +2081,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
const _RealType& __p = _RealType(0.5))
: _M_t(__t), _M_p(__p), _M_nd()
{
- _GLIBCXX_DEBUG_ASSERT((_M_t >= 0) && (_M_p >= 0.0) && (_M_p <= 1.0));
+ _GLIBCXX_DEBUG_ASSERT((_M_t >= 0) && (_M_p >= 0.0) && (_M_p <= 1.0));
_M_initialize();
}
@@ -2355,7 +2345,8 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
* @p __x from the input stream @p __is.
*
* @param __is An input stream.
- * @param __x A %exponential_distribution random number generator engine.
+ * @param __x A %exponential_distribution random number
+ * generator engine.
*
* @returns The input stream with @p __x extracted or in an error state.
*/