Skip to content

Commit 310a0fc

Browse files
matthiasrichterktf
authored andcommitted
Modernizing code Utilities/DataCompression
replacing typedef with using declarations
1 parent e36d65b commit 310a0fc

4 files changed

Lines changed: 45 additions & 45 deletions

File tree

Utilities/DataCompression/include/DataCompression/CodingModelDispatcher.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,18 @@ class CodingModelDispatcher
6060
CodingModelDispatcher() : mPosition(0), mContainer() {}
6161
~CodingModelDispatcher() = default;
6262

63-
typedef CodingModelDispatcher<ModelDefinition> self_type;
63+
using self_type = CodingModelDispatcher<ModelDefinition>;
6464

6565
// make_mpl_vector traits makes sure that an mpl sequence is used further on
6666
// if the original type is not a sequence it is wrapped into an mpl vector with
6767
// the original type as the only element
68-
typedef typename mpl::make_mpl_vector<ModelDefinition>::type definition_type;
68+
using definition_type = typename mpl::make_mpl_vector<ModelDefinition>::type;
6969

7070
// the runtime container type is the heart of the dispatcher to runtime objects
7171
// of the sequence of data types which define the probability model
72-
typedef typename create_rtc<definition_type, RuntimeContainer<>>::type container_type;
72+
using container_type = typename create_rtc<definition_type, RuntimeContainer<>>::type;
7373

74-
typedef typename container_type::wrapped_type::code_type code_type;
74+
using code_type = typename container_type::wrapped_type::code_type;
7575

7676
/// get the number of models in the definition
7777
static int getNumberOfModels() { return boost::mpl::size<definition_type>::value; }
@@ -87,7 +87,7 @@ class CodingModelDispatcher
8787
addWeightFctr(ValueType _v, WeightType _w) : value(_v), weight(_w) {}
8888
~addWeightFctr() {}
8989

90-
typedef bool return_type;
90+
using return_type = bool;
9191

9292
template <typename T>
9393
return_type operator()(T& stage)
@@ -128,7 +128,7 @@ class CodingModelDispatcher
128128
initFctr(container_type& container) : mContainer(container) {}
129129
~initFctr() {}
130130

131-
typedef int return_type;
131+
using return_type = int;
132132

133133
template <typename T>
134134
return_type operator()(boost::type<T>)
@@ -161,7 +161,7 @@ class CodingModelDispatcher
161161
generateFctr(container_type& container) : mContainer(container) {}
162162
~generateFctr() {}
163163

164-
typedef int return_type;
164+
using return_type = int;
165165

166166
template <typename T>
167167
return_type operator()(boost::type<T>)
@@ -193,7 +193,7 @@ class CodingModelDispatcher
193193
}
194194
~encodeFctr() {}
195195

196-
typedef bool return_type;
196+
using return_type = bool;
197197

198198
template <typename T>
199199
return_type operator()(T& stage)
@@ -234,7 +234,7 @@ class CodingModelDispatcher
234234
}
235235
~decodeFctr() {}
236236

237-
typedef bool return_type;
237+
using return_type = bool;
238238

