(Hopefully last fix) _from_index will now take std::size_t

This commit is contained in:
Piotr Kosek 2018-08-31 17:56:56 +02:00
parent db287125b5
commit f044492ae8

18
enum.h
View File

@ -624,12 +624,12 @@ class Enum { \
\
BETTER_ENUMS_CONSTEXPR_ std::size_t _to_index() const; \
BETTER_ENUMS_IF_EXCEPTIONS( \
BETTER_ENUMS_CONSTEXPR_ static Enum _from_index(_integral value); \
BETTER_ENUMS_CONSTEXPR_ static Enum _from_index(std::size_t value); \
) \
BETTER_ENUMS_CONSTEXPR_ static Enum \
_from_index_unchecked(_integral value); \
_from_index_unchecked(std::size_t value); \
BETTER_ENUMS_CONSTEXPR_ static _optional \
_from_index_nothrow(_integral value); \
_from_index_nothrow(std::size_t value); \
\
ToStringConstexpr const char* _to_string() const; \
BETTER_ENUMS_IF_EXCEPTIONS( \
@ -759,23 +759,23 @@ BETTER_ENUMS_CONSTEXPR_ inline std::size_t Enum::_to_index() const \
} \
\
BETTER_ENUMS_CONSTEXPR_ inline Enum \
Enum::_from_index_unchecked(_integral value) \
Enum::_from_index_unchecked(std::size_t index) \
{ \
return \
::better_enums::_or_zero(_from_index_nothrow(value)); \
::better_enums::_or_zero(_from_index_nothrow(index)); \
} \
\
BETTER_ENUMS_CONSTEXPR_ inline Enum::_optional \
Enum::_from_index_nothrow(_integral value) \
Enum::_from_index_nothrow(std::size_t index) \
{ \
return _from_index_loop(value); \
return _from_index_loop(index); \
} \
\
BETTER_ENUMS_IF_EXCEPTIONS( \
BETTER_ENUMS_CONSTEXPR_ inline Enum Enum::_from_index(_integral value) \
BETTER_ENUMS_CONSTEXPR_ inline Enum Enum::_from_index(std::size_t index) \
{ \
return \
::better_enums::_or_throw(_from_index_nothrow(value), \
::better_enums::_or_throw(_from_index_nothrow(index), \
#Enum "::_from_index: invalid argument"); \
} \
) \