[英]What does ->std::ostream& mean?
Here is the part of codes that i cannot understand.This is a func definition. 这是我无法理解的代码部分,这是一个func定义。
using sPtr = std::shared_ptr < std::vector<int> >;
auto print(sPtr vec) ->std::ostream&;
what does it mean by -> std::ostream& ? -> std :: ostream&是什么意思? Is it necessary or not ?
是否有必要? In my opinion,
在我看来,
void print (sPtr vec) ;
I am learning CPP5 ch12 now, and the code is from github Mooophy/Cpp-Primer; 我现在正在学习CPP5 ch12,代码来自github Mooophy / Cpp-Primer; Thanks everyone's advice.
感谢大家的建议。
print
is a function taking a sPtr
as an input and returning an std::ostream&
. print
是将sPtr
作为输入并返回std::ostream&
的函数。 The syntax being used was introduced in C++11, and it's called "trailing return type" . 所使用的语法是在C ++ 11中引入的,称为“回程返回类型” 。
The declaration of print
can be rewritten as follows: print
声明可以重写如下:
std::ostream& print(sPtr vec);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.