Is the following code supposed to compile?
#include <type_traits>
void foo() {
const std::pair<int, int> x = {1, 2};
auto [a, b] = x;
static_assert(std::is_const_v<decltype(a)>);
static_assert(std::is_const_v<decltype(b)>);
}
So, is this an MSVC bug?
The standard is not straightforward here (I had a quick look), but considering the rules for auto
, I suppose, a
and b
should be copied discarding cv-qualifier.