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:
@@ -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_);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user