#define BABELTRACE_CPP_COMMON_BT2_COMPONENT_PORT_HPP
#include <cstdint>
-#include <string>
#include <babeltrace2/babeltrace.h>
}
Port operator[](std::uint64_t index) const noexcept;
- Port operator[](const char *name) const noexcept;
- Port operator[](const std::string& name) const noexcept;
+ OptionalBorrowedObject<Port> operator[](bt2c::CStringView name) const noexcept;
Iterator begin() const noexcept;
Iterator end() const noexcept;
};
}
template <typename LibCompT, typename LibPortT>
-typename ConstComponentPorts<LibCompT, LibPortT>::Port
-ConstComponentPorts<LibCompT, LibPortT>::operator[](const char * const name) const noexcept
-{
- return Port {_Spec::portByName(this->libObjPtr(), name)};
-}
-
-template <typename LibCompT, typename LibPortT>
-typename ConstComponentPorts<LibCompT, LibPortT>::Port
-ConstComponentPorts<LibCompT, LibPortT>::operator[](const std::string& name) const noexcept
+OptionalBorrowedObject<typename ConstComponentPorts<LibCompT, LibPortT>::Port>
+ConstComponentPorts<LibCompT, LibPortT>::operator[](const bt2c::CStringView name) const noexcept
{
- return (*this)[name.data()];
+ return _Spec::portByName(this->libObjPtr(), name);
}
template <typename LibCompT, typename LibPortT>