Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit b491363

Browse files
committed
Modify IPS4O to be C++11 compliant
1 parent 31e6b49 commit b491363

File tree

5 files changed

+38
-1
lines changed

5 files changed

+38
-1
lines changed

test/codegen/oa_hash_table_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include <unordered_map>
14+
#include <random>
1415

1516
#include "common/harness.h"
1617

third_party/ips4o/ips4o/buffers.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,14 @@ class Sorter<Cfg>::Block {
128128
}
129129

130130
private:
131+
#if __cplusplus==201402L
131132
using storage_type = std::conditional_t<kInitializedStorage, value_type,
132133
std::aligned_storage_t<sizeof(value_type), alignof(value_type)>>;
134+
#else
135+
// pmenon: Modified for C++11
136+
using storage_type = typename std::conditional<kInitializedStorage, value_type,
137+
typename std::aligned_storage<sizeof(value_type), alignof(value_type)>::type>::type;
138+
#endif
133139
storage_type storage_[Cfg::kBlockSize];
134140
};
135141

third_party/ips4o/ips4o/classifier.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,20 @@ class Sorter<Cfg>::Classifier {
207207
}
208208

209209
// Filled from 1 to num_buckets_
210+
#if __cplusplus==201402L
210211
std::aligned_storage_t<sizeof(value_type), alignof(value_type)> storage_[Cfg::kMaxBuckets / 2];
212+
#else
213+
// pmenon: Modified for C++11
214+
typename std::aligned_storage<sizeof(value_type), alignof(value_type)>::type storage_[Cfg::kMaxBuckets / 2];
215+
#endif
211216
// Filled from 0 to num_buckets_, last one is duplicated
217+
#if __cplusplus==201402L
212218
std::aligned_storage_t<sizeof(value_type), alignof(value_type)> sorted_storage_[Cfg::kMaxBuckets / 2];
219+
#else
220+
// pmenon: Modified for C++11
221+
typename std::aligned_storage<sizeof(value_type), alignof(value_type)>::type sorted_storage_[Cfg::kMaxBuckets / 2];
222+
#endif
223+
213224
int log_buckets_ = 0;
214225
bucket_type num_buckets_ = 0;
215226
less comp_;

third_party/ips4o/ips4o/config.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,15 @@ struct Config {
160160
* The oversampling factor to be used for input of size n.
161161
*/
162162
static constexpr double oversamplingFactor(std::ptrdiff_t n) {
163-
const double f = OversampleF_ / 100.0 * detail::log2(n);
163+
#if __cplusplus==201402L
164+
constexpr double f = OversampleF_ / 100.0 * detail::log2(n);
164165
return f < 1.0 ? 1.0 : f;
166+
#else
167+
// pmenon: Modified for C++11
168+
#define f (OversampleF_ / 100.0 * detail::log2(n))
169+
return f < 1.0 ? 1.0 : f;
170+
#undef f
171+
#endif
165172
}
166173

167174
/**

third_party/ips4o/ips4o/ips4o.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,25 @@ namespace ips4o {
5151
/**
5252
* Helper function for creating a reusable sequential sorter.
5353
*/
54+
#if __cplusplus==201402L
5455
template <class It, class Cfg = Config<>, class Comp = std::less<>>
56+
#else
57+
// pmenon: Modified for C++11
58+
template <class It, class Cfg = Config<>, class Comp>
59+
#endif
5560
SequentialSorter<ExtendedConfig<It, Comp, Cfg>> make_sorter(Comp comp = Comp()) {
5661
return SequentialSorter<ExtendedConfig<It, Comp, Cfg>>{std::move(comp)};
5762
}
5863

5964
/**
6065
* Configurable interface.
6166
*/
67+
#if __cplusplus==201402L
6268
template <class Cfg, class It, class Comp = std::less<>>
69+
#else
70+
// pmenon: Modified for C++11
71+
template <class Cfg, class It, class Comp>
72+
#endif
6373
void sort(It begin, It end, Comp comp = Comp()) {
6474
if ((end - begin) <= Cfg::kBaseCaseMultiplier * Cfg::kBaseCaseSize)
6575
detail::baseCaseSort(std::move(begin), std::move(end), std::move(comp));
@@ -75,10 +85,12 @@ void sort(It begin, It end, Comp comp) {
7585
ips4o::sort<Config<>>(std::move(begin), std::move(end), std::move(comp));
7686
}
7787

88+
#if 0
7889
template <class It>
7990
void sort(It begin, It end) {
8091
ips4o::sort<Config<>>(std::move(begin), std::move(end), std::less<>());
8192
}
93+
#endif
8294

8395
#if defined(_REENTRANT) || defined(_OPENMP)
8496
namespace parallel {

0 commit comments

Comments
 (0)