mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-14 18:32:29 +00:00
ea84430864
http://eel.is/c++draft/class.copy.elision#:constructor,copy,elision Some quote: > Speaking of RVO, return std::move(w); prohibits it. It means "use move constructor or fail to compile", whereas return w; means "use RVO, and if you can't, use move constructor, and if you can't, use copy constructor, and if you can't, fail to compile." There is one exception to this rule: ```cpp Block FilterBlockInputStream::removeFilterIfNeed(Block && block) { if (block && remove_filter) block.erase(static_cast<size_t>(filter_column)); return std::move(block); } ``` because references are not eligible for NRVO, which is another rule "always move rvalue references and forward universal references" that takes precedence.
43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
#include <Parsers/ASTExpressionList.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
ASTPtr ASTExpressionList::clone() const
|
|
{
|
|
auto clone = std::make_shared<ASTExpressionList>(*this);
|
|
clone->cloneChildren();
|
|
return clone;
|
|
}
|
|
|
|
void ASTExpressionList::formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
|
|
{
|
|
for (ASTs::const_iterator it = children.begin(); it != children.end(); ++it)
|
|
{
|
|
if (it != children.begin())
|
|
settings.ostr << ", ";
|
|
|
|
(*it)->formatImpl(settings, state, frame);
|
|
}
|
|
}
|
|
|
|
void ASTExpressionList::formatImplMultiline(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
|
|
{
|
|
std::string indent_str = "\n" + std::string(4 * (frame.indent + 1), ' ');
|
|
|
|
++frame.indent;
|
|
for (ASTs::const_iterator it = children.begin(); it != children.end(); ++it)
|
|
{
|
|
if (it != children.begin())
|
|
settings.ostr << ", ";
|
|
|
|
if (children.size() > 1)
|
|
settings.ostr << indent_str;
|
|
|
|
(*it)->formatImpl(settings, state, frame);
|
|
}
|
|
}
|
|
|
|
}
|