Implement resolutions of LWG 2399, 2400 and 2401.
[gcc.git] / libstdc++-v3 / include / bits / random.h
index f31f5535dee35a0c84f70868124ff0a3aa309778..774f726d0a6410db71f3c75936f3aebf22042c3c 100644 (file)
@@ -1,6 +1,6 @@
 // random number generation -*- C++ -*-
 
-// Copyright (C) 2009-2012 Free Software Foundation, Inc.
+// Copyright (C) 2009-2014 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
@@ -164,6 +164,8 @@ _GLIBCXX_END_NAMESPACE_VERSION
     template<typename _Engine, typename _DInputType>
       struct _Adaptor
       {
+       static_assert(std::is_floating_point<_DInputType>::value,
+                     "template argument not a floating point type");
 
       public:
        _Adaptor(_Engine& __g)
@@ -659,10 +661,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *
    * The size of the state is @f$r@f$
    * and the maximum period of the generator is @f$(m^r - m^s - 1)@f$.
-   *
-   * @var _M_x     The state of the generator.  This is a ring buffer.
-   * @var _M_carry The carry.
-   * @var _M_p     Current index of x(i - r).
    */
   template<typename _UIntType, size_t __w, size_t __s, size_t __r>
     class subtract_with_carry_engine
@@ -794,9 +792,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       template<typename _UIntType1, size_t __w1, size_t __s1, 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::subtract_with_carry_engine<_UIntType1, __w1,
-                  __s1, __r1>&);
+                  __s1, __r1>& __x);
 
       /**
        * @brief Extracts the current state of a % subtract_with_carry_engine
@@ -813,14 +811,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       template<typename _UIntType1, size_t __w1, size_t __s1, 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::subtract_with_carry_engine<_UIntType1, __w1,
-                  __s1, __r1>&);
+                  __s1, __r1>& __x);
 
     private:
+      /// The state of the generator.  This is a ring buffer.
       _UIntType  _M_x[long_lag];
-      _UIntType  _M_carry;
-      size_t     _M_p;
+      _UIntType  _M_carry;             ///< The carry
+      size_t     _M_p;                 ///< Current index of x(i - r).
     };
 
   /**
@@ -1638,9 +1637,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
     union
     {
-    FILE*        _M_file;
-    mt19937      _M_mt;
-  };
+      void*      _M_file;
+      mt19937    _M_mt;
+    };
   };
 
   /* @} */ // group random_generators
@@ -1767,7 +1766,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       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
@@ -1779,7 +1778,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        void
        __generate(_ForwardIterator __f, _ForwardIterator __t,
                   _UniformRandomNumberGenerator& __urng)
-       { this->__generate(__f, __t, __urng, this->param()); }
+       { this->__generate(__f, __t, __urng, _M_param); }
 
       template<typename _ForwardIterator,
               typename _UniformRandomNumberGenerator>
