OSDN Git Service

2012-11-02 Paolo Carlini <paolo.carlini@oracle.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / include / bits / random.h
index b7ba1e0..1e8caa0 100644 (file)
@@ -1,6 +1,6 @@
 // random number generation -*- C++ -*-
 
-// Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+// Copyright (C) 2009-2012 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
 /**
  * @file bits/random.h
  *  This is an internal header file, included by other library headers.
- *  You should not attempt to use it directly.
+ *  Do not attempt to use it directly. @headername{random}
  */
 
+#ifndef _RANDOM_H
+#define _RANDOM_H 1
+
 #include <vector>
 
-namespace std
+namespace std _GLIBCXX_VISIBILITY(default)
 {
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
   // [26.4] Random number generation
 
   /**
-   * @addtogroup std_random Random Number Generation
+   * @defgroup random Random Number Generation
+   * @ingroup numerics
+   *
    * A facility for generating random numbers on selected distributions.
    * @{
    */
@@ -50,11 +57,15 @@ namespace std
     _RealType
     generate_canonical(_UniformRandomNumberGenerator& __g);
 
+_GLIBCXX_END_NAMESPACE_VERSION
+
   /*
    * Implementation-space details.
    */
   namespace __detail
   {
+  _GLIBCXX_BEGIN_NAMESPACE_VERSION
+
     template<typename _UIntType, size_t __w,
             bool = __w < static_cast<size_t>
                          (std::numeric_limits<_UIntType>::digits)>
@@ -111,11 +122,15 @@ namespace std
       private:
        _Engine& _M_g;
       };
+
+  _GLIBCXX_END_NAMESPACE_VERSION
   } // namespace __detail
 
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
   /**
-   * @addtogroup std_random_generators Random Number Generators
-   * @ingroup std_random
+   * @addtogroup random_generators Random Number Generators
+   * @ingroup random
    *
    * These classes define objects which provide random or pseudorandom
    * numbers, either from a discrete or a continuous interval.  The
@@ -159,17 +174,22 @@ namespace std
       static_assert(__m == 0u || (__a < __m && __c < __m),
                    "template argument substituting __m out of bounds");
 
+      // XXX FIXME:
+      // _Mod::__calc should handle correctly __m % __a >= __m / __a too.
+      static_assert(__m % __a < __m / __a,
+                   "sorry, not implemented yet: try a smaller 'a' constant");
+
     public:
       /** The type of the generated random value. */
       typedef _UIntType result_type;
 
       /** The multiplier. */
-      static const result_type multiplier   = __a;
+      static constexpr result_type multiplier   = __a;
       /** An increment. */
-      static const result_type increment    = __c;
+      static constexpr result_type increment    = __c;
       /** The modulus. */
-      static const result_type modulus      = __m;
-      static const result_type default_seed = 1u;
+      static constexpr result_type modulus      = __m;
+      static constexpr result_type default_seed = 1u;
 
       /**
        * @brief Constructs a %linear_congruential_engine random number
@@ -188,11 +208,12 @@ namespace std
        *
        * @param __q the seed sequence.
        */
-      template<typename _Sseq, typename
-              = typename std::enable_if<std::is_class<_Sseq>::value>::type>
+      template<typename _Sseq, typename = typename
+       std::enable_if<!std::is_same<_Sseq, linear_congruential_engine>::value>
+              ::type>
         explicit
         linear_congruential_engine(_Sseq& __q)
-        { seed<_Sseq>(__q); }
+        { seed(__q); }
 
       /**
        * @brief Reseeds the %linear_congruential_engine random number generator
@@ -210,9 +231,8 @@ namespace std
        *
        * @param __q the seed sequence.
        */
-      template<typename _Sseq, typename
-              = typename std::enable_if<std::is_class<_Sseq>::value>::type>
-        void
+      template<typename _Sseq>
+        typename std::enable_if<std::is_class<_Sseq>::value>::type
         seed(_Sseq& __q);
 
       /**
@@ -220,26 +240,20 @@ namespace std
        *
        * The minimum depends on the @p __c parameter: if it is zero, the
        * minimum generated must be > 0, otherwise 0 is allowed.
-       *
-       * @todo This should be constexpr.
        */
-      result_type
-      min() const
+      static constexpr result_type
+      min()
       { return __c == 0u ? 1u : 0u; }
 
       /**
        * @brief Gets the largest possible value in the output range.
-       *
-       * @todo This should be constexpr.
        */
-      result_type
-      max() const
+      static constexpr result_type
+      max()
       { return __m - 1u; }
 
       /**
        * @brief Discard a sequence of random numbers.
-       *
-       * @todo Look for a faster way to do discard.
        */
       void
       discard(unsigned long long __z)
@@ -266,7 +280,8 @@ namespace std
        * @param __rhs Another linear congruential random number generator
        *              object.
        *
