【发布时间】:2019-12-18 00:42:47
【问题描述】:
我一直在研究 std::span 的最新规范,在 Godbolt 上使用 clang trunk 和 libc++,发现一些构造函数令人困惑。
特别是我发现来自普通旧数组和std::array 的构造函数与其他容器不同。
例如以下代码似乎可以编译:
std::vector<int*> v = {nullptr, nullptr};
std::span<const int* const> s{v};
但事实并非如此:
std::array<int*, 2> a = {nullptr, nullptr};
std::span<const int* const> s{a};
这似乎与the way the constructors are described on cppreference.com 一致,我只是在努力理解为什么会这样。有人能解释一下吗?
【问题讨论】: