Even more concisely, you can use list initialization.
- in a return statement with braced-init-list used as the return expression and list-initialization initializes the returned object
std::vector<int> foo(int a, int b)
{
return {a, b};
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…