Skip to content

Commit 86faa86

Browse files
committed
Add make_unique
1 parent 3358614 commit 86faa86

1 file changed

Lines changed: 40 additions & 34 deletions

File tree

src/codecfactory.cpp

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -58,111 +58,117 @@ std::shared_ptr<IntegerCODEC> const& CODECFactory::getFromName(std::string name)
5858
return scodecmap.at(name);
5959
}
6060

61+
// std::make_unique equivalent
62+
template<typename T, typename... Args>
63+
static std::unique_ptr<T> make_unique(Args&&... args) {
64+
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
65+
}
66+
6167
std::unique_ptr<IntegerCODEC> fastbinarypacking8_codec() {
62-
return std::make_unique<CompositeCodec<FastBinaryPacking<8>, VariableByte>>();
68+
return make_unique<CompositeCodec<FastBinaryPacking<8>, VariableByte>>();
6369
}
6470
std::unique_ptr<IntegerCODEC> fastbinarypacking16_codec() {
65-
return std::make_unique<CompositeCodec<FastBinaryPacking<16>, VariableByte>>();
71+
return make_unique<CompositeCodec<FastBinaryPacking<16>, VariableByte>>();
6672
}
6773
std::unique_ptr<IntegerCODEC> fastbinarypacking32_codec() {
68-
return std::make_unique<CompositeCodec<FastBinaryPacking<32>, VariableByte>>();
74+
return make_unique<CompositeCodec<FastBinaryPacking<32>, VariableByte>>();
6975
}
7076
std::unique_ptr<IntegerCODEC> BP32_codec() {
71-
return std::make_unique<CompositeCodec<BP32, VariableByte>>();
77+
return make_unique<CompositeCodec<BP32, VariableByte>>();
7278
}
7379
std::unique_ptr<IntegerCODEC> vsencoding_codec() {
74-
return std::make_unique<vsencoding::VSEncodingBlocks>(1U << 16);
80+
return make_unique<vsencoding::VSEncodingBlocks>(1U << 16);
7581
}
7682
std::unique_ptr<IntegerCODEC> fastpfor128_codec() {
77-
return std::make_unique<CompositeCodec<FastPFor<4>, VariableByte>>();
83+
return make_unique<CompositeCodec<FastPFor<4>, VariableByte>>();
7884
}
7985
std::unique_ptr<IntegerCODEC> fastpfor256_codec() {
80-
return std::make_unique<CompositeCodec<FastPFor<8>, VariableByte>>();
86+
return make_unique<CompositeCodec<FastPFor<8>, VariableByte>>();
8187
}
8288
std::unique_ptr<IntegerCODEC> simdfastpfor128_codec() {
83-
return std::make_unique<CompositeCodec<SIMDFastPFor<4>, VariableByte>>();
89+
return make_unique<CompositeCodec<SIMDFastPFor<4>, VariableByte>>();
8490
}
8591
std::unique_ptr<IntegerCODEC> simdfastpfor256_codec() {
86-
return std::make_unique<CompositeCodec<SIMDFastPFor<8>, VariableByte>>();
92+
return make_unique<CompositeCodec<SIMDFastPFor<8>, VariableByte>>();
8793
}
8894
std::unique_ptr<IntegerCODEC> simplepfor_codec() {
89-
return std::make_unique<CompositeCodec<SimplePFor<>, VariableByte>>();
95+
return make_unique<CompositeCodec<SimplePFor<>, VariableByte>>();
9096
}
9197
std::unique_ptr<IntegerCODEC> simdsimplepfor_codec() {
92-
return std::make_unique<CompositeCodec<SIMDSimplePFor<>, VariableByte>>();
98+
return make_unique<CompositeCodec<SIMDSimplePFor<>, VariableByte>>();
9399
}
94100
std::unique_ptr<IntegerCODEC> pfor_codec() {
95-
return std::make_unique<CompositeCodec<PFor, VariableByte>>();
101+
return make_unique<CompositeCodec<PFor, VariableByte>>();
96102
}
97103
std::unique_ptr<IntegerCODEC> simdpfor_codec() {
98-
return std::make_unique<CompositeCodec<SIMDPFor, VariableByte>>();
104+
return make_unique<CompositeCodec<SIMDPFor, VariableByte>>();
99105
}
100106
std::unique_ptr<IntegerCODEC> pfor2008_codec() {
101-
return std::make_unique<CompositeCodec<PFor2008, VariableByte>>();
107+
return make_unique<CompositeCodec<PFor2008, VariableByte>>();
102108
}
103109
std::unique_ptr<IntegerCODEC> simdnewpfor_codec() {
104-
return std::make_unique<CompositeCodec<SIMDNewPFor<4, Simple16<false>>, VariableByte>>();
110+
return make_unique<CompositeCodec<SIMDNewPFor<4, Simple16<false>>, VariableByte>>();
105111
}
106112
std::unique_ptr<IntegerCODEC> newpfor_codec() {
107-
return std::make_unique<CompositeCodec<NewPFor<4, Simple16<false>>, VariableByte>>();
113+
return make_unique<CompositeCodec<NewPFor<4, Simple16<false>>, VariableByte>>();
108114
}
109115
std::unique_ptr<IntegerCODEC> optpfor_codec() {
110-
return std::make_unique<CompositeCodec<OPTPFor<4, Simple16<false>>, VariableByte>>();
116+
return make_unique<CompositeCodec<OPTPFor<4, Simple16<false>>, VariableByte>>();
111117
}
112118
std::unique_ptr<IntegerCODEC> simdoptpfor_codec() {
113-
return std::make_unique<CompositeCodec<SIMDOPTPFor<4, Simple16<false>>, VariableByte>>();
119+
return make_unique<CompositeCodec<SIMDOPTPFor<4, Simple16<false>>, VariableByte>>();
114120
}
115121
std::unique_ptr<IntegerCODEC> varint_codec() {
116-
return std::make_unique<VariableByte>();
122+
return make_unique<VariableByte>();
117123
}
118124
std::unique_ptr<IntegerCODEC> vbyte_codec() {
119-
return std::make_unique<VByte>();
125+
return make_unique<VByte>();
120126
}
121127
std::unique_ptr<IntegerCODEC> maskedvbyte_codec() {
122-
return std::make_unique<MaskedVByte>();
128+
return make_unique<MaskedVByte>();
123129
}
124130
std::unique_ptr<IntegerCODEC> streamvbyte_codec() {
125-
return std::make_unique<StreamVByte>();
131+
return make_unique<StreamVByte>();
126132
}
127133
std::unique_ptr<IntegerCODEC> varintgb_codec() {
128-
return std::make_unique<VarIntGB<>>();
134+
return make_unique<VarIntGB<>>();
129135
}
130136
std::unique_ptr<IntegerCODEC> simple16_codec() {
131-
return std::make_unique<Simple16<true>>();
137+
return make_unique<Simple16<true>>();
132138
}
133139
std::unique_ptr<IntegerCODEC> simple9_codec() {
134-
return std::make_unique<Simple9<true>>();
140+
return make_unique<Simple9<true>>();
135141
}
136142
std::unique_ptr<IntegerCODEC> simple9_rle_codec() {
137-
return std::make_unique<Simple9_RLE<true>>();
143+
return make_unique<Simple9_RLE<true>>();
138144
}
139145
std::unique_ptr<IntegerCODEC> simple8b_codec() {
140-
return std::make_unique<Simple8b<true>>();
146+
return make_unique<Simple8b<true>>();
141147
}
142148
std::unique_ptr<IntegerCODEC> simple8b_rle_codec() {
143-
return std::make_unique<Simple8b_RLE<true>>();
149+
return make_unique<Simple8b_RLE<true>>();
144150
}
145151
#ifdef VARINTG8IU_H__
146152
std::unique_ptr<IntegerCODEC> varintg8iu_codec() {
147-
return std::make_unique<VarIntG8IU>();
153+
return make_unique<VarIntG8IU>();
148154
}
149155
#endif
150156
#ifdef USESNAPPY
151157
std::unique_ptr<IntegerCODEC> snappy_codec() {
152-
return std::make_unique<JustSnappy>();
158+
return make_unique<JustSnappy>();
153159
}
154160
#endif
155161
std::unique_ptr<IntegerCODEC> simdbinarypacking_codec() {
156-
return std::make_unique<CompositeCodec<SIMDBinaryPacking, VariableByte>>();
162+
return make_unique<CompositeCodec<SIMDBinaryPacking, VariableByte>>();
157163
}
158164
std::unique_ptr<IntegerCODEC> simdgroupsimple_codec() {
159-
return std::make_unique<CompositeCodec<SIMDGroupSimple<false, false>, VariableByte>>();
165+
return make_unique<CompositeCodec<SIMDGroupSimple<false, false>, VariableByte>>();
160166
}
161167
std::unique_ptr<IntegerCODEC> simdgroupsimple_ringbuf_codec() {
162-
return std::make_unique<CompositeCodec<SIMDGroupSimple<true, true>, VariableByte>>();
168+
return make_unique<CompositeCodec<SIMDGroupSimple<true, true>, VariableByte>>();
163169
}
164170
std::unique_ptr<IntegerCODEC> copy_codec() {
165-
return std::make_unique<JustCopy>();
171+
return make_unique<JustCopy>();
166172
}
167173

168174
static CodecMap initializefactory() {

0 commit comments

Comments
 (0)