-       * @returns true if the two objects are equal, false otherwise.
+       * @returns true if the infinite sequences of generated values
+       *          would be equal, false otherwise.
        */
       friend bool
       operator==(const linear_congruential_engine& __lhs,
@@ -284,9 +299,9 @@ namespace std
       template<typename _UIntType1, _UIntType1 __a1, _UIntType1 __c1,
               _UIntType1 __m1, typename _CharT, typename _Traits>
        friend std::basic_ostream<_CharT, _Traits>&
-       operator<<(std::basic_ostream<_CharT, _Traits>&,
+       operator<<(std::basic_ostream<_CharT, _Traits>& __os,
                   const std::linear_congruential_engine<_UIntType1,
-                  __a1, __c1, __m1>&);
+                  __a1, __c1, __m1>& __lcr);
 
       /**
        * @brief Sets the state of the engine by reading its textual
@@ -304,14 +319,33 @@ namespace std
       template<typename _UIntType1, _UIntType1 __a1, _UIntType1 __c1,
               _UIntType1 __m1, typename _CharT, typename _Traits>
        friend std::basic_istream<_CharT, _Traits>&
-       operator>>(std::basic_istream<_CharT, _Traits>&,
+       operator>>(std::basic_istream<_CharT, _Traits>& __is,
                   std::linear_congruential_engine<_UIntType1, __a1,
-                  __c1, __m1>&);
+                  __c1, __m1>& __lcr);
 
     private:
       _UIntType _M_x;
     };
 
+  /**
+   * @brief Compares two linear congruential random number generator
+   * objects of the same type for inequality.
+   *
+   * @param __lhs A linear congruential random number generator object.
+   * @param __rhs Another linear congruential random number generator
+   *              object.
+   *
+   * @returns true if the infinite sequences of generated values
+   *          would be different, false otherwise.
+   */
+  template<typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
+    inline bool
+    operator!=(const std::linear_congruential_engine<_UIntType, __a,
+              __c, __m>& __lhs,
+              const std::linear_congruential_engine<_UIntType, __a,
+              __c, __m>& __rhs)
+    { return !(__lhs == __rhs); }
+
 
   /**
    * A generalized feedback shift register discrete random number generator.
@@ -326,17 +360,20 @@ namespace std
    * This algorithm was originally invented by Makoto Matsumoto and
    * Takuji Nishimura.
    *
-   * @var word_size   The number of bits in each element of the state vector.
-   * @var state_size  The degree of recursion.
-   * @var shift_size  The period parameter.
-   * @var mask_bits   The separation point bit index.
-   * @var parameter_a The last row of the twist matrix.
-   * @var output_u    The first right-shift tempering matrix parameter.
-   * @var output_s    The first left-shift tempering matrix parameter.
-   * @var output_b    The first left-shift tempering matrix mask.
-   * @var output_t    The second left-shift tempering matrix parameter.
-   * @var output_c    The second left-shift tempering matrix mask.
-   * @var output_l    The second right-shift tempering matrix parameter.
+   * @tparam __w  Word size, the number of bits in each element of 
+   *              the state vector.
+   * @tparam __n  The degree of recursion.
+   * @tparam __m  The period parameter.
+   * @tparam __r  The separation point bit index.
+   * @tparam __a  The last row of the twist matrix.
+   * @tparam __u  The first right-shift tempering matrix parameter.
+   * @tparam __d  The first right-shift tempering matrix mask.
+   * @tparam __s  The first left-shift tempering matrix parameter.
+   * @tparam __b  The first left-shift tempering matrix mask.
+   * @tparam __t  The second left-shift tempering matrix parameter.
+   * @tparam __c  The second left-shift tempering matrix mask.
+   * @tparam __l  The second right-shift tempering matrix parameter.
+   * @tparam __f  Initialization multiplier.
    */
   template<typename _UIntType, size_t __w,
           size_t __n, size_t __m, size_t __r,
@@ -377,20 +414,20 @@ namespace std
       typedef _UIntType result_type;
 
       // parameter values
-      static const size_t      word_size                 = __w;
-      static const size_t      state_size                = __n;
-      static const size_t      shift_size                = __m;
-      static const size_t      mask_bits                 = __r;
-      static const result_type xor_mask                  = __a;
-      static const size_t      tempering_u               = __u;
-      static const result_type tempering_d               = __d;
-      static const size_t      tempering_s               = __s;
-      static const result_type tempering_b               = __b;
-      static const size_t      tempering_t               = __t;
-      static const result_type tempering_c               = __c;
-      static const size_t      tempering_l               = __l;
-      static const result_type initialization_multiplier = __f;
-      static const result_type default_seed = 5489u;
+      static constexpr size_t      word_size                 = __w;
+      static constexpr size_t      state_size                = __n;
+      static constexpr size_t      shift_size                = __m;
+      static constexpr size_t      mask_bits                 = __r;
+      static constexpr result_type xor_mask                  = __a;
+      static constexpr size_t      tempering_u               = __u;
+      static constexpr result_type tempering_d               = __d;
+      static constexpr size_t      tempering_s               = __s;
+      static constexpr result_type tempering_b               = __b;
+      static constexpr size_t      tempering_t               = __t;
+      static constexpr result_type tempering_c               = __c;
+      static constexpr size_t      tempering_l               = __l;
+      static constexpr result_type initialization_multiplier = __f;
+      static constexpr result_type default_seed = 5489u;
 
       // constructors and member function
       explicit
@@ -403,42 +440,36 @@ namespace std
        *
        * @param __q the seed sequence.
        */
-      template<typename _Sseq, typename
-              = typename std::enable_if<std::is_class<_Sseq>::value>::type>
+      template<typename _Sseq, typename = typename
+        std::enable_if<!std::is_same<_Sseq, mersenne_twister_engine>::value>
+              ::type>
         explicit
         mersenne_twister_engine(_Sseq& __q)
-        { seed<_Sseq>(__q); }
+        { seed(__q); }
 
       void
       seed(result_type __sd = default_seed);
 
-      template<typename _Sseq, typename
-              = typename std::enable_if<std::is_class<_Sseq>::value>::type>
-        void
+      template<typename _Sseq>
+       typename std::enable_if<std::is_class<_Sseq>::value>::type
         seed(_Sseq& __q);
 
       /**
        * @brief Gets the smallest possible value in the output range.
-       *
-       * @todo This should be constexpr.
        */
-      result_type
-      min() const
+      static constexpr result_type
+      min()
       { return 0; };
 
       /**
        * @brief Gets the largest possible value in the output range.
-       *
-       * @todo This should be constexpr.
        */
-      result_type
-      max() const
+      static constexpr result_type
+      max()
       { return __detail::_Shift<_UIntType, __w>::__value - 1; }
 
       /**
        * @brief Discard a sequence of random numbers.
-       *
-       * @todo Look for a faster way to do discard.
        */
       void
       discard(unsigned long long __z)
@@ -459,12 +490,14 @@ namespace std
        * @param __rhs Another % mersenne_twister_engine random number
        *              generator object.
        *
-       * @returns true if the two objects are equal, false otherwise.
+       * @returns true if the infinite sequences of generated values
+       *          would be equal, false otherwise.
        */
       friend bool
       operator==(const mersenne_twister_engine& __lhs,
                 const mersenne_twister_engine& __rhs)
-      { return std::equal(__lhs._M_x, __lhs._M_x + state_size, __rhs._M_x); }
+      { return (std::equal(__lhs._M_x, __lhs._M_x + state_size, __rhs._M_x)
+               && __lhs._M_p == __rhs._M_p); }
 
       /**
        * @brief Inserts the current state of a % mersenne_twister_engine
@@ -487,10 +520,10 @@ namespace std
               _UIntType1 __c1, size_t __l1, _UIntType1 __f1,
               typename _CharT, typename _Traits>
        friend std::basic_ostream<_CharT, _Traits>&
-       operator<<(std::basic_ostream<_CharT, _Traits>&,
+       operator<<(std::basic_ostream<_CharT, _Traits>& __os,
                   const std::mersenne_twister_engine<_UIntType1, __w1, __n1,
                   __m1, __r1, __a1, __u1, __d1, __s1, __b1, __t1, __c1,
-                  __l1, __f1>&);
+                  __l1, __f1>& __x);
 
       /**
        * @brief Extracts the current state of a % mersenne_twister_engine
@@ -513,10 +546,10 @@ namespace std
               _UIntType1 __c1, size_t __l1, _UIntType1 __f1,
               typename _CharT, typename _Traits>
        friend std::basic_istream<_CharT, _Traits>&
-       operator>>(std::basic_istream<_CharT, _Traits>&,
+       operator>>(std::basic_istream<_CharT, _Traits>& __is,
                   std::mersenne_twister_engine<_UIntType1, __w1, __n1, __m1,
                   __r1, __a1, __u1, __d1, __s1, __b1, __t1, __c1,
-                  __l1, __f1>&);
+                  __l1, __f1>& __x);
 
     private:
       _UIntType _M_x[state_size];
@@ -524,6 +557,31 @@ namespace std
     };
 
   /**
+   * @brief Compares two % mersenne_twister_engine random number generator
+   *        objects of the same type for inequality.
+   *
+   * @param __lhs A % mersenne_twister_engine random number generator
+   *              object.
+   * @param __rhs Another % mersenne_twister_engine random number
+   *              generator object.
+   *
+   * @returns true if the infinite sequences of generated values
+   *          would be different, false otherwise.
+   */
+  template<typename _UIntType, size_t __w,
+          size_t __n, size_t __m, size_t __r,
+          _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+          _UIntType __b, size_t __t,
+          _UIntType __c, size_t __l, _UIntType __f>
+    inline bool
+    operator!=(const std::mersenne_twister_engine<_UIntType, __w, __n, __m,
+              __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>& __lhs,
+              const std::mersenne_twister_engine<_UIntType, __w, __n, __m,
+              __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>& __rhs)
+    { return !(__lhs == __rhs); }
+
+
+  /**
    * @brief The Marsaglia-Zaman generator.
    *
    * This is a model of a Generalized Fibonacci discrete random number
@@ -557,10 +615,10 @@ namespace std
       typedef _UIntType result_type;
 
       // parameter values
-      static const size_t      word_size    = __w;
-      static const size_t      short_lag    = __s;
-      static const size_t      long_lag     = __r;
-      static const result_type default_seed = 19780503u;
+      static constexpr size_t      word_size    = __w;
+      static constexpr size_t      short_lag    = __s;
+      static constexpr size_t      long_lag     = __r;
+      static constexpr result_type default_seed = 19780503u;
 
       /**
        * @brief Constructs an explicitly seeded % subtract_with_carry_engine
@@ -576,11 +634,12 @@ namespace std
        *
        * @param __q the seed sequence.
        */
-      template<typename _Sseq, typename
-              = typename std::enable_if<std::is_class<_Sseq>::value>::type>
+      template<typename _Sseq, typename = typename
+        std::enable_if<!std::is_same<_Sseq, subtract_with_carry_engine>::value>
+              ::type>
         explicit
         subtract_with_carry_engine(_Sseq& __q)
-        { seed<_Sseq>(__q); }
+        { seed(__q); }
 
       /**
        * @brief Seeds the initial state @f$x_0@f$ of the random number
@@ -601,35 +660,28 @@ namespace std
        * @brief Seeds the initial state @f$x_0@f$ of the
        * % subtract_with_carry_engine random number generator.
        */
-      template<typename _Sseq, typename
-              = typename std::enable_if<std::is_class<_Sseq>::value>::type>
-        void
+      template<typename _Sseq>
+       typename std::enable_if<std::is_class<_Sseq>::value>::type
         seed(_Sseq& __q);
 
       /**
        * @brief Gets the inclusive minimum value of the range of random
        * integers returned by this generator.
-       *
-       * @todo This should be constexpr.
        */
-      result_type
-      min() const
+      static constexpr result_type
+      min()
       { return 0; }
 
       /**
        * @brief Gets the inclusive maximum value of the range of random
        * integers returned by this generator.
-       *
-       * @todo This should be constexpr.
        */
-      result_type
-      max() const
+      static constexpr result_type
+      max()
       { return __detail::_Shift<_UIntType, __w>::__value - 1; }
 
       /**
        * @brief Discard a sequence of random numbers.
-       *
-       * @todo Look for a faster way to do discard.
        */
       void
       discard(unsigned long long __z)
@@ -653,12 +705,15 @@ namespace std
        * @param __rhs Another % subtract_with_carry_engine random number
        *              generator object.
        *
-       * @returns true if the two objects are equal, false otherwise.
-       */
+       * @returns true if the infinite sequences of generated values
+       *          would be equal, false otherwise.
+      */
       friend bool
       operator==(const subtract_with_carry_engine& __lhs,
                 const subtract_with_carry_engine& __rhs)
-      { return std::equal(__lhs._M_x, __lhs._M_x + long_lag, __rhs._M_x); }
+      { return (std::equal(__lhs._M_x, __lhs._M_x + long_lag, __rhs._M_x)
+               && __lhs._M_carry == __rhs._M_carry
+               && __lhs._M_p == __rhs._M_p); }
 
       /**
        * @brief Inserts the current state of a % subtract_with_carry_engine
@@ -705,6 +760,27 @@ namespace std
     };
 
   /**
+   * @brief Compares two % subtract_with_carry_engine random number
+   *        generator objects of the same type for inequality.
+   *
+   * @param __lhs A % subtract_with_carry_engine random number generator
+   *              object.
+   * @param __rhs Another % subtract_with_carry_engine random number
+   *              generator object.
+   *
+   * @returns true if the infinite sequences of generated values
+   *          would be different, false otherwise.
+   */
+  template<typename _UIntType, size_t __w, size_t __s, size_t __r>
+    inline bool
+    operator!=(const std::subtract_with_carry_engine<_UIntType, __w,
+              __s, __r>& __lhs,
+              const std::subtract_with_carry_engine<_UIntType, __w,
+              __s, __r>& __rhs)
+    { return !(__lhs == __rhs); }
+
+
+  /**
    * Produces random numbers from some base engine by discarding blocks of
    * data.
    *
@@ -721,8 +797,8 @@ namespace std
       typedef typename _RandomNumberEngine::result_type result_type;
 
       // parameter values
-      static const size_t block_size = __p;
-      static const size_t used_block = __r;
+      static constexpr size_t block_size = __p;
+      static constexpr size_t used_block = __r;
 
       /**
        * @brief Constructs a default %discard_block_engine engine.
@@ -736,21 +812,21 @@ namespace std
        * @brief Copy constructs a %discard_block_engine engine.
        *
        * Copies an existing base class random number generator.
-       * @param rng An existing (base class) engine object.
+       * @param __rng An existing (base class) engine object.
        */
       explicit
-      discard_block_engine(const _RandomNumberEngine& __rne)
-      : _M_b(__rne), _M_n(0) { }
+      discard_block_engine(const _RandomNumberEngine& __rng)
+      : _M_b(__rng), _M_n(0) { }
 
       /**
        * @brief Move constructs a %discard_block_engine engine.
        *
        * Copies an existing base class random number generator.
-       * @param rng An existing (base class) engine object.
+       * @param __rng An existing (base class) engine object.
        */
       explicit
-      discard_block_engine(_RandomNumberEngine&& __rne)
-      : _M_b(std::move(__rne)), _M_n(0) { }
+      discard_block_engine(_RandomNumberEngine&& __rng)
+      : _M_b(std::move(__rng)), _M_n(0) { }
 
       /**
        * @brief Seed constructs a %discard_block_engine engine.
@@ -767,10 +843,10 @@ namespace std
        *
        * @param __q A seed sequence.
        */
-      template<typename _Sseq, typename
-        = typename std::enable_if<std::is_class<_Sseq>::value
-                                 && !std::is_same<_Sseq, _RandomNumberEngine>
-                                 ::value>::type>
+      template<typename _Sseq, typename = typename
+       std::enable_if<!std::is_same<_Sseq, discard_block_engine>::value
+                      && !std::is_same<_Sseq, _RandomNumberEngine>::value>
+              ::type>
         explicit
         discard_block_engine(_Sseq& __q)
        : _M_b(__q), _M_n(0)
@@ -803,12 +879,11 @@ namespace std
        *        sequence.
        * @param __q A seed generator function.
        */
-      template<typename _Sseq, typename
-              = typename std::enable_if<std::is_class<_Sseq>::value>::type>
+      template<typename _Sseq>
         void
         seed(_Sseq& __q)
         {
-         _M_b.seed<_Sseq>(__q);
+         _M_b.seed(__q);
          _M_n = 0;
        }
 
@@ -817,31 +892,25 @@ namespace std
        *        object.
        */
       const _RandomNumberEngine&
-      base() const
+      base() const noexcept
       { return _M_b; }
 
       /**
        * @brief Gets the minimum value in the generated random number range.
-       *
-       * @todo This should be constexpr.
        */
-      result_type
-      min() const
-      { return _M_b.min(); }
+      static constexpr result_type
+      min()
+      { return _RandomNumberEngine::min(); }
 
       /**
        * @brief Gets the maximum value in the generated random number range.
-       *
-       * @todo This should be constexpr.
        */
-      result_type
-      max() const
-      { return _M_b.max(); }
+      static constexpr result_type
+      max()
+      { return _RandomNumberEngine::max(); }
 
       /**
        * @brief Discard a sequence of random numbers.
-       *
-       * @todo Look for a faster way to do discard.
        */
       void
       discard(unsigned long long __z)
@@ -864,12 +933,13 @@ namespace std
        * @param __rhs Another %discard_block_engine random number generator
        *              object.
        *
-       * @returns true if the two objects are equal, false otherwise.
+       * @returns true if the infinite sequences of generated values
+       *          would be equal, false otherwise.
        */
       friend bool
       operator==(const discard_block_engine& __lhs,
                 const discard_block_engine& __rhs)
-      { return (__lhs._M_b == __rhs._M_b) && (__lhs._M_n == __rhs._M_n); }
+      { return __lhs._M_b == __rhs._M_b && __lhs._M_n == __rhs._M_n; }
 
       /**
        * @brief Inserts the current state of a %discard_block_engine random
@@ -885,9 +955,9 @@ namespace std
       template<typename _RandomNumberEngine1, size_t __p1, size_t __r1,
               typename _CharT, typename _Traits>
        friend std::basic_ostream<_CharT, _Traits>&
-       operator<<(std::basic_ostream<_CharT, _Traits>&,
+       operator<<(std::basic_ostream<_CharT, _Traits>& __os,
                   const std::discard_block_engine<_RandomNumberEngine1,
-                  __p1, __r1>&);
+                  __p1, __r1>& __x);
 
       /**
        * @brief Extracts the current state of a % subtract_with_carry_engine
@@ -903,9 +973,9 @@ namespace std
       template<typename _RandomNumberEngine1, size_t __p1, size_t __r1,
               typename _CharT, typename _Traits>
        friend std::basic_istream<_CharT, _Traits>&
-       operator>>(std::basic_istream<_CharT, _Traits>&,
+       operator>>(std::basic_istream<_CharT, _Traits>& __is,
                   std::discard_block_engine<_RandomNumberEngine1,
-                  __p1, __r1>&);
+                  __p1, __r1>& __x);
 
     private:
       _RandomNumberEngine _M_b;
@@ -913,6 +983,26 @@ namespace std
     };
 
   /**
+   * @brief Compares two %discard_block_engine random number generator
+   *        objects of the same type for inequality.
+   *
+   * @param __lhs A %discard_block_engine random number generator object.
+   * @param __rhs Another %discard_block_engine random number generator
+   *              object.
+   *
+   * @returns true if the infinite sequences of generated values
+   *          would be different, false otherwise.
+   */
+  template<typename _RandomNumberEngine, size_t __p, size_t __r>
+    inline bool
+    operator!=(const std::discard_block_engine<_RandomNumberEngine, __p,
+              __r>& __lhs,
+              const std::discard_block_engine<_RandomNumberEngine, __p,
+              __r>& __rhs)
+    { return !(__lhs == __rhs); }
+
+
+  /**
    * Produces random numbers by combining random numbers from some base
    * engine to produce random numbers with a specifies number of bits @p __w.
    */
@@ -940,21 +1030,21 @@ namespace std
        * @brief Copy constructs a %independent_bits_engine engine.
        *
        * Copies an existing base class random number generator.
-       * @param rng An existing (base class) engine object.
+       * @param __rng An existing (base class) engine object.
        */
       explicit
-      independent_bits_engine(const _RandomNumberEngine& __rne)
-      : _M_b(__rne) { }
+      independent_bits_engine(const _RandomNumberEngine& __rng)
+      : _M_b(__rng) { }
 
       /**
        * @brief Move constructs a %independent_bits_engine engine.
        *
        * Copies an existing base class random number generator.
-       * @param rng An existing (base class) engine object.
+       * @param __rng An existing (base class) engine object.
        */
       explicit
-      independent_bits_engine(_RandomNumberEngine&& __rne)
-      : _M_b(std::move(__rne)) { }
+      independent_bits_engine(_RandomNumberEngine&& __rng)
+      : _M_b(std::move(__rng)) { }
 
       /**
        * @brief Seed constructs a %independent_bits_engine engine.
@@ -971,10 +1061,10 @@ namespace std
        *
        * @param __q A seed sequence.
        */
-      template<typename _Sseq, typename
-        = typename std::enable_if<std::is_class<_Sseq>::value
-                                 && !std::is_same<_Sseq, _RandomNumberEngine>
-                                 ::value>::type>
+      template<typename _Sseq, typename = typename
+       std::enable_if<!std::is_same<_Sseq, independent_bits_engine>::value
+                      && !std::is_same<_Sseq, _RandomNumberEngine>::value>
+               ::type>
         explicit
         independent_bits_engine(_Sseq& __q)
         : _M_b(__q)
@@ -1001,42 +1091,35 @@ namespace std
        *        seed sequence.
        * @param __q A seed generator function.
        */
-      template<typename _Sseq, typename
-              = typename std::enable_if<std::is_class<_Sseq>::value>::type>
+      template<typename _Sseq>
         void
         seed(_Sseq& __q)
-        { _M_b.seed<_Sseq>(__q); }
+        { _M_b.seed(__q); }
 
       /**
        * @brief Gets a const reference to the underlying generator engine
        *        object.
        */
       const _RandomNumberEngine&
-      base() const
+      base() const noexcept
       { return _M_b; }
 
       /**
        * @brief Gets the minimum value in the generated random number range.
-       *
-       * @todo This should be constexpr.
        */
-      result_type
-      min() const
+      static constexpr result_type
+      min()
       { return 0U; }
 
       /**
        * @brief Gets the maximum value in the generated random number range.
-       *
-       * @todo This should be constexpr.
        */
-      result_type
-      max() const
+      static constexpr result_type
+      max()
       { return __detail::_Shift<_UIntType, __w>::__value - 1; }
 
       /**
        * @brief Discard a sequence of random numbers.
-       *
-       * @todo Look for a faster way to do discard.
        */
       void
       discard(unsigned long long __z)
@@ -1060,7 +1143,8 @@ namespace std
        * @param __rhs Another %independent_bits_engine random number generator
        *              object.
        *
-       * @returns true if the two objects are equal, false otherwise.
+       * @returns true if the infinite sequences of generated values
+       *          would be equal, false otherwise.
        */
       friend bool
       operator==(const independent_bits_engine& __lhs,
@@ -1094,6 +1178,26 @@ namespace std
     };
 
   /**
+   * @brief Compares two %independent_bits_engine random number generator
+   * objects of the same type for inequality.
+   *
+   * @param __lhs A %independent_bits_engine random number generator
+   *              object.
+   * @param __rhs Another %independent_bits_engine random number generator
+   *              object.
+   *
+   * @returns true if the infinite sequences of generated values
+   *          would be different, false otherwise.
+   */
+  template<typename _RandomNumberEngine, size_t __w, typename _UIntType>
+    inline bool
+    operator!=(const std::independent_bits_engine<_RandomNumberEngine, __w,
+              _UIntType>& __lhs,
+              const std::independent_bits_engine<_RandomNumberEngine, __w,
+              _UIntType>& __rhs)
+    { return !(__lhs == __rhs); }
+
+  /**
    * @brief Inserts the current state of a %independent_bits_engine random
    *        number generator engine @p __x into the output stream @p __os.
    *
@@ -1114,6 +1218,7 @@ namespace std
       return __os;
     }
 
+
   /**
    * @brief Produces random numbers by combining random numbers from some
    * base engine to produce random numbers with a specifies number of bits
@@ -1129,7 +1234,7 @@ namespace std
       /** The type of the generated random value. */
       typedef typename _RandomNumberEngine::result_type result_type;
 
-      static const size_t table_size = __k;
+      static constexpr size_t table_size = __k;
 
       /**
        * @brief Constructs a default %shuffle_order_engine engine.
@@ -1144,22 +1249,22 @@ namespace std
        * @brief Copy constructs a %shuffle_order_engine engine.
        *
        * Copies an existing base class random number generator.
-       * @param rng An existing (base class) engine object.
+       * @param __rng An existing (base class) engine object.
        */
       explicit
-      shuffle_order_engine(const _RandomNumberEngine& __rne)
-      : _M_b(__rne)
+      shuffle_order_engine(const _RandomNumberEngine& __rng)
+      : _M_b(__rng)
       { _M_initialize(); }
 
       /**
        * @brief Move constructs a %shuffle_order_engine engine.
        *
        * Copies an existing base class random number generator.
-       * @param rng An existing (base class) engine object.
+       * @param __rng An existing (base class) engine object.
        */
       explicit
-      shuffle_order_engine(_RandomNumberEngine&& __rne)
-      : _M_b(std::move(__rne))
+      shuffle_order_engine(_RandomNumberEngine&& __rng)
+      : _M_b(std::move(__rng))
       { _M_initialize(); }
 
       /**
@@ -1178,10 +1283,10 @@ namespace std
        *
        * @param __q A seed sequence.
        */
-      template<typename _Sseq, typename
-        = typename std::enable_if<std::is_class<_Sseq>::value
-                                 && !std::is_same<_Sseq, _RandomNumberEngine>
-                                 ::value>::type>
+      template<typename _Sseq, typename = typename
+       std::enable_if<!std::is_same<_Sseq, shuffle_order_engine>::value
+                      && !std::is_same<_Sseq, _RandomNumberEngine>::value>
+              ::type>
         explicit
         shuffle_order_engine(_Sseq& __q)
         : _M_b(__q)
@@ -1214,12 +1319,11 @@ namespace std
        *        sequence.
        * @param __q A seed generator function.
        */
-      template<typename _Sseq, typename
-              = typename std::enable_if<std::is_class<_Sseq>::value>::type>
+      template<typename _Sseq>
         void
         seed(_Sseq& __q)
         {
-         _M_b.seed<_Sseq>(__q);
+         _M_b.seed(__q);
          _M_initialize();
        }
 
@@ -1227,31 +1331,25 @@ namespace std
        * Gets a const reference to the underlying generator engine object.
        */
       const _RandomNumberEngine&
-      base() const
+      base() const noexcept
       { return _M_b; }
 
       /**
        * Gets the minimum value in the generated random number range.
-       *
-       * @todo This should be constexpr.
        */
-      result_type
-      min() const
-      { return _M_b.min(); }
+      static constexpr result_type
+      min()
+      { return _RandomNumberEngine::min(); }
 
       /**
        * Gets the maximum value in the generated random number range.
-       *
-       * @todo This should be constexpr.
        */
-      result_type
-      max() const
-      { return _M_b.max(); }
+      static constexpr result_type
+      max()
+      { return _RandomNumberEngine::max(); }
 
       /**
        * Discard a sequence of random numbers.
-       *
-       * @todo Look for a faster way to do discard.
        */
       void
       discard(unsigned long long __z)
@@ -1274,12 +1372,15 @@ namespace std
        * @param __rhs Another %shuffle_order_engine random number generator
        *              object.
        *
-       * @returns true if the two objects are equal, false otherwise.
-       */
+       * @returns true if the infinite sequences of generated values
+       *          would be equal, false otherwise.
+      */
       friend bool
       operator==(const shuffle_order_engine& __lhs,
                 const shuffle_order_engine& __rhs)
-      { return __lhs._M_b == __rhs._M_b; }
+      { return (__lhs._M_b == __rhs._M_b
+               && std::equal(__lhs._M_v, __lhs._M_v + __k, __rhs._M_v)
+               && __lhs._M_y == __rhs._M_y); }
 
       /**
        * @brief Inserts the current state of a %shuffle_order_engine random
@@ -1295,9 +1396,9 @@ namespace std
       template<typename _RandomNumberEngine1, size_t __k1,
               typename _CharT, typename _Traits>
        friend std::basic_ostream<_CharT, _Traits>&
-       operator<<(std::basic_ostream<_CharT, _Traits>&,
+       operator<<(std::basic_ostream<_CharT, _Traits>& __os,
                   const std::shuffle_order_engine<_RandomNumberEngine1,
-                  __k1>&);
+                  __k1>& __x);
 
       /**
        * @brief Extracts the current state of a % subtract_with_carry_engine
@@ -1313,8 +1414,8 @@ namespace std
       template<typename _RandomNumberEngine1, size_t __k1,
               typename _CharT, typename _Traits>
        friend std::basic_istream<_CharT, _Traits>&
-       operator>>(std::basic_istream<_CharT, _Traits>&,
-                  std::shuffle_order_engine<_RandomNumberEngine1, __k1>&);
+       operator>>(std::basic_istream<_CharT, _Traits>& __is,
+                  std::shuffle_order_engine<_RandomNumberEngine1, __k1>& __x);
 
     private:
       void _M_initialize()
@@ -1330,6 +1431,26 @@ namespace std
     };
 
   /**
+   * Compares two %shuffle_order_engine random number generator objects
+   * of the same type for inequality.
+   *
+   * @param __lhs A %shuffle_order_engine random number generator object.
+   * @param __rhs Another %shuffle_order_engine random number generator
+   *              object.
+   *
+   * @returns true if the infinite sequences of generated values
+   *          would be different, false otherwise.
+   */
+  template<typename _RandomNumberEngine, size_t __k>
+    inline bool
+    operator!=(const std::shuffle_order_engine<_RandomNumberEngine,
+              __k>& __lhs,
+              const std::shuffle_order_engine<_RandomNumberEngine,
+              __k>& __rhs)
+    { return !(__lhs == __rhs); }
+
+
+  /**
    * The classic Minimum Standard rand0 of Lewis, Goodman, and Miller.
    */
   typedef linear_congruential_engine<uint_fast32_t, 16807UL, 0UL, 2147483647UL>
@@ -1436,16 +1557,16 @@ namespace std
 
 #endif
 
-    result_type
-    min() const
+    static constexpr result_type
+    min()
     { return std::numeric_limits<result_type>::min(); }
 
-    result_type
-    max() const
+    static constexpr result_type
+    max()
     { return std::numeric_limits<result_type>::max(); }
 
     double
-    entropy() const
+    entropy() const noexcept
     { return 0.0; }
 
     result_type
@@ -1474,17 +1595,17 @@ namespace std
 #endif
   };
 
