-
Notifications
You must be signed in to change notification settings - Fork 417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add nostd::make_unique
#3097
Add nostd::make_unique
#3097
Conversation
✅ Deploy Preview for opentelemetry-cpp-api-docs canceled.
|
@@ -49,7 +50,7 @@ class InMemoryMetricExporter final : public sdk::metrics::PushMetricExporter | |||
OTEL_INTERNAL_LOG_ERROR("[In Memory Metric Exporter] Exporting failed, exporter is shutdown"); | |||
return ExportResult::kFailure; | |||
} | |||
data_->Add(std::make_unique<ResourceMetrics>(data)); | |||
data_->Add(opentelemetry::nostd::make_unique<ResourceMetrics>(data)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This opens a whole new can of worms (see CI), because now data_ is a std::shared_ptr
and the code wants to add an nostd::unique_ptr
to it, instead of a std::unique_ptr
.
How about a simpler solution without new nostd helpers, like:
data_->Add(std::unique_ptr<ResourceMetrics>(new ResourceMetrics(data)));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I modified the parameter type of this API but kept std::unique_ptr
in the exported APIs for ABI compatibility.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3097 +/- ##
==========================================
+ Coverage 87.12% 87.86% +0.74%
==========================================
Files 200 195 -5
Lines 6109 5986 -123
==========================================
- Hits 5322 5259 -63
+ Misses 787 727 -60
|
I'm a bit puzzled—why are we reintroducing support for building with GCC 4.8 and C++11 when we've already moved on to supporting C++14 and above? Or may be I am missing something :) |
Instead of reintroducing nostd helpers for code in the sdk already using Let's call it There are 4 lines to fix in the entire code base, so that:
needs to change to
and then very old toolchains will still work. While C++11 is no longer officially supported, we should not break it if it is easy (4 lines) to avoid. @owent would this work for you ? |
Previous discussion on C++11 / C++14: |
Yes, prefer not introducing |
Yes, it works. But I wonder if it's necessary to keep I raised #3098 to replace |
In my understanding, If we change the code in the API to replace nostd with std, the methods signatures will change, breaking the ABI. |
Closed in favor of alternate solution, implemented in #3098 |
Fixes #3096
Changes
nostd::make_unique
For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes