88// granted to it by virtue of its status as an Intergovernmental Organization
99// or submit itself to any jurisdiction.
1010
11- // -*- Mode: C++ -*-
12-
1311#ifndef DATAGENERATOR_H
1412#define DATAGENERATOR_H
1513// ****************************************************************************
@@ -64,16 +62,17 @@ template<typename ValueT
6462 , typename ModelT>
6563class DataGenerator {
6664public:
67- typedef int size_type;
68- typedef ValueT result_type;
69- typedef DataGenerator self_type;
65+ using size_type = std::size_t ;
66+ using value_type = ValueT;
67+ using result_type = value_type;
68+ using self_type = DataGenerator;
7069
7170 template <typename ... Args>
7271 DataGenerator (result_type _min,
7372 result_type _max,
7473 result_type _step,
7574 Args&&... args)
76- : mGenerator (), min(_min), max(_max), step(_step), nbins((max-min)/step), mModel (std::forward<Args>(args)...) {}
75+ : min(_min), max(_max), step(_step), nbins((max-min)/step), mGenerator ( ), mModel (std::forward<Args>(args)...) {}
7776 ~DataGenerator () {}
7877 DataGenerator (const DataGenerator&) = default ;
7978 DataGenerator& operator =(const DataGenerator&) = default ;
@@ -83,8 +82,7 @@ class DataGenerator {
8382 const result_type step;
8483 const size_type nbins;
8584
86- typedef ValueT value_type;
87- typedef std::default_random_engine random_engine;
85+ using random_engine = std::default_random_engine;
8886
8987 // / get next random value
9088 // TODO: can it be const?
@@ -98,7 +96,7 @@ class DataGenerator {
9896 }
9997 }
10098 int bin = (v - min)/step;
101- return min + bin * step;
99+ return min + bin * step + 0.5 * step ;
102100 }
103101
104102 // / get next random value
@@ -115,7 +113,7 @@ class DataGenerator {
115113 return mModel .getProbability (v);
116114 }
117115
118- typedef std::iterator<std::forward_iterator_tag, result_type> _iterator_base ;
116+ using _iterator_base = std::iterator<std::forward_iterator_tag, result_type>;
119117
120118 /* *
121119 * @class iterator a forward iterator to access the bins
@@ -129,9 +127,9 @@ class DataGenerator {
129127 iterator (const ContainerT& parent, size_type count = 0 ) : mParent (parent), mCount (count) {}
130128 ~iterator () {}
131129
132- typedef iterator self_type;
133- typedef typename _iterator_base::value_type value_type;
134- typedef typename _iterator_base::reference reference;
130+ using self_type = iterator ;
131+ using value_type = typename _iterator_base::value_type;
132+ using reference = typename _iterator_base::reference;
135133
136134 // prefix increment
137135 self_type& operator ++() {
@@ -153,7 +151,7 @@ class DataGenerator {
153151 return copy;
154152 }
155153
156- value_type operator *() {return mParent .min + ( mCount +. 5 ) * mParent .step ;}
154+ value_type operator *() {return mParent .min + mCount * mParent . step + . 5 * mParent .step ;}
157155 // pointer operator->() const {return &mValue;}
158156 // reference operator[](size_type n) const;
159157
@@ -194,7 +192,7 @@ template <class RealType = double
194192 >
195193class normal_distribution : public _BASE {
196194public:
197- typedef typename _BASE::result_type result_type;
195+ using result_type = typename _BASE::result_type;
198196
199197 normal_distribution (result_type _mean,
200198 result_type _stddev
@@ -226,7 +224,7 @@ template <class IntType = int
226224 >
227225class poisson_distribution : public _BASE {
228226public:
229- typedef typename _BASE::result_type result_type;
227+ using result_type = typename _BASE::result_type;
230228
231229 poisson_distribution (result_type _mean) : _BASE(_mean), mean(_mean) {}
232230 ~poisson_distribution () {};
0 commit comments