-  /* @} */ // group std_random_generators
+  /* @} */ // group random_generators
 
   /**
-   * @addtogroup std_random_distributions Random Number Distributions
-   * @ingroup std_random
+   * @addtogroup random_distributions Random Number Distributions
+   * @ingroup random
    * @{
    */
 
   /**
-   * @addtogroup std_random_distributions_uniform Uniform Distributions
-   * @ingroup std_random_distributions
+   * @addtogroup random_distributions_uniform Uniform Distributions
+   * @ingroup random_distributions
    * @{
    */
 
@@ -1523,6 +1644,10 @@ namespace std
        b() const
        { return _M_b; }
 
+       friend bool
+       operator==(const param_type& __p1, const param_type& __p2)
+       { return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; }
+
       private:
        _IntType _M_a;
        _IntType _M_b;
@@ -1560,20 +1685,6 @@ namespace std
       { return _M_param.b(); }
 
       /**
-       * @brief Returns the inclusive lower bound of the distribution range.
-       */
-      result_type
-      min() const
-      { return this->a(); }
-
-      /**
-       * @brief Returns the inclusive upper bound of the distribution range.
-       */
-      result_type
-      max() const
-      { return this->b(); }
-
-      /**
        * @brief Returns the parameter set of the distribution.
        */
       param_type
