I have following C++ code snippet :
inline std::vector<std::unique_ptr<xir::Tensor>> cloneTensorBuffer(
const std::vector<const xir::Tensor*>& tensors)
{
auto ret = std::vector<std::unique_ptr<xir::Tensor>>{};
auto type = +::DataType::XINT;
ret.reserve(tensors.size());
for (const auto& tensor : tensors) {
ret.push_back(std::unique_ptr<xir::Tensor>(xir::Tensor::create(
tensor->get_name(), tensor->get_shape(), xir::DataType{type, 8u})));
}
return ret;
}
I am not clear about the statement:
auto type = +::DataType::XINT;
What is meant by + followed by ::(scope resolution operator)?
The combination has no special meaning.
+is the regular prefix operator. In this particular case it’s probably redundant, or performs coercion toint. However, the actual meaning might differ depending on how it’s overloaded for the type of::DataType::XINT.And
::is regular scope resolution operator. When used at the beginning of a sub-expression (i.e. without a left-hand operand), it causes lookup to be performed at the top scope, i.e. it ignores any shadowing redefinition ofDataTypein a nested scope: