【发布时间】:2020-02-21 12:35:23
【问题描述】:
static const auto compare = [](const std::string& now, const std::string& next) noexcept ->bool
{
return now.size() == next.size() ? now < next : now.size() < next.size();
};
我在 Hacker 等级上看到了这段代码,但我不明白它是如何工作的。
第一季度。为什么这个人使用 static const auto 和 const std::string Q2。这是什么意思 ? Q3。为什么是字符串&?不是字符串 Q4。 noexcept -> bool 是什么意思?
任何 cmets 将不胜感激!
【问题讨论】:
-
这是一个lambda表达式en.cppreference.com/w/cpp/language/lambda
标签: c++ static constants grammar noexcept