Skip to content

Commit

Permalink
Use std::optional and std::make_unique in favor of absl::* in C++
Browse files Browse the repository at this point in the history
Change-Id: Ia6bdcdd058d7aeb8e17e71a20c5c4e86a003c58a
GitOrigin-RevId: 549aaa2bf32936824b027b2481d710eb801cb6d8
  • Loading branch information
Differential Privacy Team authored and miracvbasaran committed Jun 6, 2024
1 parent 6bc750c commit 05cd41f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions cc/algorithms/bounded-sum.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <algorithm>
#include <cmath>
#include <cstdint>
#include <limits>
#include <memory>
#include <optional>
Expand Down Expand Up @@ -476,14 +477,14 @@ class BoundedSum<T>::Builder {
}

private:
absl::optional<double> epsilon_;
std::optional<double> epsilon_;
double delta_ = 0;
absl::optional<T> upper_;
absl::optional<T> lower_;
std::optional<T> upper_;
std::optional<T> lower_;
int max_partitions_contributed_ = 1;
int max_contributions_per_partition_ = 1;
std::unique_ptr<NumericalMechanismBuilder> mechanism_builder_ =
absl::make_unique<LaplaceMechanism::Builder>();
std::make_unique<LaplaceMechanism::Builder>();
std::unique_ptr<ApproxBounds<T>> approx_bounds_;

absl::StatusOr<std::unique_ptr<BoundedSum<T>>> BuildSumWithFixedBounds() {
Expand All @@ -495,7 +496,7 @@ class BoundedSum<T>::Builder {
upper_.value()));

return absl::StatusOr<std::unique_ptr<BoundedSum<T>>>(
absl::make_unique<BoundedSumWithFixedBounds<T>>(
std::make_unique<BoundedSumWithFixedBounds<T>>(
epsilon_.value(), delta_, lower_.value(), upper_.value(),
std::move(mechanism)));
}
Expand All @@ -520,7 +521,7 @@ class BoundedSum<T>::Builder {
}

return absl::StatusOr<std::unique_ptr<BoundedSum<T>>>(
absl::make_unique<BoundedSumWithApproxBounds<T>>(
std::make_unique<BoundedSumWithApproxBounds<T>>(
epsilon_.value(), delta_, max_partitions_contributed_,
max_contributions_per_partition_, mechanism_builder_->Clone(),
std::move(approx_bounds_)));
Expand Down

0 comments on commit 05cd41f

Please sign in to comment.