-
Notifications
You must be signed in to change notification settings - Fork 441
Open
Description
Take the function iox::runtime::IpcRuntimeInterface::create() as an example.
expected<IpcRuntimeInterface, IpcRuntimeInterfaceError> IpcRuntimeInterface::create(const RuntimeName_t& runtimeName, const DomainId domainId, const units::Duration roudiWaitingTimeout) noexcept
{
if (runtimeName.empty())
{
IOX_LOG(Debug, "The runtime name must not be empty!");
return err(IpcRuntimeInterfaceError::CANNOT_CREATE_APPLICATION_CHANNEL);
}
MgmtShmCharacteristics mgmtShmCharacteristics;
auto roudiIpcInterface = IpcInterfaceUser(roudi::IPC_CHANNEL_ROUDI_NAME, domainId, ResourceType::ICEORYX_DEFINED);
auto appIpcInterface = IpcInterfaceCreator::create(runtimeName, domainId, ResourceType::USER_DEFINED);
if (appIpcInterface.has_error() || !appIpcInterface->isInitialized())
{
return err(IpcRuntimeInterfaceError::CANNOT_CREATE_APPLICATION_CHANNEL);
}
deadline_timer timer(roudiWaitingTimeout);
We can see local variable defined like this:
// since C++17, a prvalue is directly constructed into the storage of its final destination
auto roudiIpcInterface = IpcInterfaceUser(roudi::IPC_CHANNEL_ROUDI_NAME, domainId, ResourceType::ICEORYX_DEFINED);
// direct initialization
deadline_timer timer(roudiWaitingTimeout);
As far as I know, since C++17, auto roudiIpcInterface = IpcInterfaceUser(roudi::IPC_CHANNEL_ROUDI_NAME, domainId, ResourceType::ICEORYX_DEFINED);
is the same as IpcInterfaceUser roudiIpcInterface(roudi::IPC_CHANNEL_ROUDI_NAME, domainId, ResourceType::ICEORYX_DEFINED);
. (Is that correct? Please correct me if I'm wrong)
So why we mix the two styles here? What makes us choose to use the first style when initializing roudiIpcInterface
and the second style when initializing the timer
?
Metadata
Metadata
Assignees
Labels
No labels