@@ -1589,28 +1700,56 @@ namespace std
       { _M_param = __param; }
 
       /**
-       * Gets a uniformly distributed random number in the range
-       * @f$(min, max)@f$.
+       * @brief Returns the inclusive lower bound of the distribution range.
+       */
+      result_type
+      min() const
+      { return this->a(); }
+
+      /**
+       * @brief Returns the inclusive upper bound of the distribution range.
+       */
+      result_type
+      max() const
+      { return this->b(); }
+
+      /**
+       * @brief Generating functions.
        */
       template<typename _UniformRandomNumberGenerator>
        result_type
        operator()(_UniformRandomNumberGenerator& __urng)
-        { return this->operator()(__urng, this->param()); }
+        { return this->operator()(__urng, _M_param); }
 
-      /**
-       * Gets a uniform random number in the range @f$[0, n)@f$.
-       *
-       * This function is aimed at use with std::random_shuffle.
-       */
       template<typename _UniformRandomNumberGenerator>
        result_type
        operator()(_UniformRandomNumberGenerator& __urng,
                   const param_type& __p);
 
+      /**
+       * @brief Return true if two uniform integer distributions have
+       *        the same parameters.
+       */
+      friend bool
+      operator==(const uniform_int_distribution& __d1,
+                const uniform_int_distribution& __d2)
+      { return __d1._M_param == __d2._M_param; }
+
+    private:
       param_type _M_param;
     };
 
   /**
+   * @brief Return true if two uniform integer distributions have
+   *        different parameters.
+   */
+  template<typename _IntType>
+    inline bool
+    operator!=(const std::uniform_int_distribution<_IntType>& __d1,
+              const std::uniform_int_distribution<_IntType>& __d2)
+    { return !(__d1 == __d2); }
+
+  /**
    * @brief Inserts a %uniform_int_distribution random number
    *        distribution @p __x into the output stream @p os.
    *
@@ -1677,6 +1816,10 @@ namespace std
        b() const
        { return _M_b; }
 
+       friend bool
+       operator==(const param_type& __p1, const param_type& __p2)
+       { return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; }
+
       private:
        _RealType _M_a;
        _RealType _M_b;
@@ -1686,8 +1829,8 @@ namespace std
       /**
        * @brief Constructs a uniform_real_distribution object.
        *
-       * @param __min [IN]  The lower bound of the distribution.
-       * @param __max [IN]  The upper bound of the distribution.
+       * @param __a [IN]  The lower bound of the distribution.
+       * @param __b [IN]  The upper bound of the distribution.
        */
       explicit
       uniform_real_distribution(_RealType __a = _RealType(0),
@@ -1717,6 +1860,21 @@ namespace std
       { return _M_param.b(); }
 
       /**
+       * @brief Returns the parameter set of the distribution.
+       */
+      param_type
+      param() const
+      { return _M_param; }
+
+      /**
+       * @brief Sets the parameter set of the distribution.
+       * @param __param The new parameter set of the distribution.
+       */
+      void
+      param(const param_type& __param)
+      { _M_param = __param; }
+
+      /**
        * @brief Returns the inclusive lower bound of the distribution range.
        */
       result_type
@@ -1731,24 +1889,12 @@ namespace std
       { return this->b(); }
 
       /**
-       * @brief Returns the parameter set of the distribution.
-       */
-      param_type
-      param() const
-      { return _M_param; }
-
-      /**
-       * @brief Sets the parameter set of the distribution.
-       * @param __param The new parameter set of the distribution.
+       * @brief Generating functions.
        */
-      void
-      param(const param_type& __param)
-      { _M_param = __param; }
-
       template<typename _UniformRandomNumberGenerator>
        result_type
        operator()(_UniformRandomNumberGenerator& __urng)
-        { return this->operator()(__urng, this->param()); }
+        { return this->operator()(__urng, _M_param); }
 
       template<typename _UniformRandomNumberGenerator>
        result_type
@@ -1760,11 +1906,30 @@ namespace std
          return (__aurng() * (__p.b() - __p.a())) + __p.a();
        }
 
+      /**
+       * @brief Return true if two uniform real distributions have
+       *        the same parameters.
+       */
+      friend bool
+      operator==(const uniform_real_distribution& __d1,
+                const uniform_real_distribution& __d2)
+      { return __d1._M_param == __d2._M_param; }
+
     private:
       param_type _M_param;
     };
 
   /**
+   * @brief Return true if two uniform real distributions have
+   *        different parameters.
+   */
+  template<typename _IntType>
+    inline bool
+    operator!=(const std::uniform_real_distribution<_IntType>& __d1,
+              const std::uniform_real_distribution<_IntType>& __d2)
+    { return !(__d1 == __d2); }
+
+  /**
    * @brief Inserts a %uniform_real_distribution random number
    *        distribution @p __x into the output stream @p __os.
    *
@@ -1793,11 +1958,11 @@ namespace std
     operator>>(std::basic_istream<_CharT, _Traits>&,
               std::uniform_real_distribution<_RealType>&);
 
-  /* @} */ // group std_random_distributions_uniform
+  /* @} */ // group random_distributions_uniform
 
   /**
-   * @addtogroup std_random_distributions_normal Normal Distributions
-   * @ingroup std_random_distributions
+   * @addtogroup random_distributions_normal Normal Distributions
+   * @ingroup random_distributions
    * @{
    */
 
@@ -1840,6 +2005,11 @@ namespace std
        stddev() const
        { return _M_stddev; }
 
+       friend bool
+       operator==(const param_type& __p1, const param_type& __p2)
+       { return (__p1._M_mean == __p2._M_mean
+                 && __p1._M_stddev == __p2._M_stddev); }
+
       private:
        _RealType _M_mean;
        _RealType _M_stddev;
@@ -1911,10 +2081,13 @@ namespace std
       max() const
       { return std::numeric_limits<result_type>::max(); }
 
+      /**
+       * @brief Generating functions.
+       */
       template<typename _UniformRandomNumberGenerator>
        result_type
        operator()(_UniformRandomNumberGenerator& __urng)
-       { return this->operator()(__urng, this->param()); }
+       { return this->operator()(__urng, _M_param); }
 
       template<typename _UniformRandomNumberGenerator>
        result_type
@@ -1922,6 +2095,16 @@ namespace std
                   const param_type& __p);
 
       /**
+       * @brief Return true if two normal distributions have
+       *        the same parameters and the sequences that would
+       *        be generated are equal.
+       */
+      template<typename _RealType1>
+       friend bool
+        operator==(const std::normal_distribution<_RealType1>& __d1,
+                  const std::normal_distribution<_RealType1>& __d2);
+
+      /**
        * @brief Inserts a %normal_distribution random number distribution
        * @p __x into the output stream @p __os.
        *
@@ -1933,8 +2116,8 @@ namespace std
        */
       template<typename _RealType1, typename _CharT, typename _Traits>
        friend std::basic_ostream<_CharT, _Traits>&
-       operator<<(std::basic_ostream<_CharT, _Traits>&,
-                  const std::normal_distribution<_RealType1>&);
+       operator<<(std::basic_ostream<_CharT, _Traits>& __os,
+                  const std::normal_distribution<_RealType1>& __x);
 
       /**
        * @brief Extracts a %normal_distribution random number distribution
@@ -1948,8 +2131,8 @@ namespace std
        */
       template<typename _RealType1, typename _CharT, typename _Traits>
        friend std::basic_istream<_CharT, _Traits>&
-       operator>>(std::basic_istream<_CharT, _Traits>&,
-                  std::normal_distribution<_RealType1>&);
+       operator>>(std::basic_istream<_CharT, _Traits>& __is,
+                  std::normal_distribution<_RealType1>& __x);
 
     private:
       param_type  _M_param;
@@ -1957,6 +2140,15 @@ namespace std
       bool        _M_saved_available;
     };
 
+  /**
+   * @brief Return true if two normal distributions are different.
+   */
+  template<typename _RealType>
+    inline bool
+    operator!=(const std::normal_distribution<_RealType>& __d1,
+              const std::normal_distribution<_RealType>& __d2)
+    { return !(__d1 == __d2); }
+
 
   /**
    * @brief A lognormal_distribution random number distribution.
@@ -1995,6 +2187,10 @@ namespace std
        s() const
        { return _M_s; }
 
+       friend bool
+       operator==(const param_type& __p1, const param_type& __p2)
+       { return __p1._M_m == __p2._M_m && __p1._M_s == __p2._M_s; }
+
       private:
        _RealType _M_m;
        _RealType _M_s;
@@ -2058,10 +2254,13 @@ namespace std
       max() const
       { return std::numeric_limits<result_type>::max(); }
 
+      /**
+       * @brief Generating functions.
+       */
       template<typename _UniformRandomNumberGenerator>
        result_type
        operator()(_UniformRandomNumberGenerator& __urng)
-       { return this->operator()(__urng, this->param()); }
+       { return this->operator()(__urng, _M_param); }
 
       template<typename _UniformRandomNumberGenerator>
        result_type
@@ -2070,6 +2269,17 @@ namespace std
         { return std::exp(__p.s() * _M_nd(__urng) + __p.m()); }
 
       /**
+       * @brief Return true if two lognormal distributions have
+       *        the same parameters and the sequences that would
+       *        be generated are equal.
+       */
+      friend bool
+      operator==(const lognormal_distribution& __d1,
+                const lognormal_distribution& __d2)
+      { return (__d1._M_param == __d2._M_param
+               && __d1._M_nd == __d2._M_nd); }
+
+      /**
        * @brief Inserts a %lognormal_distribution random number distribution
        * @p __x into the output stream @p __os.
        *
@@ -2081,8 +2291,8 @@ namespace std
        */
       template<typename _RealType1, typename _CharT, typename _Traits>
        friend std::basic_ostream<_CharT, _Traits>&
-       operator<<(std::basic_ostream<_CharT, _Traits>&,
-                  const std::lognormal_distribution<_RealType1>&);
+       operator<<(std::basic_ostream<_CharT, _Traits>& __os,
+                  const std::lognormal_distribution<_RealType1>& __x);
 
       /**
        * @brief Extracts a %lognormal_distribution random number distribution
@@ -2096,8 +2306,8 @@ namespace std
        */
       template<typename _RealType1, typename _CharT, typename _Traits>
        friend std::basic_istream<_CharT, _Traits>&
-       operator>>(std::basic_istream<_CharT, _Traits>&,
-                  std::lognormal_distribution<_RealType1>&);
+       operator>>(std::basic_istream<_CharT, _Traits>& __is,
+                  std::lognormal_distribution<_RealType1>& __x);
 
     private:
       param_type _M_param;
@@ -2105,7 +2315,16 @@ namespace std
       std::normal_distribution<result_type> _M_nd;
     };
 
-  
+  /**
+   * @brief Return true if two lognormal distributions are different.
+   */
+  template<typename _RealType>
+    inline bool
+    operator!=(const std::lognormal_distribution<_RealType>& __d1,
+              const std::lognormal_distribution<_RealType>& __d2)
+    { return !(__d1 == __d2); }
+
+
   /**
    * @brief A gamma continuous distribution for random numbers.
    *
@@ -2147,6 +2366,11 @@ namespace std
        beta() const
        { return _M_beta; }
 
+       friend bool
+       operator==(const param_type& __p1, const param_type& __p2)
+       { return (__p1._M_alpha == __p2._M_alpha
+                 && __p1._M_beta == __p2._M_beta); }
+
       private:
        void
        _M_initialize();
@@ -2223,10 +2447,13 @@ namespace std
       max() const
       { return std::numeric_limits<result_type>::max(); }
 
+      /**
+       * @brief Generating functions.
+       */
       template<typename _UniformRandomNumberGenerator>
        result_type
        operator()(_UniformRandomNumberGenerator& __urng)
-       { return this->operator()(__urng, this->param()); }
+       { return this->operator()(__urng, _M_param); }
 
       template<typename _UniformRandomNumberGenerator>
        result_type
@@ -2234,6 +2461,17 @@ namespace std
                   const param_type& __p);
 
       /**
+       * @brief Return true if two gamma distributions have the same
+       *        parameters and the sequences that would be generated
+       *        are equal.
+       */
+      friend bool
+      operator==(const gamma_distribution& __d1,
+                const gamma_distribution& __d2)
+      { return (__d1._M_param == __d2._M_param
+               && __d1._M_nd == __d2._M_nd); }
+
+      /**
        * @brief Inserts a %gamma_distribution random number distribution
        * @p __x into the output stream @p __os.
        *
@@ -2245,8 +2483,8 @@ namespace std
        */
       template<typename _RealType1, typename _CharT, typename _Traits>
        friend std::basic_ostream<_CharT, _Traits>&
