Skip to content

Commit b0c18de

Browse files
committed
Use c++11 features only
1 parent 8160e42 commit b0c18de

13 files changed

Lines changed: 432 additions & 434 deletions

Doxyfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,7 @@ INPUT = common/include \
955955
fi/include \
956956
count/include \
957957
req/include \
958+
ddsketch/include \
958959
README.md
959960

960961
# This tag can be used to specify the character encoding of the source files

ddsketch/include/dense_store_impl.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727

2828
namespace datasketches {
2929

30+
template<typename Store, typename Allocator>
31+
constexpr int DenseStore<Store, Allocator>::DEFAULT_ARRAY_LENGTH_GROWTH_INCREMENT;
32+
3033
template<class Derived, typename Allocator>
3134
DenseStore<Derived, Allocator>::DenseStore() :
3235
DenseStore(DEFAULT_ARRAY_LENGTH_GROWTH_INCREMENT)

ddsketch/include/index_mapping_factory.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class index_mapping_factory {
3030
template<typename... Args>
3131
static std::unique_ptr<IndexMapping> new_mapping(Args&&... args)
3232
{
33-
return std::unique_ptr<IndexMapping>();
33+
return std::unique_ptr<IndexMapping>(new IndexMapping(std::forward<Args>(args)...));
3434
}
3535
};
3636
}

ddsketch/include/linearly_interpolated_mapping.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ class LinearlyInterpolatedMapping : public LogLikeIndexMapping<LinearlyInterpola
5555

5656
IndexMappingLayout layout() const;
5757

58-
static constexpr double BASE = 2.0;
59-
static constexpr double CORRECTING_FACTOR = 1.44269504088896340735;
58+
static constexpr double BASE() { return 2.0; }
59+
static constexpr double CORRECTING_FACTOR() { return 1.44269504088896340735; }
6060

6161
private:
6262
static double index_offset_shift(const double& relative_accuracy);

ddsketch/include/linearly_interpolated_mapping_impl.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,8 @@
2222

