epoc32/include/stdapis/boost/random/uniform_real.hpp
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/boost/random/uniform_real.hpp	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,83 @@
     1.4 +/* boost random/uniform_real.hpp header file
     1.5 + *
     1.6 + * Copyright Jens Maurer 2000-2001
     1.7 + * Distributed under the Boost Software License, Version 1.0. (See
     1.8 + * accompanying file LICENSE_1_0.txt or copy at
     1.9 + * http://www.boost.org/LICENSE_1_0.txt)
    1.10 + *
    1.11 + * See http://www.boost.org for most recent version including documentation.
    1.12 + *
    1.13 + * $Id: uniform_real.hpp,v 1.17 2005/01/28 15:04:17 dgregor Exp $
    1.14 + *
    1.15 + * Revision history
    1.16 + *  2001-04-08  added min<max assertion (N. Becker)
    1.17 + *  2001-02-18  moved to individual header files
    1.18 + */
    1.19 +
    1.20 +#ifndef BOOST_RANDOM_UNIFORM_REAL_HPP
    1.21 +#define BOOST_RANDOM_UNIFORM_REAL_HPP
    1.22 +
    1.23 +#include <cassert>
    1.24 +#include <iostream>
    1.25 +#include <boost/config.hpp>
    1.26 +#include <boost/limits.hpp>
    1.27 +#include <boost/static_assert.hpp>
    1.28 +
    1.29 +namespace boost {
    1.30 +
    1.31 +// uniform distribution on a real range
    1.32 +template<class RealType = double>
    1.33 +class uniform_real
    1.34 +{
    1.35 +public:
    1.36 +  typedef RealType input_type;
    1.37 +  typedef RealType result_type;
    1.38 +
    1.39 +  explicit uniform_real(RealType min = RealType(0),
    1.40 +                        RealType max = RealType(1))
    1.41 +    : _min(min), _max(max)
    1.42 +  {
    1.43 +#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
    1.44 +    BOOST_STATIC_ASSERT(!std::numeric_limits<RealType>::is_integer);
    1.45 +#endif
    1.46 +    assert(min < max);
    1.47 +  }
    1.48 +
    1.49 +  // compiler-generated copy ctor and assignment operator are fine
    1.50 +
    1.51 +  result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return _min; }
    1.52 +  result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return _max; }
    1.53 +  void reset() { }
    1.54 +
    1.55 +  template<class Engine>
    1.56 +  result_type operator()(Engine& eng) {
    1.57 +    return static_cast<result_type>(eng() - eng.min BOOST_PREVENT_MACRO_SUBSTITUTION())
    1.58 +           / static_cast<result_type>(eng.max BOOST_PREVENT_MACRO_SUBSTITUTION() - eng.min BOOST_PREVENT_MACRO_SUBSTITUTION())
    1.59 +           * (_max - _min) + _min;
    1.60 +  }
    1.61 +
    1.62 +#if !defined(BOOST_NO_OPERATORS_IN_NAMESPACE) && !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
    1.63 +  template<class CharT, class Traits>
    1.64 +  friend std::basic_ostream<CharT,Traits>&
    1.65 +  operator<<(std::basic_ostream<CharT,Traits>& os, const uniform_real& ud)
    1.66 +  {
    1.67 +    os << ud._min << " " << ud._max;
    1.68 +    return os;
    1.69 +  }
    1.70 +
    1.71 +  template<class CharT, class Traits>
    1.72 +  friend std::basic_istream<CharT,Traits>&
    1.73 +  operator>>(std::basic_istream<CharT,Traits>& is, uniform_real& ud)
    1.74 +  {
    1.75 +    is >> std::ws >> ud._min >> std::ws >> ud._max;
    1.76 +    return is;
    1.77 +  }
    1.78 +#endif
    1.79 +
    1.80 +private:
    1.81 +  RealType _min, _max;
    1.82 +};
    1.83 +
    1.84 +} // namespace boost
    1.85 +
    1.86 +#endif // BOOST_RANDOM_UNIFORM_REAL_HPP