Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r86321 - trunk/boost/random
From: loufoque_at_[hidden]
Date: 2013-10-15 10:08:58


Author: mgaunard
Date: 2013-10-15 10:08:57 EDT (Tue, 15 Oct 2013)
New Revision: 86321
URL: http://svn.boost.org/trac/boost/changeset/86321

Log:
random: avoid generating warnings with -Wshadow, fix #9115

Text files modified:
   trunk/boost/random/lagged_fibonacci.hpp | 55 ++++++++++++++++++++-------------------
   trunk/boost/random/mersenne_twister.hpp | 41 +++++++++++++++--------------
   2 files changed, 49 insertions(+), 47 deletions(-)

Modified: trunk/boost/random/lagged_fibonacci.hpp
==============================================================================
--- trunk/boost/random/lagged_fibonacci.hpp Tue Oct 15 07:08:22 2013 (r86320)
+++ trunk/boost/random/lagged_fibonacci.hpp 2013-10-15 10:08:57 EDT (Tue, 15 Oct 2013) (r86321)
@@ -10,6 +10,7 @@
  * $Id$
  *
  * Revision history
+ * 2013-10-14 fixed some warnings with Wshadow (mgaunard)
  * 2001-02-18 moved to individual header files
  */
 
@@ -35,7 +36,7 @@
 namespace boost {
 namespace random {
 
-/**
+/**
  * Instantiations of class template \lagged_fibonacci_engine model a
  * \pseudo_random_number_generator. It uses a lagged Fibonacci
  * algorithm with two lags @c p and @c q:
@@ -79,7 +80,7 @@
     { seed(first, last); }
 
     // compiler-generated copy ctor and assignment operator are fine
-
+
     /** Calls @c seed(default_seed). */
     void seed() { seed(default_seed); }
 
@@ -123,7 +124,7 @@
             fill();
         return x[i++];
     }
-
+
     /** Fills a range with random values */
     template<class Iter>
     void generate(Iter first, Iter last)
@@ -136,36 +137,36 @@
             (*this)();
         }
     }
-
+
     /**
      * Writes the textual representation of the generator to a @c std::ostream.
      */
     BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, lagged_fibonacci_engine, f)
     {
         os << f.i;
- for(unsigned int i = 0; i < f.long_lag; ++i)
- os << ' ' << f.x[i];
+ for(unsigned int j = 0; j < f.long_lag; ++j)
+ os << ' ' << f.x[j];
         return os;
     }
-
+
     /**
      * Reads the textual representation of the generator from a @c std::istream.
      */
     BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, lagged_fibonacci_engine, f)
     {
         is >> f.i >> std::ws;
- for(unsigned int i = 0; i < f.long_lag; ++i)
- is >> f.x[i] >> std::ws;
+ for(unsigned int j = 0; j < f.long_lag; ++j)
+ is >> f.x[j] >> std::ws;
         return is;
     }
-
+
     /**
      * Returns true if the two generators will produce identical
      * sequences of outputs.
      */
- BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(lagged_fibonacci_engine, x, y)
- { return x.i == y.i && std::equal(x.x, x.x+long_lag, y.x); }
-
+ BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(lagged_fibonacci_engine, x_, y_)
+ { return x_.i == y_.i && std::equal(x_.x, x_.x+long_lag, y_.x); }
+
     /**
      * Returns true if the two generators will produce different
      * sequences of outputs.
@@ -306,7 +307,7 @@
         detail::seed_array_real<w>(seq, x);
         i = long_lag;
     }
-
+
     /**
      * Seeds this @c lagged_fibonacci_01_engine using values from the
      * iterator range [first, last). If there are not enough elements
@@ -318,7 +319,7 @@
         detail::fill_array_real<w>(first, last, x);
         i = long_lag;
     }
-
+
     /** Returns the smallest value that the generator can produce. */
     static result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () { return result_type(0); }
     /** Returns the upper bound of the generators outputs. */
