mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 07:54:58 +00:00
AK: Generalize AK::String::to_int() for more types
This commit is contained in:
parent
39364bdda4
commit
37df4bbd90
8 changed files with 93 additions and 24 deletions
|
@ -222,16 +222,28 @@ StringView StringView::substring_view_starting_after_substring(const StringView&
|
|||
return { remaining_characters, remaining_length };
|
||||
}
|
||||
|
||||
Optional<int> StringView::to_int() const
|
||||
template<typename T>
|
||||
Optional<T> StringView::to_int() const
|
||||
{
|
||||
return StringUtils::convert_to_int(*this);
|
||||
return StringUtils::convert_to_int<T>(*this);
|
||||
}
|
||||
|
||||
Optional<unsigned> StringView::to_uint() const
|
||||
template Optional<i8> StringView::to_int() const;
|
||||
template Optional<i16> StringView::to_int() const;
|
||||
template Optional<i32> StringView::to_int() const;
|
||||
template Optional<i64> StringView::to_int() const;
|
||||
|
||||
template<typename T>
|
||||
Optional<T> StringView::to_uint() const
|
||||
{
|
||||
return StringUtils::convert_to_uint(*this);
|
||||
return StringUtils::convert_to_uint<T>(*this);
|
||||
}
|
||||
|
||||
template Optional<u8> StringView::to_uint() const;
|
||||
template Optional<u16> StringView::to_uint() const;
|
||||
template Optional<u32> StringView::to_uint() const;
|
||||
template Optional<u64> StringView::to_uint() const;
|
||||
|
||||
unsigned StringView::hash() const
|
||||
{
|
||||
if (is_empty())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue