mirror of
https://github.com/boostorg/spirit.git
synced 2026-01-19 04:42:11 +00:00
ts_real_policies: Parse directly into output parameter
There is no need to initialize accumulator with zero value before the first call to `parse`, and to use a temporary.
This commit is contained in:
@@ -157,7 +157,7 @@ struct ts_real_policies : boost::spirit::qi::ureal_policies<T>
|
||||
// Thousands separated numbers
|
||||
template <typename Iterator, typename Accumulator>
|
||||
static bool
|
||||
parse_n(Iterator& first, Iterator const& last, Accumulator& attr)
|
||||
parse_n(Iterator& first, Iterator const& last, Accumulator& result)
|
||||
{
|
||||
using boost::spirit::qi::uint_parser;
|
||||
namespace qi = boost::spirit::qi;
|
||||
@@ -165,7 +165,6 @@ struct ts_real_policies : boost::spirit::qi::ureal_policies<T>
|
||||
uint_parser<unsigned, 10, 1, 3> uint3;
|
||||
uint_parser<unsigned, 10, 3, 3> uint3_3;
|
||||
|
||||
Accumulator result = 0;
|
||||
if (parse(first, last, uint3, result))
|
||||
{
|
||||
Accumulator n;
|
||||
@@ -177,7 +176,6 @@ struct ts_real_policies : boost::spirit::qi::ureal_policies<T>
|
||||
first = iter;
|
||||
}
|
||||
|
||||
attr = result;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -59,7 +59,7 @@ struct ts_real_policies : boost::spirit::qi::ureal_policies<T>
|
||||
// Thousands separated numbers
|
||||
template <typename Iterator, typename Accumulator>
|
||||
static bool
|
||||
parse_n(Iterator& first, Iterator const& last, Accumulator& attr)
|
||||
parse_n(Iterator& first, Iterator const& last, Accumulator& result)
|
||||
{
|
||||
using boost::spirit::qi::uint_parser;
|
||||
namespace qi = boost::spirit::qi;
|
||||
@@ -67,7 +67,6 @@ struct ts_real_policies : boost::spirit::qi::ureal_policies<T>
|
||||
uint_parser<unsigned, 10, 1, 3> uint3;
|
||||
uint_parser<unsigned, 10, 3, 3> uint3_3;
|
||||
|
||||
Accumulator result = 0;
|
||||
if (parse(first, last, uint3, result))
|
||||
{
|
||||
Accumulator n;
|
||||
@@ -79,7 +78,6 @@ struct ts_real_policies : boost::spirit::qi::ureal_policies<T>
|
||||
first = iter;
|
||||
}
|
||||
|
||||
attr = result;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -56,7 +56,7 @@ struct ts_real_policies : boost::spirit::x3::ureal_policies<T>
|
||||
// Thousands separated numbers
|
||||
template <typename Iterator, typename Accumulator>
|
||||
static bool
|
||||
parse_n(Iterator& first, Iterator const& last, Accumulator& attr)
|
||||
parse_n(Iterator& first, Iterator const& last, Accumulator& result)
|
||||
{
|
||||
using boost::spirit::x3::uint_parser;
|
||||
namespace x3 = boost::spirit::x3;
|
||||
@@ -64,7 +64,6 @@ struct ts_real_policies : boost::spirit::x3::ureal_policies<T>
|
||||
uint_parser<unsigned, 10, 1, 3> uint3;
|
||||
uint_parser<unsigned, 10, 3, 3> uint3_3;
|
||||
|
||||
Accumulator result = 0;
|
||||
if (parse(first, last, uint3, result))
|
||||
{
|
||||
Accumulator n;
|
||||
@@ -76,7 +75,6 @@ struct ts_real_policies : boost::spirit::x3::ureal_policies<T>
|
||||
first = iter;
|
||||
}
|
||||
|
||||
attr = result;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user