-       operator<<(std::basic_ostream<_CharT, _Traits>&,
-                  const std::gamma_distribution<_RealType1>&);
+       operator<<(std::basic_ostream<_CharT, _Traits>& __os,
+                  const std::gamma_distribution<_RealType1>& __x);
 
       /**
        * @brief Extracts a %gamma_distribution random number distribution
@@ -2259,8 +2497,8 @@ namespace std
        */
       template<typename _RealType1, typename _CharT, typename _Traits>
        friend std::basic_istream<_CharT, _Traits>&
-       operator>>(std::basic_istream<_CharT, _Traits>&,
-                  std::gamma_distribution<_RealType1>&);
+       operator>>(std::basic_istream<_CharT, _Traits>& __is,
+                  std::gamma_distribution<_RealType1>& __x);
 
     private:
       param_type _M_param;
@@ -2268,6 +2506,15 @@ namespace std
       std::normal_distribution<result_type> _M_nd;
     };
 
+  /**
+   * @brief Return true if two gamma distributions are different.
+   */
+   template<typename _RealType>
+    inline bool
+     operator!=(const std::gamma_distribution<_RealType>& __d1,
+               const std::gamma_distribution<_RealType>& __d2)
+    { return !(__d1 == __d2); }
+
 
   /**
    * @brief A chi_squared_distribution random number distribution.
@@ -2298,6 +2545,10 @@ namespace std
        n() const
        { return _M_n; }
 
+       friend bool
+       operator==(const param_type& __p1, const param_type& __p2)
+       { return __p1._M_n == __p2._M_n; }
+
       private:
        _RealType _M_n;
       };
@@ -2355,6 +2606,9 @@ namespace std
       max() const
       { return std::numeric_limits<result_type>::max(); }
 
+      /**
+       * @brief Generating functions.
+       */
       template<typename _UniformRandomNumberGenerator>
        result_type
        operator()(_UniformRandomNumberGenerator& __urng)
@@ -2371,6 +2625,16 @@ namespace std
        }
 
       /**
+       * @brief Return true if two Chi-squared distributions have
+       *        the same parameters and the sequences that would be
+       *        generated are equal.
+       */
+      friend bool
+      operator==(const chi_squared_distribution& __d1,
+                const chi_squared_distribution& __d2)
+      { return __d1._M_param == __d2._M_param && __d1._M_gd == __d2._M_gd; }
+
+      /**
        * @brief Inserts a %chi_squared_distribution random number distribution
        * @p __x into the output stream @p __os.
        *
@@ -2382,8 +2646,8 @@ namespace std
        */
       template<typename _RealType1, typename _CharT, typename _Traits>
        friend std::basic_ostream<_CharT, _Traits>&
-       operator<<(std::basic_ostream<_CharT, _Traits>&,
-                  const std::chi_squared_distribution<_RealType1>&);
+       operator<<(std::basic_ostream<_CharT, _Traits>& __os,
+                  const std::chi_squared_distribution<_RealType1>& __x);
 
       /**
        * @brief Extracts a %chi_squared_distribution random number distribution
@@ -2397,8 +2661,8 @@ namespace std
        */
       template<typename _RealType1, typename _CharT, typename _Traits>
        friend std::basic_istream<_CharT, _Traits>&
-       operator>>(std::basic_istream<_CharT, _Traits>&,
-                  std::chi_squared_distribution<_RealType1>&);
+       operator>>(std::basic_istream<_CharT, _Traits>& __is,
+                  std::chi_squared_distribution<_RealType1>& __x);
 
     private:
       param_type _M_param;
@@ -2406,6 +2670,15 @@ namespace std
       std::gamma_distribution<result_type> _M_gd;
     };
 
+  /**
+   * @brief Return true if two Chi-squared distributions are different.
+   */
+  template<typename _RealType>
+    inline bool
+    operator!=(const std::chi_squared_distribution<_RealType>& __d1,
+              const std::chi_squared_distribution<_RealType>& __d2)
+    { return !(__d1 == __d2); }
+
 
   /**
    * @brief A cauchy_distribution random number distribution.
@@ -2441,6 +2714,10 @@ namespace std
        b() const
        { return _M_b; }
 
+       friend bool
+       operator==(const param_type& __p1, const param_type& __p2)
+       { return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; }
+
       private:
        _RealType _M_a;
        _RealType _M_b;
@@ -2504,21 +2781,43 @@ namespace std
       max() const
       { return std::numeric_limits<result_type>::max(); }
 
+      /**
+       * @brief Generating functions.
+       */
       template<typename _UniformRandomNumberGenerator>
        result_type
        operator()(_UniformRandomNumberGenerator& __urng)
-       { return this->operator()(__urng, this->param()); }
+       { return this->operator()(__urng, _M_param); }
 
       template<typename _UniformRandomNumberGenerator>
        result_type
        operator()(_UniformRandomNumberGenerator& __urng,
                   const param_type& __p);
 
+      /**
+       * @brief Return true if two Cauchy distributions have
+       *        the same parameters.
+       */
+      friend bool
+      operator==(const cauchy_distribution& __d1,
+                const cauchy_distribution& __d2)
+      { return __d1._M_param == __d2._M_param; }
+
     private:
       param_type _M_param;
     };
 
   /**
+   * @brief Return true if two Cauchy distributions have
+   *        different parameters.
+   */
+  template<typename _RealType>
+    inline bool
+    operator!=(const std::cauchy_distribution<_RealType>& __d1,
+              const std::cauchy_distribution<_RealType>& __d2)
+    { return !(__d1 == __d2); }
+
+  /**
    * @brief Inserts a %cauchy_distribution random number distribution
    * @p __x into the output stream @p __os.
    *
@@ -2530,8 +2829,8 @@ namespace std
    */
   template<typename _RealType, typename _CharT, typename _Traits>
     std::basic_ostream<_CharT, _Traits>&
-    operator<<(std::basic_ostream<_CharT, _Traits>&,
-              const std::cauchy_distribution<_RealType>&);
+    operator<<(std::basic_ostream<_CharT, _Traits>& __os,
+              const std::cauchy_distribution<_RealType>& __x);
 
   /**
    * @brief Extracts a %cauchy_distribution random number distribution
@@ -2545,8 +2844,8 @@ namespace std
    */
   template<typename _RealType, typename _CharT, typename _Traits>
     std::basic_istream<_CharT, _Traits>&
-    operator>>(std::basic_istream<_CharT, _Traits>&,
-              std::cauchy_distribution<_RealType>&);
+    operator>>(std::basic_istream<_CharT, _Traits>& __is,
+              std::cauchy_distribution<_RealType>& __x);
 
 
   /**
@@ -2587,6 +2886,10 @@ namespace std
        n() const
        { return _M_n; }
 
+       friend bool
+       operator==(const param_type& __p1, const param_type& __p2)
+       { return __p1._M_m == __p2._M_m && __p1._M_n == __p2._M_n; }
+
       private:
        _RealType _M_m;
        _RealType _M_n;
@@ -2653,6 +2956,9 @@ namespace std
       max() const
       { return std::numeric_limits<result_type>::max(); }
 
+      /**
+       * @brief Generating functions.
+       */
       template<typename _UniformRandomNumberGenerator>
        result_type
        operator()(_UniformRandomNumberGenerator& __urng)
@@ -2670,6 +2976,18 @@ namespace std
        }
 
       /**
+       * @brief Return true if two Fisher f distributions have
+       *        the same parameters and the sequences that would
+       *        be generated are equal.
+       */
+      friend bool
+      operator==(const fisher_f_distribution& __d1,
+                const fisher_f_distribution& __d2)
+      { return (__d1._M_param == __d2._M_param
+               && __d1._M_gd_x == __d2._M_gd_x
+               && __d1._M_gd_y == __d2._M_gd_y); }
+
+      /**
        * @brief Inserts a %fisher_f_distribution random number distribution
        * @p __x into the output stream @p __os.
        *
@@ -2681,8 +2999,8 @@ namespace std
        */
       template<typename _RealType1, typename _CharT, typename _Traits>
        friend std::basic_ostream<_CharT, _Traits>&
-       operator<<(std::basic_ostream<_CharT, _Traits>&,
-                  const std::fisher_f_distribution<_RealType1>&);
+       operator<<(std::basic_ostream<_CharT, _Traits>& __os,
+                  const std::fisher_f_distribution<_RealType1>& __x);
 
       /**
        * @brief Extracts a %fisher_f_distribution random number distribution
@@ -2696,8 +3014,8 @@ namespace std
        */
       template<typename _RealType1, typename _CharT, typename _Traits>
        friend std::basic_istream<_CharT, _Traits>&
-       operator>>(std::basic_istream<_CharT, _Traits>&,
-                  std::fisher_f_distribution<_RealType1>&);
+       operator>>(std::basic_istream<_CharT, _Traits>& __is,
+                  std::fisher_f_distribution<_RealType1>& __x);
 
     private:
       param_type _M_param;
@@ -2705,6 +3023,14 @@ namespace std
       std::gamma_distribution<result_type> _M_gd_x, _M_gd_y;
     };
 
+  /**
+   * @brief Return true if two Fisher f distributions are diferent.
+   */
+  template<typename _RealType>
+    inline bool
+    operator!=(const std::fisher_f_distribution<_RealType>& __d1,
+              const std::fisher_f_distribution<_RealType>& __d2)
+    { return !(__d1 == __d2); }
 
   /**
    * @brief A student_t_distribution random number distribution.
@@ -2738,6 +3064,10 @@ namespace std
        n() const
        { return _M_n; }
 
+       friend bool
+       operator==(const param_type& __p1, const param_type& __p2)
+       { return __p1._M_n == __p2._M_n; }
+
       private:
        _RealType _M_n;
       };
@@ -2798,6 +3128,9 @@ namespace std
       max() const
       { return std::numeric_limits<result_type>::max(); }
 
+      /**
+       * @brief Generating functions.
+       */
       template<typename _UniformRandomNumberGenerator>
        result_type
         operator()(_UniformRandomNumberGenerator& __urng)
@@ -2816,6 +3149,17 @@ namespace std
         }
 
       /**
+       * @brief Return true if two Student t distributions have
+       *        the same parameters and the sequences that would
+       *        be generated are equal.
+       */
+      friend bool
+      operator==(const student_t_distribution& __d1,
+                const student_t_distribution& __d2)
+      { return (__d1._M_param == __d2._M_param
+               && __d1._M_nd == __d2._M_nd && __d1._M_gd == __d2._M_gd); }
+
+      /**
        * @brief Inserts a %student_t_distribution random number distribution
        * @p __x into the output stream @p __os.
        *
@@ -2827,8 +3171,8 @@ namespace std
        */
       template<typename _RealType1, typename _CharT, typename _Traits>
        friend std::basic_ostream<_CharT, _Traits>&
-       operator<<(std::basic_ostream<_CharT, _Traits>&,
-                  const std::student_t_distribution<_RealType1>&);
+       operator<<(std::basic_ostream<_CharT, _Traits>& __os,
+                  const std::student_t_distribution<_RealType1>& __x);
 
       /**
        * @brief Extracts a %student_t_distribution random number distribution
@@ -2842,8 +3186,8 @@ namespace std
        */
       template<typename _RealType1, typename _CharT, typename _Traits>
        friend std::basic_istream<_CharT, _Traits>&
-       operator>>(std::basic_istream<_CharT, _Traits>&,
-                  std::student_t_distribution<_RealType1>&);
+       operator>>(std::basic_istream<_CharT, _Traits>& __is,
+                  std::student_t_distribution<_RealType1>& __x);
 
     private:
       param_type _M_param;
@@ -2852,11 +3196,21 @@ namespace std
       std::gamma_distribution<result_type> _M_gd;
     };
 
-  /* @} */ // group std_random_distributions_normal
+  /**
+   * @brief Return true if two Student t distributions are different.
+   */
+  template<typename _RealType>
+    inline bool
+    operator!=(const std::student_t_distribution<_RealType>& __d1,
+              const std::student_t_distribution<_RealType>& __d2)
+    { return !(__d1 == __d2); }
+
+
+  /* @} */ // group random_distributions_normal
 
   /**
-   * @addtogroup std_random_distributions_bernoulli Bernoulli Distributions
-   * @ingroup std_random_distributions
+   * @addtogroup random_distributions_bernoulli Bernoulli Distributions
+   * @ingroup random_distributions
    * @{
    */
 
@@ -2887,6 +3241,10 @@ namespace std
       p() const
       { return _M_p; }
 