239239
template <typename T>
240240
return_type operator()(T& stage)
@@ -270,7 +270,7 @@ class CodingModelDispatcher
270270
class getCodingDirectionFctr
271271
{
272272
public:
273-
typedef bool return_type;
273+
using return_type = bool;
274274
template <typename T>
275275
return_type operator()(T& stage)
276276
{
@@ -290,7 +290,7 @@ class CodingModelDispatcher
290290
writeFctr(std::ostream& out, container_type& container) : mOut(out), mContainer(container) {}
291291
~writeFctr() {}
292292

293-
typedef std::ostream& return_type;
293+
using return_type = std::ostream&;
294294

295295
template <typename T>
296296
return_type operator()(boost::type<T>)
@@ -330,7 +330,7 @@ class CodingModelDispatcher
330330
readFctr(std::istream& in, container_type& container) : mIn(in), mContainer(container) {}
331331
~readFctr() {}
332332

333-
typedef bool return_type;
333+
using return_type = bool;
334334

335335
template <typename T>
336336
return_type operator()(boost::type<T>)

Utilities/DataCompression/include/DataCompression/HuffmanCodec.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ template <typename _CodeType>
5656
class HuffmanNode
5757
{
5858
public:
59-
typedef HuffmanNode self_type;
60-
typedef self_type* pointer;
61-
typedef std::shared_ptr<self_type> shared_pointer;
62-
typedef _CodeType CodeType;
59+
using self_type = HuffmanNode;
60+
using pointer = self_type*;
61+
using shared_pointer = std::shared_ptr<self_type>;
62+
using CodeType = _CodeType;
6363

6464
HuffmanNode() : mLeft(), mRight(), mWeight(0.), mIndex(~uint16_t(0)), mCode(), mCodeLen(0) {}
6565
HuffmanNode(const HuffmanNode& other) = default;
@@ -172,7 +172,7 @@ class HuffmanCodec
172172
HuffmanCodec(const _CodingModel& model) : mCodingModel(model) {}
173173
~HuffmanCodec() {}
174174

175-
typedef _CodingModel model_type;
175+
using model_type = _CodingModel;
176176

177177
/// Return Huffman code for a value
178178
template <typename CodeType, typename ValueType>
@@ -216,10 +216,10 @@ class HuffmanModel : public _BASE
216216
HuffmanModel() : mAlphabet(), mLeaveNodes(), mTreeNodes() {}
217217
~HuffmanModel() {}
218218

219-
typedef _BASE base_type;
220-
typedef class HuffmanModel<_BASE, _NodeType> self_type;
221-
typedef typename _BASE::value_type value_type;
222-
typedef typename _NodeType::CodeType code_type;
219+
using base_type = _BASE;
220+
using self_type = class HuffmanModel<_BASE, _NodeType>;
221+
using value_type = typename _BASE::value_type;
222+
using code_type = typename _NodeType::CodeType;
223223
static constexpr bool orderMSB = _orderMSB;
224224

225225
int init(double v = 1.) { return _BASE::initWeight(mAlphabet, v); }

Utilities/DataCompression/include/DataCompression/dc_primitives.h

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class ExampleAlphabet
134134
ExampleAlphabet();
135135
~ExampleAlphabet();
136136

137-
typedef T value_type;
137+
using value_type = T;
138138

139139
/// check for valid value within range
140140
static bool isValid(value_type v);
@@ -148,7 +148,7 @@ class ExampleAlphabet
148148
/// get the range of indices aka number of indices
149149
constexpr unsigned getIndexRange();
150150

151-
typedef std::iterator<std::forward_iterator_tag, T> _iterator_base;
151+
using _iterator_base = std::iterator<std::forward_iterator_tag, T>;
152152

153153
/// a forward iterator to access the list of elements
154154
class iterator : public _iterator_base
@@ -157,9 +157,9 @@ class ExampleAlphabet
157157
iterator();
158158
~iterator();
159159

160-
typedef iterator self_type;
161-
typedef typename _iterator_base::reference reference;
162-
typedef T* pointer;
160+
using self_type = iterator;
161+
using reference = typename _iterator_base::reference;
162+
using pointer = typename _iterator_base::pointer;
163163

164164
// prefix increment
165165
self_type& operator++();
@@ -204,10 +204,10 @@ class ContiguousAlphabet
204204
ContiguousAlphabet() {}
205205
~ContiguousAlphabet() {}
206206

207-
typedef T value_type;
208-
typedef T size_type;
209-
typedef boost::mpl::range_c<T, _min, _max> range;
210-
typedef boost::mpl::plus<boost::mpl::size<range>, boost::mpl::int_<1>> size;
207+
using value_type = T;
208+
using size_type = T;
209+
using range = boost::mpl::range_c<T, _min, _max>;
210+
using size = boost::mpl::plus<boost::mpl::size<range>, boost::mpl::int_<1>>;
211211

212212
/// check for valid value within range
213213
static bool isValid(value_type v) { return v >= _min && v <= _max; }
@@ -239,7 +239,7 @@ class ContiguousAlphabet
239239
/// name is part of the type definition, defined as a boost mpl string
240240
constexpr const char* getName() const { return boost::mpl::c_str<NameT>::value; }
241241

242-
typedef std::iterator<std::forward_iterator_tag, T> _iterator_base;
242+
using _iterator_base = std::iterator<std::forward_iterator_tag, T>;
243243

244244
/// a forward iterator to access the list of elements
245245
class iterator : public _iterator_base
@@ -249,11 +249,9 @@ class ContiguousAlphabet
249249
iterator(T value, bool isEnd) : mValue(value), mIsEnd(isEnd) {}
250250
~iterator() {}
251251

252-
typedef iterator self_type;
253-
// TODO: while value_type can be used, the reference has to be defined
254-
// once again, not yet understood
255-
typedef typename _iterator_base::reference reference;
256-
typedef T* pointer;
252+
using self_type = iterator;
253+
using reference = typename _iterator_base::reference;
254+
using pointer = typename _iterator_base::pointer;
257255

258256
// prefix increment
259257
self_type& operator++()
@@ -342,10 +340,10 @@ template <class Alphabet, typename WeightType = double>
342340
class ProbabilityModel
343341
{
344342
public:
345-
typedef Alphabet alphabet_type;
346-
typedef typename Alphabet::value_type value_type;
347-
typedef WeightType weight_type;
348-
typedef std::map<value_type, WeightType> TableType;
343+
using alphabet_type = Alphabet;
344+
using value_type = typename Alphabet::value_type;
345+
using weight_type = WeightType;
346+
using TableType = std::map<value_type, WeightType>;
349347

350348
// TODO: check if this is the correct way for WeightType defaults
351349
static const value_type _default0 = 0;

Utilities/DataCompression/include/DataCompression/mpl_tools.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class make_mpl_vector
6161
template <typename U, typename _Iter>
6262
struct VectorTraits {
6363
enum { result = true };
64-
typedef typename U::type type;
64+
using type = typename U::type;
6565
};
6666
// specialization for non sequences, for any data type which has no
6767
// begin meta function defined, the iterator is void type and this
@@ -70,15 +70,17 @@ class make_mpl_vector
7070
template <typename U>
7171
struct VectorTraits<U, boost::mpl::void_> {
7272
enum { result = false };
73-
typedef typename boost::mpl::fold<boost::mpl::vector<>, boost::mpl::set<U>,
74-
boost::mpl::insert<boost::mpl::_1, U>>::type type;
73+
using type = typename boost::mpl::fold<boost::mpl::vector<>, //
74+
boost::mpl::set<U>, //
75+
boost::mpl::insert<boost::mpl::_1, U> //
76+
>::type; //
7577
};
7678

7779
public:
7880
/// iSequence tells if the original type is a sequence
7981
enum { isSequence = VectorTraits<T, typename boost::mpl::begin<T>::type>::result };
8082
/// the tarits type, always a sequence
81-
typedef typename VectorTraits<T, typename boost::mpl::begin<T>::type>::type type;
83+
using type = typename VectorTraits<T, typename boost::mpl::begin<T>::type>::type;
8284
};
8385

8486
/******************************************************************************
@@ -152,7 +154,7 @@ struct apply_at_sequence_position<_IndexT, _End, _End, _ReturnT, _Index, F> {
152154
* @brief A default functor with void return type and no operation
153155
*/
154156
struct defaultFunctor {
155-
typedef void return_type;
157+
using return_type = void;
156158
template <typename T>
157159
return_type operator()(T)
158160
{

0 commit comments

Comments
 (0)