2323
namespace datasketches {
2424

25-
constexpr double LinearlyInterpolatedMapping::BASE;
26-
constexpr double LinearlyInterpolatedMapping::CORRECTING_FACTOR;
27-
2825
inline LinearlyInterpolatedMapping::LinearlyInterpolatedMapping(const double& relative_accuracy):
29-
LogLikeIndexMapping<LinearlyInterpolatedMapping>(compute_gamma(require_valid_relative_accuracy(relative_accuracy), CORRECTING_FACTOR), index_offset_shift(relative_accuracy)) {}
26+
LogLikeIndexMapping<LinearlyInterpolatedMapping>(compute_gamma(require_valid_relative_accuracy(relative_accuracy), CORRECTING_FACTOR()), index_offset_shift(relative_accuracy)) {}
3027

3128
inline LinearlyInterpolatedMapping::LinearlyInterpolatedMapping(const double& gamma, const double& index_offset):
3229
LogLikeIndexMapping<LinearlyInterpolatedMapping>(gamma, index_offset) {}

ddsketch/include/log_like_index_mapping.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class LogLikeIndexMapping : public IndexMapping<Derived> {
104104
bool operator!=(const LogLikeIndexMapping<Derived>& other) const;
105105

106106
private:
107-
static double compute_relative_accuracy(const double& gamma, const double& correcting_factor);
107+
static double compute_relative_accuracy(const double gamma, const double correcting_factor);
108108
static double require_valid_gamma(const double& gamma);
109109
IndexMappingLayout layout() const;
110110

ddsketch/include/log_like_index_mapping_impl.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ template<class Derived>
2929
LogLikeIndexMapping<Derived>::LogLikeIndexMapping(const double& gamma, const double& index_offset):
3030
gamma(require_valid_gamma(gamma)),
3131
index_offset(index_offset),
32-
relative_accuracy(compute_relative_accuracy(gamma, Derived::CORRECTING_FACTOR)),
33-
multiplier(std::log(Derived::BASE) / std::log1p(gamma - 1)) {}
32+
relative_accuracy(compute_relative_accuracy(gamma, Derived::CORRECTING_FACTOR())),
33+
multiplier(std::log(Derived::BASE()) / std::log1p(gamma - 1)) {}
3434

3535
template<class Derived>
36-
double LogLikeIndexMapping<Derived>::compute_relative_accuracy(const double& gamma, const double& correcting_factor) {
36+
double LogLikeIndexMapping<Derived>::compute_relative_accuracy(const double gamma, const double correcting_factor) {
3737
const double exact_log_gamma = std::pow(gamma, correcting_factor);
3838
return (exact_log_gamma - 1) / (exact_log_gamma + 1);
3939
}
@@ -89,14 +89,14 @@ double LogLikeIndexMapping<Derived>::get_relative_accuracy() const {
8989

9090
template<class Derived>
9191
double LogLikeIndexMapping<Derived>::min_indexable_value() const {
92-
const double& a = std::pow(Derived::BASE, (static_cast<double>(std::numeric_limits<int>::min()) - index_offset) / multiplier + 1);
92+
const double& a = std::pow(Derived::BASE(), (static_cast<double>(std::numeric_limits<int>::min()) - index_offset) / multiplier + 1);
9393
const double& b = std::numeric_limits<double>::min() * (1 + relative_accuracy) / (1 - relative_accuracy);
9494
return std::max(a, b);
9595
}
9696

9797
template<class Derived>
9898
double LogLikeIndexMapping<Derived>::max_indexable_value() const {
99-
const double& a = std::pow(Derived::BASE, (static_cast<double>(std::numeric_limits<int>::max()) - index_offset) / multiplier - 1);
99+
const double& a = std::pow(Derived::BASE(), (static_cast<double>(std::numeric_limits<int>::max()) - index_offset) / multiplier - 1);
100100
const double& b = std::numeric_limits<double>::max() / (1 + relative_accuracy);
101101
return std::min(a, b);
102102
}

ddsketch/include/logarithmic_mapping.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ class LogarithmicMapping : public LogLikeIndexMapping<LogarithmicMapping> {
5555

5656
IndexMappingLayout layout() const;
5757

58-
static constexpr double BASE = 2.71828182845904523536;
59-
static constexpr double CORRECTING_FACTOR = 1.0;
58+
static constexpr double BASE() { return 2.71828182845904523536; }
59+
static constexpr double CORRECTING_FACTOR() { return 1.0; }
6060
};
6161
}
6262

ddsketch/include/logarithmic_mapping_impl.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#include "logarithmic_mapping.hpp"
2323

2424
namespace datasketches {
25-
constexpr double LogarithmicMapping::BASE;
26-
constexpr double LogarithmicMapping::CORRECTING_FACTOR;
2725

2826
inline LogarithmicMapping::LogarithmicMapping(const double& relative_accuracy) :
2927
LogLikeIndexMapping<LogarithmicMapping>(compute_gamma(require_valid_relative_accuracy(relative_accuracy), 1.0), 0.0) {}

ddsketch/include/quadratically_interpolated_mapping.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ class QuadraticallyInterpolatedMapping : public LogLikeIndexMapping<Quadraticall
5454

5555
IndexMappingLayout layout() const;
5656

57-
static constexpr double BASE = 2.0;
58-
static constexpr double CORRECTING_FACTOR = 3.0 / (4.0 * 0.69314718055994530941);
57+
static constexpr double BASE() { return 2.0; }
58+
static constexpr double CORRECTING_FACTOR() { return 3.0 / (4.0 * 0.69314718055994530941); }
5959

6060
private:
61-
static constexpr double ONE_THIRD = 1.0 / 3.0;
61+
static constexpr double ONE_THIRD() { return 1.0 / 3.0; }
6262
};
6363
}
6464
#endif //QUADRATICALLY_INTERPOLATED_MAPPING_HPP

0 commit comments

Comments
 (0)