+      friend bool
+      operator==(const param_type& __p1, const param_type& __p2)
+      { return __p1._M_p == __p2._M_p; }
+
     private:
       double _M_p;
     };
@@ -2953,12 +3311,12 @@ namespace std
     { return std::numeric_limits<result_type>::max(); }
 
     /**
-     * @brief Returns the next value in the Bernoullian sequence.
+     * @brief Generating functions.
      */
     template<typename _UniformRandomNumberGenerator>
       result_type
       operator()(_UniformRandomNumberGenerator& __urng)
-      { return this->operator()(__urng, this->param()); }
+      { return this->operator()(__urng, _M_param); }
 
     template<typename _UniformRandomNumberGenerator>
       result_type
@@ -2973,11 +3331,29 @@ namespace std
        return false;
       }
 
+    /**
+     * @brief Return true if two Bernoulli distributions have
+     *        the same parameters.
+     */
+    friend bool
+    operator==(const bernoulli_distribution& __d1,
+              const bernoulli_distribution& __d2)
+    { return __d1._M_param == __d2._M_param; }
+
   private:
     param_type _M_param;
   };
 
   /**
+   * @brief Return true if two Bernoulli distributions have
+   *        different parameters.
+   */
+  inline bool
+  operator!=(const std::bernoulli_distribution& __d1,
+            const std::bernoulli_distribution& __d2)
+  { return !(__d1 == __d2); }
+
+  /**
    * @brief Inserts a %bernoulli_distribution random number distribution
    * @p __x into the output stream @p __os.
    *
@@ -2989,8 +3365,8 @@ namespace std
    */
   template<typename _CharT, typename _Traits>
     std::basic_ostream<_CharT, _Traits>&
-    operator<<(std::basic_ostream<_CharT, _Traits>&,
-              const std::bernoulli_distribution&);
+    operator<<(std::basic_ostream<_CharT, _Traits>& __os,
+              const std::bernoulli_distribution& __x);
 
   /**
    * @brief Extracts a %bernoulli_distribution random number distribution
@@ -3053,6 +3429,10 @@ namespace std
        p() const
        { return _M_p; }
 
+       friend bool
+       operator==(const param_type& __p1, const param_type& __p2)
+       { return __p1._M_t == __p2._M_t && __p1._M_p == __p2._M_p; }
+
       private:
        void
        _M_initialize();
@@ -3130,10 +3510,13 @@ namespace std
       max() const
       { return _M_param.t(); }
 
+      /**
+       * @brief Generating functions.
+       */
       template<typename _UniformRandomNumberGenerator>
        result_type
        operator()(_UniformRandomNumberGenerator& __urng)
-       { return this->operator()(__urng, this->param()); }
+       { return this->operator()(__urng, _M_param); }
 
       template<typename _UniformRandomNumberGenerator>
        result_type
@@ -3141,6 +3524,20 @@ namespace std
                   const param_type& __p);
 
       /**
+       * @brief Return true if two binomial distributions have
+       *        the same parameters and the sequences that would
+       *        be generated are equal.
+       */
+       friend bool
+        operator==(const binomial_distribution& __d1,
+                  const binomial_distribution& __d2)
+#ifdef _GLIBCXX_USE_C99_MATH_TR1
+       { return __d1._M_param == __d2._M_param && __d1._M_nd == __d2._M_nd; }
+#else
+        { return __d1._M_param == __d2._M_param; }
+#endif
+
+      /**
        * @brief Inserts a %binomial_distribution random number distribution
        * @p __x into the output stream @p __os.
        *
@@ -3153,8 +3550,8 @@ namespace std
       template<typename _IntType1,
               typename _CharT, typename _Traits>
        friend std::basic_ostream<_CharT, _Traits>&
-       operator<<(std::basic_ostream<_CharT, _Traits>&,
-                  const std::binomial_distribution<_IntType1>&);
+       operator<<(std::basic_ostream<_CharT, _Traits>& __os,
+                  const std::binomial_distribution<_IntType1>& __x);
 
       /**
        * @brief Extracts a %binomial_distribution random number distribution
@@ -3169,8 +3566,8 @@ namespace std
       template<typename _IntType1,
               typename _CharT, typename _Traits>
        friend std::basic_istream<_CharT, _Traits>&
-       operator>>(std::basic_istream<_CharT, _Traits>&,
-                  std::binomial_distribution<_IntType1>&);
+       operator>>(std::basic_istream<_CharT, _Traits>& __is,
+                  std::binomial_distribution<_IntType1>& __x);
 
     private:
       template<typename _UniformRandomNumberGenerator>
@@ -3183,12 +3580,21 @@ namespace std
       std::normal_distribution<double> _M_nd;
     };
 
+  /**
+   * @brief Return true if two binomial distributions are different.
+   */
+  template<typename _IntType>
+    inline bool
+    operator!=(const std::binomial_distribution<_IntType>& __d1,
+              const std::binomial_distribution<_IntType>& __d2)
+    { return !(__d1 == __d2); }
+
 
   /**
    * @brief A discrete geometric random number distribution.
    *
    * The formula for the geometric probability density function is
-   * @f$p(i|p) = (1 - p)p^{i-1}@f$ where @f$p@f$ is the parameter of the
+   * @f$p(i|p) = p(1 - p)^{i}@f$ where @f$p@f$ is the parameter of the
    * distribution.
    */
   template<typename _IntType = int>
@@ -3210,8 +3616,7 @@ namespace std
        param_type(double __p = 0.5)
        : _M_p(__p)
        {
-         _GLIBCXX_DEBUG_ASSERT((_M_p >= 0.0)
-                            && (_M_p <= 1.0));
+         _GLIBCXX_DEBUG_ASSERT((_M_p > 0.0) && (_M_p < 1.0));
          _M_initialize();
        }
 
@@ -3219,14 +3624,18 @@ namespace std
        p() const
        { return _M_p; }
 
+       friend bool
+       operator==(const param_type& __p1, const param_type& __p2)
+       { return __p1._M_p == __p2._M_p; }
+
       private:
        void
        _M_initialize()
-       { _M_log_p = std::log(_M_p); }
+       { _M_log_1_p = std::log(1.0 - _M_p); }
 
        double _M_p;
 
-       double _M_log_p;
+       double _M_log_1_p;
       };
 
       // constructors and member function
@@ -3284,21 +3693,43 @@ namespace std
       max() const
       { return std::numeric_limits<result_type>::max(); }
 
+      /**
+       * @brief Generating functions.
+       */
       template<typename _UniformRandomNumberGenerator>
        result_type
        operator()(_UniformRandomNumberGenerator& __urng)
-       { return this->operator()(__urng, this->param()); }
+       { return this->operator()(__urng, _M_param); }
 
       template<typename _UniformRandomNumberGenerator>
        result_type
        operator()(_UniformRandomNumberGenerator& __urng,
                   const param_type& __p);
 
+      /**
+       * @brief Return true if two geometric distributions have
+       *        the same parameters.
+       */
+      friend bool
+      operator==(const geometric_distribution& __d1,
+                const geometric_distribution& __d2)
+      { return __d1._M_param == __d2._M_param; }
+
     private:
       param_type _M_param;
     };
 
   /**
+   * @brief Return true if two geometric distributions have
+   *        different parameters.
+   */
+  template<typename _IntType>
+    inline bool
+    operator!=(const std::geometric_distribution<_IntType>& __d1,
+              const std::geometric_distribution<_IntType>& __d2)
+    { return !(__d1 == __d2); }
+
+  /**
    * @brief Inserts a %geometric_distribution random number distribution
    * @p __x into the output stream @p __os.
    *
@@ -3311,8 +3742,8 @@ namespace std
   template<typename _IntType,
           typename _CharT, typename _Traits>
     std::basic_ostream<_CharT, _Traits>&
-    operator<<(std::basic_ostream<_CharT, _Traits>&,
-              const std::geometric_distribution<_IntType>&);
+    operator<<(std::basic_ostream<_CharT, _Traits>& __os,
+              const std::geometric_distribution<_IntType>& __x);
 
   /**
    * @brief Extracts a %geometric_distribution random number distribution
@@ -3326,8 +3757,8 @@ namespace std
   template<typename _IntType,
           typename _CharT, typename _Traits>
     std::basic_istream<_CharT, _Traits>&
-    operator>>(std::basic_istream<_CharT, _Traits>&,
-              std::geometric_distribution<_IntType>&);
+    operator>>(std::basic_istream<_CharT, _Traits>& __is,
+              std::geometric_distribution<_IntType>& __x);
 
 
   /**
@@ -3354,7 +3785,9 @@ namespace std
        explicit
        param_type(_IntType __k = 1, double __p = 0.5)
        : _M_k(__k), _M_p(__p)
-       { }
+       {
+         _GLIBCXX_DEBUG_ASSERT((_M_k > 0) && (_M_p > 0.0) && (_M_p <= 1.0));
+       }
 
        _IntType
        k() const
@@ -3364,6 +3797,10 @@ namespace std
        p() const
        { return _M_p; }
 
+       friend bool
+       operator==(const param_type& __p1, const param_type& __p2)
+       { return __p1._M_k == __p2._M_k && __p1._M_p == __p2._M_p; }
+
       private:
        _IntType _M_k;
        double _M_p;
@@ -3371,12 +3808,12 @@ namespace std
 
       explicit
       negative_binomial_distribution(_IntType __k = 1, double __p = 0.5)
-      : _M_param(__k, __p), _M_gd(__k, __p / (1.0 - __p))
+      : _M_param(__k, __p), _M_gd(__k, (1.0 - __p) / __p)
       { }
 
       explicit
       negative_binomial_distribution(const param_type& __p)
-      : _M_param(__p), _M_gd(__p.k(), __p.p() / (1.0 - __p.p()))
+      : _M_param(__p), _M_gd(__p.k(), (1.0 - __p.p()) / __p.p())
       { }
 
       /**
@@ -3429,6 +3866,9 @@ namespace std
       max() const
       { return std::numeric_limits<result_type>::max(); }
 
+      /**
+       * @brief Generating functions.
+       */
       template<typename _UniformRandomNumberGenerator>
        result_type
         operator()(_UniformRandomNumberGenerator& __urng);
@@ -3439,6 +3879,16 @@ namespace std
                   const param_type& __p);
 
       /**
+       * @brief Return true if two negative binomial distributions have
+       *        the same parameters and the sequences that would be
+       *        generated are equal.
+       */
+      friend bool
+      operator==(const negative_binomial_distribution& __d1,
+                const negative_binomial_distribution& __d2)
+      { return __d1._M_param == __d2._M_param && __d1._M_gd == __d2._M_gd; }
+
+      /**
        * @brief Inserts a %negative_binomial_distribution random
        *        number distribution @p __x into the output stream @p __os.
        *
@@ -3451,8 +3901,8 @@ namespace std
        */
       template<typename _IntType1, typename _CharT, typename _Traits>
        friend std::basic_ostream<_CharT, _Traits>&
-       operator<<(std::basic_ostream<_CharT, _Traits>&,
-                  const std::negative_binomial_distribution<_IntType1>&);
+       operator<<(std::basic_ostream<_CharT, _Traits>& __os,
+                  const std::negative_binomial_distribution<_IntType1>& __x);
 
       /**
        * @brief Extracts a %negative_binomial_distribution random number
@@ -3466,8 +3916,8 @@ namespace std
        */
       template<typename _IntType1, typename _CharT, typename _Traits>
        friend std::basic_istream<_CharT, _Traits>&
-       operator>>(std::basic_istream<_CharT, _Traits>&,
-                  std::negative_binomial_distribution<_IntType1>&);
+       operator>>(std::basic_istream<_CharT, _Traits>& __is,
+                  std::negative_binomial_distribution<_IntType1>& __x);
 
     private:
       param_type _M_param;
@@ -3475,11 +3925,21 @@ namespace std
       std::gamma_distribution<double> _M_gd;
     };
 
-  /* @} */ // group std_random_distributions_bernoulli
+  /**
+   * @brief Return true if two negative binomial distributions are different.
+   */
+  template<typename _IntType>
+    inline bool
+    operator!=(const std::negative_binomial_distribution<_IntType>& __d1,
+              const std::negative_binomial_distribution<_IntType>& __d2)
+    { return !(__d1 == __d2); }
+
+
+  /* @} */ // group random_distributions_bernoulli
 
   /**
-   * @addtogroup std_random_distributions_poisson Poisson Distributions
-   * @ingroup std_random_distributions
+   * @addtogroup random_distributions_poisson Poisson Distributions
+   * @ingroup random_distributions
    * @{
    */
 
