Skip to content

Commit 30743a8

Browse files
committed
BasicFormatString::parse_specifier doesn't need to return an optional
1 parent cd4a85c commit 30743a8

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

fly/types/string/detail/format_string.hpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ class BasicFormatString
6262
* string. If valid, the format parsing context will be advanced to the character after the
6363
* closing brace.
6464
*
65-
* @return If successful, the parsed replacement field. Otherwise, an uninitialized value.
65+
* @return The parsed replacement field.
6666
*/
67-
constexpr std::optional<FormatSpecifier> parse_specifier();
67+
constexpr FormatSpecifier parse_specifier();
6868

6969
/**
7070
* Parse a replacement field for a user-defined type.
@@ -118,9 +118,9 @@ FLY_CONSTEVAL BasicFormatString<CharType, ParameterTypes...>::BasicFormatString(
118118
{
119119
m_context.on_error("Exceeded maximum allowed number of specifiers");
120120
}
121-
else if (auto specifier = parse_specifier(); specifier)
121+
else
122122
{
123-
m_specifiers[m_specifier_count++] = *std::move(specifier);
123+
m_specifiers[m_specifier_count++] = parse_specifier();
124124
}
125125
}
126126
else if (ch == s_right_brace)
@@ -158,8 +158,7 @@ auto BasicFormatString<CharType, ParameterTypes...>::next_specifier()
158158

159159
//==================================================================================================
160160
template <typename CharType, typename... ParameterTypes>
161-
constexpr auto BasicFormatString<CharType, ParameterTypes...>::parse_specifier()
162-
-> std::optional<FormatSpecifier>
161+
constexpr auto BasicFormatString<CharType, ParameterTypes...>::parse_specifier() -> FormatSpecifier
163162
{
164163
// The opening { will have already been consumed, so the starting position is one less.
165164
const auto starting_position = m_context.lexer().position() - 1;

0 commit comments

Comments
 (0)