-
Notifications
You must be signed in to change notification settings - Fork 501
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Linux: debian bookworm, GCC 12.2.0
The nostd::shared_ptr class does not support creation from a std::unique_ptr whereas std::shared_ptr supports that. What missing is a constructor and assignment operator, see (13)
at https://en.cppreference.com/w/cpp/memory/shared_ptr/shared_ptr and (6)
at https://en.cppreference.com/w/cpp/memory/shared_ptr/operator%3D.
This is an issue for my use case since v1.17.0 as the return type of e.g. std::unique_ptr<opentelemetry::sdk::logs::LoggerProvider> LoggerProviderFactory::Create(...)
changed. My fix is to introduce
template <typename T>
opentelemetry::nostd::shared_ptr<T> StdUniqueToNostdShared(std::unique_ptr<T> &&other)
{
return opentelemetry::nostd::shared_ptr<T>{std::shared_ptr<T>{other.release()}};
}
and the use it like
auto logger_provider = StdUniqueToNostdShared(
opentelemetry::sdk::logs::LoggerProviderFactory::Create(std::move(processor), resource));
opentelemetry::logs::Provider::SetLoggerProvider(interface->logger_provider);
or am I doing something wrong?
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working