@@ -3517,6 +3977,10 @@ namespace std
        mean() const
        { return _M_mean; }
 
+       friend bool
+       operator==(const param_type& __p1, const param_type& __p2)
+       { return __p1._M_mean == __p2._M_mean; }
+
       private:
        // Hosts either log(mean) or the threshold of the simple method.
        void
@@ -3584,16 +4048,33 @@ namespace std
       max() const
       { return std::numeric_limits<result_type>::max(); }
 
+      /**
+       * @brief Generating functions.
+       */
       template<typename _UniformRandomNumberGenerator>
        result_type
        operator()(_UniformRandomNumberGenerator& __urng)
-       { return this->operator()(__urng, this->param()); }
+       { return this->operator()(__urng, _M_param); }
 
       template<typename _UniformRandomNumberGenerator>
        result_type
        operator()(_UniformRandomNumberGenerator& __urng,
                   const param_type& __p);
 
+       /**
+       * @brief Return true if two Poisson distributions have the same
+       *        parameters and the sequences that would be generated
+       *        are equal.
+       */
+      friend bool
+      operator==(const poisson_distribution& __d1,
+                const poisson_distribution& __d2)
+#ifdef _GLIBCXX_USE_C99_MATH_TR1
+      { return __d1._M_param == __d2._M_param && __d1._M_nd == __d2._M_nd; }
+#else
+      { return __d1._M_param == __d2._M_param; }
+#endif
+
       /**
        * @brief Inserts a %poisson_distribution random number distribution
        * @p __x into the output stream @p __os.
@@ -3606,8 +4087,8 @@ namespace std
        */
       template<typename _IntType1, typename _CharT, typename _Traits>
        friend std::basic_ostream<_CharT, _Traits>&
-       operator<<(std::basic_ostream<_CharT, _Traits>&,
-                  const std::poisson_distribution<_IntType1>&);
+       operator<<(std::basic_ostream<_CharT, _Traits>& __os,
+                  const std::poisson_distribution<_IntType1>& __x);
 
       /**
        * @brief Extracts a %poisson_distribution random number distribution
@@ -3621,8 +4102,8 @@ namespace std
        */
       template<typename _IntType1, typename _CharT, typename _Traits>
        friend std::basic_istream<_CharT, _Traits>&
-       operator>>(std::basic_istream<_CharT, _Traits>&,
-                  std::poisson_distribution<_IntType1>&);
+       operator>>(std::basic_istream<_CharT, _Traits>& __is,
+                  std::poisson_distribution<_IntType1>& __x);
 
     private:
       param_type _M_param;
@@ -3632,6 +4113,16 @@ namespace std
     };
 
   /**
+   * @brief Return true if two Poisson distributions are different.
+   */
+  template<typename _IntType>
+    inline bool
+    operator!=(const std::poisson_distribution<_IntType>& __d1,
+              const std::poisson_distribution<_IntType>& __d2)
+    { return !(__d1 == __d2); }
+
+
+  /**
    * @brief An exponential continuous distribution for random numbers.
    *
    * The formula for the exponential probability density function is
@@ -3671,6 +4162,10 @@ namespace std
        lambda() const
        { return _M_lambda; }
 
+       friend bool
+       operator==(const param_type& __p1, const param_type& __p2)
+       { return __p1._M_lambda == __p2._M_lambda; }
+
       private:
        _RealType _M_lambda;
       };
@@ -3734,10 +4229,13 @@ namespace std
       max() const
       { return std::numeric_limits<result_type>::max(); }
 
+      /**
+       * @brief Generating functions.
+       */
       template<typename _UniformRandomNumberGenerator>
        result_type
        operator()(_UniformRandomNumberGenerator& __urng)
-        { return this->operator()(__urng, this->param()); }
+        { return this->operator()(__urng, _M_param); }
 
       template<typename _UniformRandomNumberGenerator>
        result_type
@@ -3746,14 +4244,33 @@ namespace std
        {
          __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
            __aurng(__urng);
-         return -std::log(__aurng()) / __p.lambda();
+         return -std::log(result_type(1) - __aurng()) / __p.lambda();
        }
 
+      /**
+       * @brief Return true if two exponential distributions have the same
+       *        parameters.
+       */
+      friend bool
+      operator==(const exponential_distribution& __d1,
+                const exponential_distribution& __d2)
+      { return __d1._M_param == __d2._M_param; }
+
     private:
       param_type _M_param;
     };
 
   /**
+   * @brief Return true if two exponential distributions have different
+   *        parameters.
+   */
+  template<typename _RealType>
+    inline bool
+    operator!=(const std::exponential_distribution<_RealType>& __d1,
+              const std::exponential_distribution<_RealType>& __d2)
+    { return !(__d1 == __d2); }
+
+  /**
    * @brief Inserts a %exponential_distribution random number distribution
    * @p __x into the output stream @p __os.
    *
@@ -3765,8 +4282,8 @@ namespace std
    */
   template<typename _RealType, typename _CharT, typename _Traits>
     std::basic_ostream<_CharT, _Traits>&
-    operator<<(std::basic_ostream<_CharT, _Traits>&,
-              const std::exponential_distribution<_RealType>&);
+    operator<<(std::basic_ostream<_CharT, _Traits>& __os,
+              const std::exponential_distribution<_RealType>& __x);
 
   /**
    * @brief Extracts a %exponential_distribution random number distribution
@@ -3780,8 +4297,8 @@ namespace std
    */
   template<typename _RealType, typename _CharT, typename _Traits>
     std::basic_istream<_CharT, _Traits>&
-    operator>>(std::basic_istream<_CharT, _Traits>&,
-              std::exponential_distribution<_RealType>&);
+    operator>>(std::basic_istream<_CharT, _Traits>& __is,
+              std::exponential_distribution<_RealType>& __x);
 
 
   /**
@@ -3821,6 +4338,10 @@ namespace std
        b() const
        { return _M_b; }
 
+       friend bool
+       operator==(const param_type& __p1, const param_type& __p2)
+       { return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; }
+
       private:
        _RealType _M_a;
        _RealType _M_b;
@@ -3887,20 +4408,42 @@ namespace std
       max() const
       { return std::numeric_limits<result_type>::max(); }
 
+      /**
+       * @brief Generating functions.
+       */
       template<typename _UniformRandomNumberGenerator>
        result_type
        operator()(_UniformRandomNumberGenerator& __urng)
-       { return this->operator()(__urng, this->param()); }
+       { return this->operator()(__urng, _M_param); }
 
       template<typename _UniformRandomNumberGenerator>
        result_type
        operator()(_UniformRandomNumberGenerator& __urng,
                   const param_type& __p);
 
+      /**
+       * @brief Return true if two Weibull distributions have the same
+       *        parameters.
+       */
+      friend bool
+      operator==(const weibull_distribution& __d1,
+                const weibull_distribution& __d2)
+      { return __d1._M_param == __d2._M_param; }
+
     private:
       param_type _M_param;
     };
 
+   /**
+    * @brief Return true if two Weibull distributions have different
+    *        parameters.
+    */
+  template<typename _RealType>
+    inline bool
+    operator!=(const std::weibull_distribution<_RealType>& __d1,
+              const std::weibull_distribution<_RealType>& __d2)
+    { return !(__d1 == __d2); }
+
   /**
    * @brief Inserts a %weibull_distribution random number distribution
    * @p __x into the output stream @p __os.
@@ -3913,8 +4456,8 @@ namespace std
    */
   template<typename _RealType, typename _CharT, typename _Traits>
     std::basic_ostream<_CharT, _Traits>&
-    operator<<(std::basic_ostream<_CharT, _Traits>&,
-              const std::weibull_distribution<_RealType>&);
+    operator<<(std::basic_ostream<_CharT, _Traits>& __os,
+              const std::weibull_distribution<_RealType>& __x);
 
   /**
    * @brief Extracts a %weibull_distribution random number distribution
@@ -3928,8 +4471,8 @@ namespace std
    */
   template<typename _RealType, typename _CharT, typename _Traits>
     std::basic_istream<_CharT, _Traits>&
-    operator>>(std::basic_istream<_CharT, _Traits>&,
-              std::weibull_distribution<_RealType>&);
+    operator>>(std::basic_istream<_CharT, _Traits>& __is,
+              std::weibull_distribution<_RealType>& __x);
 
 
   /**
@@ -3969,6 +4512,10 @@ namespace std
        b() const
        { return _M_b; }
 
+       friend bool
+       operator==(const param_type& __p1, const param_type& __p2)
+       { return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; }
+
       private:
        _RealType _M_a;
        _RealType _M_b;
@@ -4035,21 +4582,43 @@ namespace std
       max() const
       { return std::numeric_limits<result_type>::max(); }
 
+      /**
+       * @brief Generating functions.
+       */
       template<typename _UniformRandomNumberGenerator>
        result_type
        operator()(_UniformRandomNumberGenerator& __urng)
-       { return this->operator()(__urng, this->param()); }
+       { return this->operator()(__urng, _M_param); }
 
       template<typename _UniformRandomNumberGenerator>
        result_type
        operator()(_UniformRandomNumberGenerator& __urng,
                   const param_type& __p);
 
+      /**
+       * @brief Return true if two extreme value distributions have the same
+       *        parameters.
+       */
+      friend bool
+      operator==(const extreme_value_distribution& __d1,
+                const extreme_value_distribution& __d2)
+      { return __d1._M_param == __d2._M_param; }
+
     private:
       param_type _M_param;
     };
 
   /**
+    * @brief Return true if two extreme value distributions have different
+    *        parameters.
+   */
+  template<typename _RealType>
+    inline bool
+    operator!=(const std::extreme_value_distribution<_RealType>& __d1,
+              const std::extreme_value_distribution<_RealType>& __d2)
+    { return !(__d1 == __d2); }
+
+  /**
    * @brief Inserts a %extreme_value_distribution random number distribution
    * @p __x into the output stream @p __os.
    *
@@ -4061,8 +4630,8 @@ namespace std
    */
   template<typename _RealType, typename _CharT, typename _Traits>
     std::basic_ostream<_CharT, _Traits>&
-    operator<<(std::basic_ostream<_CharT, _Traits>&,
-              const std::extreme_value_distribution<_RealType>&);
+    operator<<(std::basic_ostream<_CharT, _Traits>& __os,
+              const std::extreme_value_distribution<_RealType>& __x);
 
   /**
    * @brief Extracts a %extreme_value_distribution random number
@@ -4076,8 +4645,8 @@ namespace std
    */
   template<typename _RealType, typename _CharT, typename _Traits>
     std::basic_istream<_CharT, _Traits>&
-    operator>>(std::basic_istream<_CharT, _Traits>&,
-              std::extreme_value_distribution<_RealType>&);
+    operator>>(std::basic_istream<_CharT, _Traits>& __is,
+              std::extreme_value_distribution<_RealType>& __x);
 
 
   /**
@@ -4103,7 +4672,7 @@ namespace std
 
        param_type()
        : _M_prob(), _M_cp()
-       { _M_initialize(); }
+       { }
 
        template<typename _InputIterator>
          param_type(_InputIterator __wbegin,
@@ -4119,9 +4688,17 @@ namespace std
          param_type(size_t __nw, double __xmin, double __xmax,
                     _Func __fw);
 
+       // See: http://cpp-next.com/archive/2010/10/implicit-move-must-go/
+       param_type(const param_type&) = default;
+       param_type& operator=(const param_type&) = default;
+
        std::vector<double>
        probabilities() const
-       { return _M_prob; }
+       { return _M_prob.empty() ? std::vector<double>(1, 1.0) : _M_prob; }
+
+       friend bool
+       operator==(const param_type& __p1, const param_type& __p2)
+       { return __p1._M_prob == __p2._M_prob; }
 
       private:
        void
@@ -4168,7 +4745,10 @@ namespace std
        */
       std::vector<double>
       probabilities() const
-      { return _M_param.probabilities(); }
+      {
+       return _M_param._M_prob.empty()
+         ? std::vector<double>(1, 1.0) : _M_param._M_prob;
+      }
 
       /**
        * @brief Returns the parameter set of the distribution.
@@ -4197,12 +4777,18 @@ namespace std
        */
       result_type
       max() const
-      { return this->_M_param._M_prob.size() - 1; }
+      {
+       return _M_param._M_prob.empty()
+         ? result_type(0) : result_type(_M_param._M_prob.size() - 1);
+      }
 
+      /**
+       * @brief Generating functions.
+       */
       template<typename _UniformRandomNumberGenerator>
        result_type
        operator()(_UniformRandomNumberGenerator& __urng)
