Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] 新版 C++ 特性页面中的代码修改 #2560

Closed
1 task done
zhb2000 opened this issue Aug 16, 2020 · 1 comment · Fixed by #2561
Closed
1 task done

[BUG] 新版 C++ 特性页面中的代码修改 #2560

zhb2000 opened this issue Aug 16, 2020 · 1 comment · Fixed by #2561
Labels
Content Bug / 页面内容有误 Something isn't working help wanted / 需要帮助 Extra attention is needed

Comments

@zhb2000
Copy link
Contributor

zhb2000 commented Aug 16, 2020

  • 我正在着手修复这个问题

我正在访问这个页面(最好带链接)

新版 C++ 特性

我发现页面有这样的问题

“可变参数模板的应用”一节中

template <typename T>
ostream& operator<<(ostream& os, vector<T> V) {
  os << "[ ";
  for (auto vv : V) os << vv << ", ";
  os << "]";
  return os;
}

此处的 vector<T> V 改为 const vector<T>& Vauto vv 改为 const auto& vv 较好,可避免不必要的拷贝。

修改后的代码如下所示。

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& V) {
  os << "[ ";
  for (const auto& vv : V) os << vv << ", ";
  os << "]";
  return os;
}
@zhb2000 zhb2000 added Content Bug / 页面内容有误 Something isn't working help wanted / 需要帮助 Extra attention is needed labels Aug 16, 2020
@welcome
Copy link

welcome bot commented Aug 16, 2020

感谢你对 OI Wiki 的关注!记得在 Issue 中表达清楚自己的意思哦~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content Bug / 页面内容有误 Something isn't working help wanted / 需要帮助 Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant