Skip to content

Commit

Permalink
Document _to_index, _from_index, etc.
Browse files Browse the repository at this point in the history
Follow-on to #59.

[skip ci]
  • Loading branch information
aantron committed Oct 19, 2020
1 parent f480b7e commit c730fc8
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions doc/ApiReference.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,34 @@ constants.



### Index lookup

#### member constexpr std::size_t <em>_to_index</em>() const

Returns the index of a Better Enum value within its enum declaration. The index
is determined from the value only; if two constants in the declaration have the
same value, this function may return the index of either constant.

If the value does not correspond to any constant in the declaration (for
example, if it was obtained using an unchecked conversion or a cast), then the
behavior of `value._to_index` is undefined.

#### static constexpr Enum <em>_from_index</em>(size_t)

Returns the value of the constant with the given index. Throws
`std::runtime_error` if not given the index of one of the constants.

#### static constexpr Enum <em>_from_index_unchecked</em>(size_t)

Returns the value of the constant with the given index. If not given one of the
constants in the declaration of the enum, the returned value is undefined.

#### static constexpr optional<Enum> <em>_from_index_nothrow</em>(size_t)

Returns the value of the constant with the given index.



### Stream operators

#### non-member std::ostream& <em>operator <<</em>(std::ostream&, const Enum&)
Expand Down

0 comments on commit c730fc8

Please sign in to comment.