@@ -1796,6 +1795,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                   const param_type& __p)
        { this->__generate_impl(__f, __t, __urng, __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:
       template<typename _ForwardIterator,
               typename _UniformRandomNumberGenerator>
@@ -1807,16 +1815,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       param_type _M_param;
     };
 
-  /**
-   * @brief Return true if two uniform integer distributions have
-   *        the same parameters.
-   */
-  template<typename _IntType>
-    inline bool
-    operator==(const std::uniform_int_distribution<_IntType>& __d1,
-              const std::uniform_int_distribution<_IntType>& __d2)
-    { return __d1.param() == __d2.param(); }
-
   /**
    * @brief Return true if two uniform integer distributions have
    *        different parameters.
@@ -1972,7 +1970,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       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
@@ -1989,7 +1987,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        void
        __generate(_ForwardIterator __f, _ForwardIterator __t,
                   _UniformRandomNumberGenerator& __urng)
-       { this->__generate(__f, __t, __urng, this->param()); }
+       { this->__generate(__f, __t, __urng, _M_param); }
 
       template<typename _ForwardIterator,
               typename _UniformRandomNumberGenerator>
@@ -2006,6 +2004,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                   const param_type& __p)
        { this->__generate_impl(__f, __t, __urng, __p); }
 
+      /**
+       * @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:
       template<typename _ForwardIterator,
               typename _UniformRandomNumberGenerator>
@@ -2017,16 +2024,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       param_type _M_param;
     };
 
-  /**
-   * @brief Return true if two uniform real distributions have
-   *        the same parameters.
-   */
-  template<typename _IntType>
-    inline bool
-    operator==(const std::uniform_real_distribution<_IntType>& __d1,
-              const std::uniform_real_distribution<_IntType>& __d2)
-    { return __d1.param() == __d2.param(); }
-
   /**
    * @brief Return true if two uniform real distributions have
    *        different parameters.
@@ -2180,7 +2177,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        */
       result_type
       min() const
-      { return std::numeric_limits<result_type>::min(); }
+      { return std::numeric_limits<result_type>::lowest(); }
 
       /**
        * @brief Returns the least upper bound value of the distribution.
@@ -2195,7 +2192,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       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
@@ -2207,7 +2204,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        void
        __generate(_ForwardIterator __f, _ForwardIterator __t,
                   _UniformRandomNumberGenerator& __urng)
-       { this->__generate(__f, __t, __urng, this->param()); }
+       { this->__generate(__f, __t, __urng, _M_param); }
 
       template<typename _ForwardIterator,
               typename _UniformRandomNumberGenerator>
@@ -2397,7 +2394,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       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
@@ -2410,7 +2407,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        void
        __generate(_ForwardIterator __f, _ForwardIterator __t,
                   _UniformRandomNumberGenerator& __urng)
-       { this->__generate(__f, __t, __urng, this->param()); }
+       { this->__generate(__f, __t, __urng, _M_param); }
 
       template<typename _ForwardIterator,
               typename _UniformRandomNumberGenerator>
@@ -2435,7 +2432,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       friend bool
       operator==(const lognormal_distribution& __d1,
                 const lognormal_distribution& __d2)
-      { return (__d1.param() == __d2.param()
+      { return (__d1._M_param == __d2._M_param
                && __d1._M_nd == __d2._M_nd); }
 
       /**
@@ -2619,7 +2616,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       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
@@ -2631,7 +2628,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        void
        __generate(_ForwardIterator __f, _ForwardIterator __t,
                   _UniformRandomNumberGenerator& __urng)
-       { this->__generate(__f, __t, __urng, this->param()); }
+       { this->__generate(__f, __t, __urng, _M_param); }
 
       template<typename _ForwardIterator,
               typename _UniformRandomNumberGenerator>
@@ -2656,7 +2653,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       friend bool
       operator==(const gamma_distribution& __d1,
                 const gamma_distribution& __d2)
-      { return (__d1.param() == __d2.param()
+      { return (__d1._M_param == __d2._M_param
                && __d1._M_nd == __d2._M_nd); }
 
       /**
@@ -2824,7 +2821,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        void
        __generate(_ForwardIterator __f, _ForwardIterator __t,
                   _UniformRandomNumberGenerator& __urng)
-       { this->__generate_impl(__f, __t, __urng, _M_gd.param()); }
+        { this->__generate_impl(__f, __t, __urng); }
 
       template<typename _ForwardIterator,
               typename _UniformRandomNumberGenerator>
@@ -2840,9 +2837,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        void
        __generate(result_type* __f, result_type* __t,
                   _UniformRandomNumberGenerator& __urng)
-       { typename std::gamma_distribution<result_type>::param_type
-           __p2(_M_gd.param());
-         this->__generate_impl(__f, __t, __urng, __p2); }
+        { this->__generate_impl(__f, __t, __urng); }
 
       template<typename _UniformRandomNumberGenerator>
        void
@@ -2861,7 +2856,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       friend bool
       operator==(const chi_squared_distribution& __d1,
                 const chi_squared_distribution& __d2)
-      { return __d1.param() == __d2.param() && __d1._M_gd == __d2._M_gd; }
+      { return __d1._M_param == __d2._M_param && __d1._M_gd == __d2._M_gd; }
 
       /**
        * @brief Inserts a %chi_squared_distribution random number distribution
@@ -2894,13 +2889,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                   std::chi_squared_distribution<_RealType1>& __x);
 
     private:
+      template<typename _ForwardIterator,
+              typename _UniformRandomNumberGenerator>
+       void
+       __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
+                       _UniformRandomNumberGenerator& __urng);
+
       template<typename _ForwardIterator,
               typename _UniformRandomNumberGenerator>
        void
        __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
                        _UniformRandomNumberGenerator& __urng,
-                       typename std::gamma_distribution<result_type>::param_type&
-                       __p);
+                       const typename
+                       std::gamma_distribution<result_type>::param_type& __p);
 
       param_type _M_param;
 
@@ -3009,7 +3010,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        */
       result_type
       min() const
-      { return std::numeric_limits<result_type>::min(); }
+      { return std::numeric_limits<result_type>::lowest(); }
 
       /**
        * @brief Returns the least upper bound value of the distribution.
@@ -3024,7 +3025,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       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
@@ -3036,7 +3037,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        void
        __generate(_ForwardIterator __f, _ForwardIterator __t,
                   _UniformRandomNumberGenerator& __urng)
-       { this->__generate(__f, __t, __urng, this->param()); }
+       { this->__generate(__f, __t, __urng, _M_param); }
 
       template<typename _ForwardIterator,
               typename _UniformRandomNumberGenerator>
@@ -3053,6 +3054,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                   const param_type& __p)
        { this->__generate_impl(__f, __t, __urng, __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:
       template<typename _ForwardIterator,
               typename _UniformRandomNumberGenerator>
@@ -3064,16 +3074,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       param_type _M_param;
     };
 
-  /**
-   * @brief Return true if two Cauchy distributions have
-   *        the same parameters.
-   */
-  template<typename _RealType>
-    inline bool
-    operator==(const std::cauchy_distribution<_RealType>& __d1,
-              const std::cauchy_distribution<_RealType>& __d2)
-    { return __d1.param() == __d2.param(); }
-
   /**
    * @brief Return true if two Cauchy distributions have
    *        different parameters.
@@ -3278,7 +3278,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       friend bool
       operator==(const fisher_f_distribution& __d1,
                 const fisher_f_distribution& __d2)
-      { return (__d1.param() == __d2.param()
+      { return (__d1._M_param == __d2._M_param
                && __d1._M_gd_x == __d2._M_gd_x
                && __d1._M_gd_y == __d2._M_gd_y); }
 
@@ -3332,7 +3332,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     };
 
   /**
-   * @brief Return true if two Fisher f distributions are diferent.
+   * @brief Return true if two Fisher f distributions are different.
    */
   template<typename _RealType>
     inline bool
@@ -3427,7 +3427,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        */
       result_type
       min() const
-      { return std::numeric_limits<result_type>::min(); }
+      { return std::numeric_limits<result_type>::lowest(); }
 
       /**
        * @brief Returns the least upper bound value of the distribution.
@@ -3492,7 +3492,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       friend bool
       operator==(const student_t_distribution& __d1,
                 const student_t_distribution& __d2)
-      { return (__d1.param() == __d2.param()
+      { return (__d1._M_param == __d2._M_param
                && __d1._M_nd == __d2._M_nd && __d1._M_gd == __d2._M_gd); }
 
       /**
@@ -3664,7 +3664,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     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
@@ -3684,7 +3684,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       void
       __generate(_ForwardIterator __f, _ForwardIterator __t,
                 _UniformRandomNumberGenerator& __urng)
-      { this->__generate(__f, __t, __urng, this->param()); }
+      { this->__generate(__f, __t, __urng, _M_param); }
 
     template<typename _ForwardIterator,
             typename _UniformRandomNumberGenerator>
@@ -3700,6 +3700,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                 const param_type& __p)
       { this->__generate_impl(__f, __t, __urng, __p); }
 
+    /**
+     * @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:
     template<typename _ForwardIterator,
             typename _UniformRandomNumberGenerator>
@@ -3711,15 +3720,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     param_type _M_param;
   };
 
-  /**
-   * @brief Return true if two Bernoulli distributions have
-   *        the same parameters.
-   */
-  inline bool
-  operator==(const std::bernoulli_distribution& __d1,
-            const std::bernoulli_distribution& __d2)
-  { return __d1.param() == __d2.param(); }
-
   /**
    * @brief Return true if two Bernoulli distributions have
    *        different parameters.
@@ -3769,7 +3769,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    * @brief A discrete binomial random number distribution.
    *
    * The formula for the binomial probability density function is
-   * @f$p(i|t,p) = \binom{n}{i} p^i (1 - p)^{t - i}@f$ where @f$t@f$
+   * @f$p(i|t,p) = \binom{t}{i} p^i (1 - p)^{t - i}@f$ where @f$t@f$
    * and @f$p@f$ are the parameters of the distribution.
    */
   template<typename _IntType = int>
@@ -3892,7 +3892,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       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
@@ -3904,7 +3904,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        void
        __generate(_ForwardIterator __f, _ForwardIterator __t,
                   _UniformRandomNumberGenerator& __urng)
-       { this->__generate(__f, __t, __urng, this->param()); }
+       { this->__generate(__f, __t, __urng, _M_param); }
 
       template<typename _ForwardIterator,
               typename _UniformRandomNumberGenerator>
@@ -3930,9 +3930,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
         operator==(const binomial_distribution& __d1,
                   const binomial_distribution& __d2)
 #ifdef _GLIBCXX_USE_C99_MATH_TR1
-       { return __d1.param() == __d2.param() && __d1._M_nd == __d2._M_nd; }
+       { return __d1._M_param == __d2._M_param && __d1._M_nd == __d2._M_nd; }
 #else
-        { return __d1.param() == __d2.param(); }
+        { return __d1._M_param == __d2._M_param; }
 #endif
 
       /**
@@ -3977,7 +3977,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
       template<typename _UniformRandomNumberGenerator>
        result_type
-       _M_waiting(_UniformRandomNumberGenerator& __urng, _IntType __t);
+       _M_waiting(_UniformRandomNumberGenerator& __urng,
+                  _IntType __t, double __q);
 
       param_type _M_param;
 
@@ -4104,7 +4105,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       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
@@ -4116,7 +4117,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        void
        __generate(_ForwardIterator __f, _ForwardIterator __t,
                   _UniformRandomNumberGenerator& __urng)
-       { this->__generate(__f, __t, __urng, this->param()); }
+       { this->__generate(__f, __t, __urng, _M_param); }
 
       template<typename _ForwardIterator,
               typename _UniformRandomNumberGenerator>
@@ -4133,6 +4134,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                   const param_type& __p)
        { this->__generate_impl(__f, __t, __urng, __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:
       template<typename _ForwardIterator,
               typename _UniformRandomNumberGenerator>
@@ -4144,16 +4154,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       param_type _M_param;
     };
 
-  /**
-   * @brief Return true if two geometric distributions have
-   *        the same parameters.
-   */
-  template<typename _IntType>
-    inline bool
-    operator==(const std::geometric_distribution<_IntType>& __d1,
-              const std::geometric_distribution<_IntType>& __d2)
-    { return __d1.param() == __d2.param(); }
-
   /**
    * @brief Return true if two geometric distributions have
    *        different parameters.
@@ -4349,7 +4349,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       friend bool
       operator==(const negative_binomial_distribution& __d1,
                 const negative_binomial_distribution& __d2)
-      { return __d1.param() == __d2.param() && __d1._M_gd == __d2._M_gd; }
+      { return __d1._M_param == __d2._M_param && __d1._M_gd == __d2._M_gd; }
 
       /**
        * @brief Inserts a %negative_binomial_distribution random
@@ -4529,7 +4529,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       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
@@ -4541,7 +4541,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        void
        __generate(_ForwardIterator __f, _ForwardIterator __t,
                   _UniformRandomNumberGenerator& __urng)
-       { this->__generate(__f, __t, __urng, this->param()); }
+       { this->__generate(__f, __t, __urng, _M_param); }
 
       template<typename _ForwardIterator,
               typename _UniformRandomNumberGenerator>
@@ -4567,9 +4567,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       operator==(const poisson_distribution& __d1,
                 const poisson_distribution& __d2)
 #ifdef _GLIBCXX_USE_C99_MATH_TR1
-      { return __d1.param() == __d2.param() && __d1._M_nd == __d2._M_nd; }
+      { return __d1._M_param == __d2._M_param && __d1._M_nd == __d2._M_nd; }
 #else
-      { return __d1.param() == __d2.param(); }
+      { return __d1._M_param == __d2._M_param; }
 #endif
 
       /**
@@ -4739,7 +4739,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       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
@@ -4756,7 +4756,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        void
        __generate(_ForwardIterator __f, _ForwardIterator __t,
                   _UniformRandomNumberGenerator& __urng)
-       { this->__generate(__f, __t, __urng, this->param()); }
+       { this->__generate(__f, __t, __urng, _M_param); }
 
       template<typename _ForwardIterator,
               typename _UniformRandomNumberGenerator>
@@ -4773,6 +4773,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                   const param_type& __p)
        { this->__generate_impl(__f, __t, __urng, __p); }
 
+      /**
+       * @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:
       template<typename _ForwardIterator,
               typename _UniformRandomNumberGenerator>
@@ -4784,16 +4793,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       param_type _M_param;
     };
 
-  /**
-   * @brief Return true if two exponential distributions have the same
-   *        parameters.
-   */
-  template<typename _RealType>
-    inline bool
-    operator==(const std::exponential_distribution<_RealType>& __d1,
-              const std::exponential_distribution<_RealType>& __d2)
-    { return __d1.param() == __d2.param(); }
-
   /**
    * @brief Return true if two exponential distributions have different
    *        parameters.
@@ -4948,7 +4947,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       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
@@ -4960,7 +4959,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        void
        __generate(_ForwardIterator __f, _ForwardIterator __t,
                   _UniformRandomNumberGenerator& __urng)
-       { this->__generate(__f, __t, __urng, this->param()); }
+       { this->__generate(__f, __t, __urng, _M_param); }
 
       template<typename _ForwardIterator,
               typename _UniformRandomNumberGenerator>
@@ -4977,6 +4976,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                   const param_type& __p)
        { this->__generate_impl(__f, __t, __urng, __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:
       template<typename _ForwardIterator,
               typename _UniformRandomNumberGenerator>
@@ -4988,16 +4996,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       param_type _M_param;
     };
 
-   /**
-    * @brief Return true if two Weibull distributions have the same
-    *        parameters.
-    */
-  template<typename _RealType>
-    inline bool
-    operator==(const std::weibull_distribution<_RealType>& __d1,
-              const std::weibull_distribution<_RealType>& __d2)
-    { return __d1.param() == __d2.param(); }
-
    /**
     * @brief Return true if two Weibull distributions have different
     *        parameters.
@@ -5137,7 +5135,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        */
       result_type
       min() const
-      { return std::numeric_limits<result_type>::min(); }
+      { return std::numeric_limits<result_type>::lowest(); }
 
       /**
        * @brief Returns the least upper bound value of the distribution.
@@ -5152,7 +5150,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       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
@@ -5164,7 +5162,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        void
        __generate(_ForwardIterator __f, _ForwardIterator __t,
                   _UniformRandomNumberGenerator& __urng)
-       { this->__generate(__f, __t, __urng, this->param()); }
+       { this->__generate(__f, __t, __urng, _M_param); }
 
       template<typename _ForwardIterator,
               typename _UniformRandomNumberGenerator>
@@ -5181,6 +5179,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                   const param_type& __p)
        { this->__generate_impl(__f, __t, __urng, __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:
       template<typename _ForwardIterator,
               typename _UniformRandomNumberGenerator>
@@ -5192,16 +5199,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       param_type _M_param;
     };
 
-  /**
-    * @brief Return true if two extreme value distributions have the same
-    *        parameters.
-   */
-  template<typename _RealType>
-    inline bool
-    operator==(const std::extreme_value_distribution<_RealType>& __d1,
-              const std::extreme_value_distribution<_RealType>& __d2)
-    { return __d1.param() == __d2.param(); }
-
   /**
     * @brief Return true if two extreme value distributions have different
     *        parameters.
@@ -5382,7 +5379,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       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
@@ -5394,7 +5391,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        void
        __generate(_ForwardIterator __f, _ForwardIterator __t,
                   _UniformRandomNumberGenerator& __urng)
-       { this->__generate(__f, __t, __urng, this->param()); }
+       { this->__generate(__f, __t, __urng, _M_param); }
 
       template<typename _ForwardIterator,
               typename _UniformRandomNumberGenerator>
@@ -5411,6 +5408,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                   const param_type& __p)
        { this->__generate_impl(__f, __t, __urng, __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.
@@ -5453,16 +5459,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       param_type _M_param;
     };
 
-  /**
-    * @brief Return true if two discrete distributions have the same
-    *        parameters.
-    */
-  template<typename _IntType>
-    inline bool
-    operator==(const std::discrete_distribution<_IntType>& __d1,
-              const std::discrete_distribution<_IntType>& __d2)
-    { return __d1.param() == __d2.param(); }
-
   /**
     * @brief Return true if two discrete distributions have different
     *        parameters.
@@ -5649,7 +5645,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       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
@@ -5661,7 +5657,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        void
        __generate(_ForwardIterator __f, _ForwardIterator __t,
                   _UniformRandomNumberGenerator& __urng)
-       { this->__generate(__f, __t, __urng, this->param()); }
+       { this->__generate(__f, __t, __urng, _M_param); }
 
       template<typename _ForwardIterator,
               typename _UniformRandomNumberGenerator>
@@ -5679,11 +5675,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        { this->__generate_impl(__f, __t, __urng, __p); }
 
       /**
-       * @brief Inserts a %piecewise_constan_distribution random
+       * @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_constant_distribution random
        *        number distribution @p __x into the output stream @p __os.
        *
        * @param __os An output stream.
-       * @param __x  A %piecewise_constan_distribution random number
+       * @param __x  A %piecewise_constant_distribution random number
        *             distribution.
        *
        * @returns The output stream with the state of @p __x inserted or in
@@ -5695,11 +5700,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                   const std::piecewise_constant_distribution<_RealType1>& __x);
 
       /**
-       * @brief Extracts a %piecewise_constan_distribution random
+       * @brief Extracts a %piecewise_constant_distribution random
        *        number distribution @p __x from the input stream @p __is.
        *
        * @param __is An input stream.
-       * @param __x A %piecewise_constan_distribution random number
+       * @param __x A %piecewise_constant_distribution random number
        *            generator engine.
        *
        * @returns The input stream with @p __x extracted or in an error
@@ -5721,16 +5726,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       param_type _M_param;
     };
 
-  /**
-    * @brief Return true if two piecewise constant distributions have the
-    *        same parameters.
-   */
-  template<typename _RealType>
-    inline bool
-    operator==(const std::piecewise_constant_distribution<_RealType>& __d1,
-              const std::piecewise_constant_distribution<_RealType>& __d2)
-    { return __d1.param() == __d2.param(); }
-
   /**
     * @brief Return true if two piecewise constant distributions have 
     *        different parameters.
@@ -5920,7 +5915,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       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
@@ -5932,7 +5927,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        void
        __generate(_ForwardIterator __f, _ForwardIterator __t,
                   _UniformRandomNumberGenerator& __urng)
-       { this->__generate(__f, __t, __urng, this->param()); }
+       { this->__generate(__f, __t, __urng, _M_param); }
 
       template<typename _ForwardIterator,
               typename _UniformRandomNumberGenerator>
@@ -5949,6 +5944,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                   const param_type& __p)
        { this->__generate_impl(__f, __t, __urng, __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.
@@ -5992,16 +5996,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       param_type _M_param;
     };
 
-  /**
-    * @brief Return true if two piecewise linear distributions have the
-    *        same parameters.
-   */
-  template<typename _RealType>
-    inline bool
-    operator==(const std::piecewise_linear_distribution<_RealType>& __d1,
-              const std::piecewise_linear_distribution<_RealType>& __d2)
-    { return __d1.param() == __d2.param(); }
-
   /**
     * @brief Return true if two piecewise linear distributions have
     *        different parameters.