-       { return this->operator()(__urng, this->param()); }
+       { return this->operator()(__urng, _M_param); }
 
       template<typename _UniformRandomNumberGenerator>
        result_type
@@ -4210,6 +4796,15 @@ namespace std
                   const param_type& __p);
 
       /**
+       * @brief Return true if two discrete distributions have the same
+       *        parameters.
+       */
+      friend bool
+      operator==(const discrete_distribution& __d1,
+                const discrete_distribution& __d2)
+      { return __d1._M_param == __d2._M_param; }
+
+      /**
        * @brief Inserts a %discrete_distribution random number distribution
        * @p __x into the output stream @p __os.
        *
@@ -4221,8 +4816,8 @@ namespace std
        */
       template<typename _IntType1, typename _CharT, typename _Traits>
        friend std::basic_ostream<_CharT, _Traits>&
-       operator<<(std::basic_ostream<_CharT, _Traits>&,
-                  const std::discrete_distribution<_IntType1>&);
+       operator<<(std::basic_ostream<_CharT, _Traits>& __os,
+                  const std::discrete_distribution<_IntType1>& __x);
 
       /**
        * @brief Extracts a %discrete_distribution random number distribution
@@ -4237,13 +4832,23 @@ namespace std
        */
       template<typename _IntType1, typename _CharT, typename _Traits>
        friend std::basic_istream<_CharT, _Traits>&
-       operator>>(std::basic_istream<_CharT, _Traits>&,
-                  std::discrete_distribution<_IntType1>&);
+       operator>>(std::basic_istream<_CharT, _Traits>& __is,
+                  std::discrete_distribution<_IntType1>& __x);
 
     private:
       param_type _M_param;
     };
 
+  /**
+    * @brief Return true if two discrete distributions have different
+    *        parameters.
+    */
+  template<typename _IntType>
+    inline bool
+    operator!=(const std::discrete_distribution<_IntType>& __d1,
+              const std::discrete_distribution<_IntType>& __d2)
+    { return !(__d1 == __d2); }
+
 
   /**
    * @brief A piecewise_constant_distribution random number distribution.
@@ -4268,7 +4873,7 @@ namespace std
 
        param_type()
        : _M_int(), _M_den(), _M_cp()
-       { _M_initialize(); }
+       { }
 
        template<typename _InputIteratorB, typename _InputIteratorW>
          param_type(_InputIteratorB __bfirst,
@@ -4282,13 +4887,30 @@ namespace std
          param_type(size_t __nw, _RealType __xmin, _RealType __xmax,
                     _Func __fw);
 
+       // See: http://cpp-next.com/archive/2010/10/implicit-move-must-go/
+       param_type(const param_type&) = default;
+       param_type& operator=(const param_type&) = default;
+
        std::vector<_RealType>
        intervals() const
-       { return _M_int; }
+       {
+         if (_M_int.empty())
+           {
+             std::vector<_RealType> __tmp(2);
+             __tmp[1] = _RealType(1);
+             return __tmp;
+           }
+         else
+           return _M_int;
+       }
 
        std::vector<double>
        densities() const
-       { return _M_den; }
+       { return _M_den.empty() ? std::vector<double>(1, 1.0) : _M_den; }
+
+       friend bool
+       operator==(const param_type& __p1, const param_type& __p2)
+       { return __p1._M_int == __p2._M_int && __p1._M_den == __p2._M_den; }
 
       private:
        void
@@ -4341,14 +4963,26 @@ namespace std
        */
       std::vector<_RealType>
       intervals() const
-      { return _M_param.intervals(); }
+      {
+       if (_M_param._M_int.empty())
+         {
+           std::vector<_RealType> __tmp(2);
+           __tmp[1] = _RealType(1);
+           return __tmp;
+         }
+       else
+         return _M_param._M_int;
+      }
 
       /**
        * @brief Returns a vector of the probability densities.
        */
       std::vector<double>
       densities() const
-      { return _M_param.densities(); }
+      {
+       return _M_param._M_den.empty()
+         ? std::vector<double>(1, 1.0) : _M_param._M_den;
+      }
 
       /**
        * @brief Returns the parameter set of the distribution.
@@ -4370,19 +5004,28 @@ namespace std
        */
       result_type
       min() const
-      { return this->_M_param._M_int.front(); }
+      {
+       return _M_param._M_int.empty()
+         ? result_type(0) : _M_param._M_int.front();
+      }
 
       /**
        * @brief Returns the least upper bound value of the distribution.
        */
       result_type
       max() const
-      { return this->_M_param._M_int.back(); }
+      {
+       return _M_param._M_int.empty()
+         ? result_type(1) : _M_param._M_int.back();
+      }
 
+      /**
+       * @brief Generating functions.
+       */
       template<typename _UniformRandomNumberGenerator>
        result_type
        operator()(_UniformRandomNumberGenerator& __urng)
-       { return this->operator()(__urng, this->param()); }
+       { return this->operator()(__urng, _M_param); }
 
       template<typename _UniformRandomNumberGenerator>
        result_type
@@ -4390,6 +5033,15 @@ namespace std
                   const param_type& __p);
 
       /**
+       * @brief Return true if two piecewise constant distributions have the
+       *        same parameters.
+       */
+      friend bool
+      operator==(const piecewise_constant_distribution& __d1,
+                const piecewise_constant_distribution& __d2)
+      { return __d1._M_param == __d2._M_param; }
+
+      /**
        * @brief Inserts a %piecewise_constan_distribution random
        *        number distribution @p __x into the output stream @p __os.
        *
@@ -4402,8 +5054,8 @@ namespace std
        */
       template<typename _RealType1, typename _CharT, typename _Traits>
        friend std::basic_ostream<_CharT, _Traits>&
-       operator<<(std::basic_ostream<_CharT, _Traits>&,
-                  const std::piecewise_constant_distribution<_RealType1>&);
+       operator<<(std::basic_ostream<_CharT, _Traits>& __os,
+                  const std::piecewise_constant_distribution<_RealType1>& __x);
 
       /**
        * @brief Extracts a %piecewise_constan_distribution random
@@ -4418,13 +5070,23 @@ namespace std
        */
       template<typename _RealType1, typename _CharT, typename _Traits>
        friend std::basic_istream<_CharT, _Traits>&
-       operator>>(std::basic_istream<_CharT, _Traits>&,
-                  std::piecewise_constant_distribution<_RealType1>&);
+       operator>>(std::basic_istream<_CharT, _Traits>& __is,
+                  std::piecewise_constant_distribution<_RealType1>& __x);
 
     private:
       param_type _M_param;
     };
 
+  /**
+    * @brief Return true if two piecewise constant distributions have 
+    *        different parameters.
+   */
+  template<typename _RealType>
+    inline bool
+    operator!=(const std::piecewise_constant_distribution<_RealType>& __d1,
+              const std::piecewise_constant_distribution<_RealType>& __d2)
+    { return !(__d1 == __d2); }
+
 
   /**
    * @brief A piecewise_linear_distribution random number distribution.
@@ -4449,7 +5111,7 @@ namespace std
 
        param_type()
        : _M_int(), _M_den(), _M_cp(), _M_m()
-       { _M_initialize(); }
+       { }
 
        template<typename _InputIteratorB, typename _InputIteratorW>
          param_type(_InputIteratorB __bfirst,
@@ -4463,13 +5125,31 @@ namespace std
          param_type(size_t __nw, _RealType __xmin, _RealType __xmax,
                     _Func __fw);
 
+       // See: http://cpp-next.com/archive/2010/10/implicit-move-must-go/
+       param_type(const param_type&) = default;
+       param_type& operator=(const param_type&) = default;
+
        std::vector<_RealType>
        intervals() const
-       { return _M_int; }
+       {
+         if (_M_int.empty())
+           {
+             std::vector<_RealType> __tmp(2);
+             __tmp[1] = _RealType(1);
+             return __tmp;
+           }
+         else
+           return _M_int;
+       }
 
        std::vector<double>
        densities() const
-       { return _M_den; }
+       { return _M_den.empty() ? std::vector<double>(2, 1.0) : _M_den; }
+
+       friend bool
+       operator==(const param_type& __p1, const param_type& __p2)
+       { return (__p1._M_int == __p2._M_int
+                 && __p1._M_den == __p2._M_den); }
 
       private:
        void
@@ -4523,7 +5203,16 @@ namespace std
        */
       std::vector<_RealType>
       intervals() const
-      { return _M_param.intervals(); }
+      {
+       if (_M_param._M_int.empty())
+         {
+           std::vector<_RealType> __tmp(2);
+           __tmp[1] = _RealType(1);
+           return __tmp;
+         }
+       else
+         return _M_param._M_int;
+      }
 
       /**
        * @brief Return a vector of the probability densities of the
@@ -4531,7 +5220,10 @@ namespace std
        */
       std::vector<double>
       densities() const
-      { return _M_param.densities(); }
+      {
+       return _M_param._M_den.empty()
+         ? std::vector<double>(2, 1.0) : _M_param._M_den;
+      }
 
       /**
        * @brief Returns the parameter set of the distribution.
@@ -4553,19 +5245,28 @@ namespace std
        */
       result_type
       min() const
-      { return this->_M_param._M_int.front(); }
+      {
+       return _M_param._M_int.empty()
+         ? result_type(0) : _M_param._M_int.front();
+      }
 
       /**
        * @brief Returns the least upper bound value of the distribution.
        */
       result_type
       max() const
-      { return this->_M_param._M_int.back(); }
+      {
+       return _M_param._M_int.empty()
+         ? result_type(1) : _M_param._M_int.back();
+      }
 
+      /**
+       * @brief Generating functions.
+       */
       template<typename _UniformRandomNumberGenerator>
        result_type
        operator()(_UniformRandomNumberGenerator& __urng)
-       { return this->operator()(__urng, this->param()); }
+       { return this->operator()(__urng, _M_param); }
 
       template<typename _UniformRandomNumberGenerator>
        result_type
@@ -4573,6 +5274,15 @@ namespace std
                   const param_type& __p);
 
       /**
+       * @brief Return true if two piecewise linear distributions have the
+       *        same parameters.
+       */
+      friend bool
+      operator==(const piecewise_linear_distribution& __d1,
+                const piecewise_linear_distribution& __d2)
+      { return __d1._M_param == __d2._M_param; }
+
+      /**
        * @brief Inserts a %piecewise_linear_distribution random number
        *        distribution @p __x into the output stream @p __os.
        *
@@ -4585,8 +5295,8 @@ namespace std
        */
       template<typename _RealType1, typename _CharT, typename _Traits>
        friend std::basic_ostream<_CharT, _Traits>&
-       operator<<(std::basic_ostream<_CharT, _Traits>&,
-                  const std::piecewise_linear_distribution<_RealType1>&);
+       operator<<(std::basic_ostream<_CharT, _Traits>& __os,
+                  const std::piecewise_linear_distribution<_RealType1>& __x);
 
       /**
        * @brief Extracts a %piecewise_linear_distribution random number
@@ -4601,21 +5311,31 @@ namespace std
        */
       template<typename _RealType1, typename _CharT, typename _Traits>
        friend std::basic_istream<_CharT, _Traits>&
-       operator>>(std::basic_istream<_CharT, _Traits>&,
-                  std::piecewise_linear_distribution<_RealType1>&);
+       operator>>(std::basic_istream<_CharT, _Traits>& __is,
+                  std::piecewise_linear_distribution<_RealType1>& __x);
 
     private:
       param_type _M_param;
     };
 
+  /**
+    * @brief Return true if two piecewise linear distributions have
+    *        different parameters.
+   */
+  template<typename _RealType>
+    inline bool
+    operator!=(const std::piecewise_linear_distribution<_RealType>& __d1,
+              const std::piecewise_linear_distribution<_RealType>& __d2)
+    { return !(__d1 == __d2); }
+
 
-  /* @} */ // group std_random_distributions_poisson
+  /* @} */ // group random_distributions_poisson
 
-  /* @} */ // group std_random_distributions
+  /* @} */ // group random_distributions
 
   /**
-   * @addtogroup std_random_utilities Random Number Utilities
-   * @ingroup std_random
+   * @addtogroup random_utilities Random Number Utilities
+   * @ingroup random
    * @{
    */
 
@@ -4660,9 +5380,11 @@ namespace std
     std::vector<result_type> _M_v;
   };
 
-  /* @} */ // group std_random_utilities
+  /* @} */ // group random_utilities
 
-  /* @} */ // group std_random
+  /* @} */ // group random
 
-}
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
 
+#endif