Size: a a a

2021 February 16

DP

Denis Paukaev in supapro.cxx
Liber Azerate
Нет, у scoped enum всё же ещё с 11-го стандарта неявный underlying type int
разве?
источник

AF

Aidar Fattakhov in supapro.cxx
Denis Paukaev
разве?
да но это на область значений никак не влияет
источник

AF

Aidar Fattakhov in supapro.cxx
underlaying type это просто параметр который позволяет достать какойто тип
источник

LA

Liber Azerate in supapro.cxx
Ну ладно, укажу явно значит
источник

DP

Denis Paukaev in supapro.cxx
хм, ну в старом энаме работало

enum StrongInt {
   A = -1ULL,
};
источник

CD

Constantine Drozdov in supapro.cxx
Aidar Fattakhov
это неважно
For an enumeration whose underlying type is fixed, the values of the enumeration are the values of the underlying type.
Otherwise, the values of the enumeration are the values representable by a hypothetical integer type with minimal width M such that all enumerators can be represented.
The width of the smallest bit-field large enough to hold all the values of the enumeration type is M.
It is possible to define an enumeration that has values not defined by any of its enumerators.
If the enumerator-list is empty, the values of the enumeration are as if the enumeration had a single enumerator with value 0.
источник

CD

Constantine Drozdov in supapro.cxx
чего тебе непонятного вообще
источник

DP

Denis Paukaev in supapro.cxx
а с

enum class StrongInt {
   A = -1ULL,
};


error: enumerator value evaluates to 18446744073709551615, which cannot be narrowed to type 'int' [-Wc++11-narrowing]
источник

AF

Aidar Fattakhov in supapro.cxx
Constantine Drozdov
чего тебе непонятного вообще
источник

CD

Constantine Drozdov in supapro.cxx
важно, написано : int или нет
источник

AF

Aidar Fattakhov in supapro.cxx
тред перечитай
источник

LA

Liber Azerate in supapro.cxx
Constantine Drozdov
For an enumeration whose underlying type is fixed, the values of the enumeration are the values of the underlying type.
Otherwise, the values of the enumeration are the values representable by a hypothetical integer type with minimal width M such that all enumerators can be represented.
The width of the smallest bit-field large enough to hold all the values of the enumeration type is M.
It is possible to define an enumeration that has values not defined by any of its enumerators.
If the enumerator-list is empty, the values of the enumeration are as if the enumeration had a single enumerator with value 0.
Ну это говорит, что мне всё же легально кастовать без явного : int, нет?
источник

CD

Constantine Drozdov in supapro.cxx
Aidar Fattakhov
тред перечитай
перечитал
источник

CD

Constantine Drozdov in supapro.cxx
источник

SS

Sergey Skvortsov in supapro.cxx
Liber Azerate
Ну это говорит, что мне всё же легально кастовать без явного : int, нет?
Легально, если ты кастом попал в значение enuma
Иначе смерть гроб кладбище
http://eel.is/c++draft/expr.static.cast#10
источник

LA

Liber Azerate in supapro.cxx
Sergey Skvortsov
Легально, если ты кастом попал в значение enuma
Иначе смерть гроб кладбище
http://eel.is/c++draft/expr.static.cast#10
Так я об этом и говорил, что "если попасть"
источник

SS

Sergey Skvortsov in supapro.cxx
Если попал, то молодец
источник

DP

Denis Paukaev in supapro.cxx
Constantine Drozdov
For an enumeration whose underlying type is fixed, the values of the enumeration are the values of the underlying type.
Otherwise, the values of the enumeration are the values representable by a hypothetical integer type with minimal width M such that all enumerators can be represented.
The width of the smallest bit-field large enough to hold all the values of the enumeration type is M.
It is possible to define an enumeration that has values not defined by any of its enumerators.
If the enumerator-list is empty, the values of the enumeration are as if the enumeration had a single enumerator with value 0.
перечитал, сходу не пойму к чему тут otherwise относится, если к случаю "underlying type is not fixed", то оно абзацем выше рассматривается, а больше и не вижу вариантов
источник

CD

Constantine Drozdov in supapro.cxx
Denis Paukaev
перечитал, сходу не пойму к чему тут otherwise относится, если к случаю "underlying type is not fixed", то оно абзацем выше рассматривается, а больше и не вижу вариантов
ну если задан явно, то в точности underlying, иначе из underlying доступно ровно столько битов, сколько нужно для заявленных значений
источник

DP

Denis Paukaev in supapro.cxx
Constantine Drozdov
ну если задан явно, то в точности underlying, иначе из underlying доступно ровно столько битов, сколько нужно для заявленных значений
Each enumeration defines a type that is different from all other types. Each enumeration also has an underlying type. The underlying type can be explicitly specified using an enum-base. For a scoped enumeration type, the underlying type is int if it is not explicitly specified. In both of these cases, the underlying type is said to be fixed.
источник