Почему MSVC не позволяет мне индексировать этот массив в постоянной функции?C++

Программы на C++. Форум разработчиков
Anonymous
Почему MSVC не позволяет мне индексировать этот массив в постоянной функции?

Сообщение Anonymous »

Это компилируется на Clang и GCC, но не MSVC: < /p>
#include
#include
#include
#include

template
struct BitfieldBits
{
constexpr static inline uint64_t num_bits = N;
};

struct DepthMode : BitfieldBits
{};
struct UseCulling : BitfieldBits
{};
struct VertexShaderID : BitfieldBits
{};

template
struct MyBitfield
{
uint64_t bitfield;

static inline std::tuple tuple;

constexpr static inline std::array bit_shift_offsets = [](const std::tuple& tuple) consteval
{

constexpr uint32_t tuple_size = std::tuple_size_v;

std::array arr;

uint32_t bit_offset = 0;

for (size_t i = 0; i < tuple_size; ++i)
{

arr = bit_offset;

// HERE MSVC DOESN'T COMPILE
bit_offset += std::get(tuple).num_bits;
}

return arr;

}(std::tuple());

};

int main(int argc, char* argv[])
{

MyBitfield my_bitfield;

}
< /code>
Вот ссылка Godbolt, показывающая все три компилятора.>

Подробнее здесь: https://stackoverflow.com/questions/796 ... l-function

Вернуться в «C++»