@@ -331,7 +332,7 @@
             fill();
         return x[i++];
     }
-
+
     /** Fills a range with random values */
     template<class Iter>
     void generate(Iter first, Iter last)
@@ -344,7 +345,7 @@
             (*this)();
         }
     }
-
+
     /**
      * Writes the textual representation of the generator to a @c std::ostream.
      */
@@ -353,34 +354,34 @@
         // allow for Koenig lookup
         using std::pow;
         os << f.i;
- std::ios_base::fmtflags oldflags = os.flags(os.dec | os.fixed | os.left);
- for(unsigned int i = 0; i < f.long_lag; ++i)
- os << ' ' << f.x[i] * f.modulus();
+ std::ios_base::fmtflags oldflags = os.flags(os.dec | os.fixed | os.left);
+ for(unsigned int j = 0; j < f.long_lag; ++j)
+ os << ' ' << f.x[j] * f.modulus();
         os.flags(oldflags);
         return os;
     }
-
+
     /**
      * Reads the textual representation of the generator from a @c std::istream.
      */
     BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, lagged_fibonacci_01_engine, f)
     {
         is >> f.i;
- for(unsigned int i = 0; i < f.long_lag; ++i) {
+ for(unsigned int j = 0; j < f.long_lag; ++j) {
             typename lagged_fibonacci_01_engine::result_type value;
             is >> std::ws >> value;
- f.x[i] = value / f.modulus();
+ f.x[j] = value / f.modulus();
         }
         return is;
     }
-
+
     /**
      * Returns true if the two generators will produce identical
      * sequences of outputs.
      */
- BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(lagged_fibonacci_01_engine, x, y)
- { return x.i == y.i && std::equal(x.x, x.x+long_lag, y.x); }
-
+ BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(lagged_fibonacci_01_engine, x_, y_)
+ { return x_.i == y_.i && std::equal(x_.x, x_.x+long_lag, y_.x); }
+
     /**
      * Returns true if the two generators will produce different
      * sequences of outputs.

Modified: trunk/boost/random/mersenne_twister.hpp
==============================================================================
--- trunk/boost/random/mersenne_twister.hpp Tue Oct 15 07:08:22 2013 (r86320)
+++ trunk/boost/random/mersenne_twister.hpp 2013-10-15 10:08:57 EDT (Tue, 15 Oct 2013) (r86321)
@@ -11,6 +11,7 @@
  * $Id$
  *
  * Revision history
+ * 2013-10-14 fixed some warnings with Wshadow (mgaunard)
  * 2001-02-18 moved to individual header files
  */
 
@@ -40,7 +41,7 @@
  * "Mersenne Twister: A 623-dimensionally equidistributed uniform
  * pseudo-random number generator", Makoto Matsumoto and Takuji Nishimura,
  * ACM Transactions on Modeling and Computer Simulation: Special Issue on
- * Uniform Random Number Generation, Vol. 8, No. 1, January 1998, pp. 3-30.
+ * Uniform Random Number Generation, Vol. 8, No. 1, January 1998, pp. 3-30.
  * @endblockquote
  *
  * @xmlnote
@@ -51,7 +52,7 @@
  *
  * The seeding from an integer was changed in April 2005 to address a
  * weakness.
- *
+ *
  * The quality of the generator crucially depends on the choice of the
  * parameters. User code should employ one of the sensibly parameterized
  * generators such as \mt19937 instead.
@@ -83,7 +84,7 @@
     BOOST_STATIC_CONSTANT(std::size_t, tempering_l = l);
     BOOST_STATIC_CONSTANT(UIntType, initialization_multiplier = f);
     BOOST_STATIC_CONSTANT(UIntType, default_seed = 5489u);
-
+
     // backwards compatibility
     BOOST_STATIC_CONSTANT(UIntType, parameter_a = a);
     BOOST_STATIC_CONSTANT(std::size_t, output_u = u);
@@ -92,7 +93,7 @@
     BOOST_STATIC_CONSTANT(std::size_t, output_t = t);
     BOOST_STATIC_CONSTANT(UIntType, output_c = c);
     BOOST_STATIC_CONSTANT(std::size_t, output_l = l);
-
+
     // old Boost.Random concept requirements
     BOOST_STATIC_CONSTANT(bool, has_fixed_range = false);
 
@@ -136,7 +137,7 @@
      */
     BOOST_RANDOM_DETAIL_ARITHMETIC_SEED(mersenne_twister_engine, UIntType, value)
     {
- // New seeding algorithm from
+ // New seeding algorithm from
         // http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html
         // In the previous versions, MSBs of the seed affected only MSBs of the
         // state x[].
@@ -150,7 +151,7 @@
 
         normalize_state();
     }
-
+
     /**
      * Seeds a mersenne_twister_engine using values produced by seq.generate().
      */
@@ -171,14 +172,14 @@
 
         normalize_state();
     }
