Arrays and Rvalues (as parameters)

為{幸葍}努か 提交于 2019-12-04 04:47:59

There is nothing wrong with foo_array. It's the test case that is bad: "hello" is an lvalue! Think about it. It is not a temporary: string literals have static storage duration.

An array rvalue would be something like this:

template <typename T>
using alias = T;
// you need this thing because char[23]{} is not valid...

foo_array(alias<char[23]> {});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!