Skip to content

Commit d9ae6b9

Browse files
authored
CPP-999 Compilation error in cpp-driver-2.16.2 when using C++98 standard (#569)
1 parent 86f916f commit d9ae6b9

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/metrics.hpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,11 @@ class Metrics : public Allocated {
271271

272272
Histogram(ThreadState* thread_state, unsigned refresh_interval = CASS_DEFAULT_HISTOGRAM_REFRESH_INTERVAL_NO_REFRESH)
273273
: thread_state_(thread_state)
274-
, histograms_(new PerThreadHistogram[thread_state->max_threads()])
275-
, zero_snapshot_(Snapshot {0,0,0,0,0,0,0,0,0,0}) {
274+
, histograms_(new PerThreadHistogram[thread_state->max_threads()]) {
276275

277276
refresh_interval_ = refresh_interval;
278277
refresh_timestamp_ = get_time_since_epoch_ms();
279-
cached_snapshot_ = zero_snapshot_;
278+
zero_snapshot(&cached_snapshot_);
280279

281280
hdr_init(1LL, HIGHEST_TRACKABLE_VALUE, 3, &histogram_);
282281
uv_mutex_init(&mutex_);
@@ -304,7 +303,7 @@ class Metrics : public Allocated {
304303

305304
if (histogram_->total_count == 0) {
306305
// There is no data; default to 0 for the stats.
307-
copy_snapshot(zero_snapshot_, snapshot);
306+
zero_snapshot(snapshot);
308307
} else {
309308
histogram_to_snapshot(histogram_, snapshot);
310309
}
@@ -324,7 +323,7 @@ class Metrics : public Allocated {
324323
}
325324

326325
if (histogram_->total_count == 0) {
327-
copy_snapshot(zero_snapshot_, &cached_snapshot_);
326+
zero_snapshot(&cached_snapshot_);
328327
} else {
329328
histogram_to_snapshot(histogram_, &cached_snapshot_);
330329
}
@@ -349,6 +348,19 @@ class Metrics : public Allocated {
349348
to->percentile_999th = from.percentile_999th;
350349
}
351350

351+
void zero_snapshot(Snapshot* to) const {
352+
to->min = 0;
353+
to->max = 0;
354+
to->mean = 0;
355+
to->stddev = 0;
356+
to->median = 0;
357+
to->percentile_75th = 0;
358+
to->percentile_95th = 0;
359+
to->percentile_98th = 0;
360+
to->percentile_99th = 0;
361+
to->percentile_999th = 0;
362+
}
363+
352364
void histogram_to_snapshot(hdr_histogram* h, Snapshot* to) const {
353365
to->min = hdr_min(h);
354366
to->max = hdr_max(h);
@@ -457,7 +469,6 @@ class Metrics : public Allocated {
457469
unsigned refresh_interval_;
458470
mutable uint64_t refresh_timestamp_;
459471
mutable Snapshot cached_snapshot_;
460-
const Snapshot zero_snapshot_;
461472

462473
private:
463474
DISALLOW_COPY_AND_ASSIGN(Histogram);

0 commit comments

Comments
 (0)