-
+
     /** Returns the smallest value that the generator can produce. */
     static result_type min BOOST_PREVENT_MACRO_SUBSTITUTION ()
     { return 0; }
     /** Returns the largest value that the generator can produce. */
     static result_type max BOOST_PREVENT_MACRO_SUBSTITUTION ()
     { return boost::low_bits_mask_t<w>::sig_bits; }
-
+
     /** Produces the next value of the generator. */
     result_type operator()();
 
@@ -213,7 +214,7 @@
         mt.print(os);
         return os;
     }
-
+
     /** Reads a mersenne_twister_engine from a @c std::istream */
     template<class CharT, class Traits>
     friend std::basic_istream<CharT,Traits>&
@@ -234,19 +235,19 @@
      * Returns true if the two generators are in the same state,
      * and will thus produce identical sequences.
      */
- friend bool operator==(const mersenne_twister_engine& x,
- const mersenne_twister_engine& y)
+ friend bool operator==(const mersenne_twister_engine& x_,
+ const mersenne_twister_engine& y_)
     {
- if(x.i < y.i) return x.equal_imp(y);
- else return y.equal_imp(x);
+ if(x_.i < y_.i) return x_.equal_imp(y_);
+ else return y_.equal_imp(x_);
     }
-
+
     /**
      * Returns true if the two generators are in different states.
      */
- friend bool operator!=(const mersenne_twister_engine& x,
- const mersenne_twister_engine& y)
- { return !(x == y); }
+ friend bool operator!=(const mersenne_twister_engine& x_,
+ const mersenne_twister_engine& y_)
+ { return !(x_ == y_); }
 
 private:
     /// \cond show_private
@@ -373,7 +374,7 @@
     // x[0] ... x[k] x[k+1] ... x[n-1] represents
     // x(i-k) ... x(i) x(i+1) ... x(i-k+n-1)
 
- UIntType x[n];
+ UIntType x[n];
     std::size_t i;
 };
 
@@ -487,7 +488,7 @@
  * uniform pseudo-random number generator", Makoto Matsumoto
  * and Takuji Nishimura, ACM Transactions on Modeling and
  * Computer Simulation: Special Issue on Uniform Random Number
- * Generation, Vol. 8, No. 1, January 1998, pp. 3-30.
+ * Generation, Vol. 8, No. 1, January 1998, pp. 3-30.
  * @endblockquote
  */
 typedef mersenne_twister_engine<uint32_t,32,351,175,19,0xccab8ee7,
@@ -501,7 +502,7 @@
  * uniform pseudo-random number generator", Makoto Matsumoto
  * and Takuji Nishimura, ACM Transactions on Modeling and
  * Computer Simulation: Special Issue on Uniform Random Number
- * Generation, Vol. 8, No. 1, January 1998, pp. 3-30.
+ * Generation, Vol. 8, No. 1, January 1998, pp. 3-30.
  * @endblockquote
  */
 typedef mersenne_twister_engine<uint32_t,32,624,397,31,0x9908b0df,


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk