Для справки я использую следующие определения типов:
typedef bool Bool;
typedef std::monostate Empty;
template using TupleT = std::tuple;
template struct VariantT {
static_assert(sizeof...(Types) > 0, "VariantT must have at least one type");
std::uint8_t tag;
std::aligned_union_t value;
};
< /code>
Когда я определяю следующие рекурсивные типы: < /p>
struct ConsBool;
struct ConsListBool;
struct Nil;
typedef VariantT ListBool;
typedef VariantT ListListBool;
struct ConsBool
{
using type = TupleT;
type value;
};
struct ConsListBool
{
using type = TupleT;
type value;
};
struct Nil
{
Empty value;
};
< /code>
"Ошибка: неверное применение« sizeof »к неполному типу« ноль »
Но когда я использую альтернативный порядок: < /p>
struct Nil;
struct ConsBool;
struct ConsListBool;
typedef VariantT ListBool;
typedef VariantT ListListBool;
struct Nil
{
Empty value;
};
struct ConsBool
{
using type = TupleT;
type value;
};
struct ConsListBool
{
using type = TupleT;
type value;
};
< /code>
это компилируется. Почему это? А какая логика заказа? Я использую GCC (Debian 12.2.0-14) 12.2.0
Подробнее здесь: https://stackoverflow.com/questions/793 ... reordering