2
0
mirror of https://github.com/boostorg/locale.git synced 2026-01-19 04:22:08 +00:00

Make try_to_int a template

This commit is contained in:
Alexander Grund
2024-12-30 12:37:24 +01:00
parent 258e959402
commit 8cc6f42fd4
2 changed files with 5 additions and 5 deletions

View File

@@ -64,10 +64,9 @@ namespace boost { namespace locale { namespace detail {
{
if(key.empty())
return;
int position;
if(util::try_to_int(key, position) && position > 0) {
static_assert(sizeof(unsigned) <= sizeof(decltype(d->position)), "Possible lossy conversion");
d->position = static_cast<unsigned>(position - 1);
decltype(d->position) position;
if(util::try_to_int(key, position) && position > 0u) {
d->position = position - 1u;
} else if(key == "num" || key == "number") {
as::number(ios_);

View File

@@ -13,7 +13,8 @@
namespace boost { namespace locale { namespace util {
bool try_to_int(const string_view s, int value)
template<typename Integer>
bool try_to_int(const string_view s, Integer& value)
{
if(s.empty())
return false;