Skip to content

Commit fafab14

Browse files
author
MacroFake
committed
move-only: Move UniValue::getInt definition to keep class with definitions only
Can be reviewed with the git options --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
1 parent 4e2929e commit fafab14

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

src/univalue/include/univalue.h

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,7 @@ class UniValue {
116116
const std::vector<std::string>& getKeys() const;
117117
const std::vector<UniValue>& getValues() const;
118118
template <typename Int>
119-
auto getInt() const
120-
{
121-
static_assert(std::is_integral<Int>::value);
122-
if (typ != VNUM) {
123-
throw std::runtime_error("JSON value is not an integer as expected");
124-
}
125-
Int result;
126-
const auto [first_nonmatching, error_condition] = std::from_chars(val.data(), val.data() + val.size(), result);
127-
if (first_nonmatching != val.data() + val.size() || error_condition != std::errc{}) {
128-
throw std::runtime_error("JSON integer out of range");
129-
}
130-
return result;
131-
}
119+
Int getInt() const;
132120
bool get_bool() const;
133121
const std::string& get_str() const;
134122
double get_real() const;
@@ -146,6 +134,21 @@ void UniValue::push_backV(It first, It last)
146134
values.insert(values.end(), first, last);
147135
}
148136

137+
template <typename Int>
138+
Int UniValue::getInt() const
139+
{
140+
static_assert(std::is_integral<Int>::value);
141+
if (typ != VNUM) {
142+
throw std::runtime_error("JSON value is not an integer as expected");
143+
}
144+
Int result;
145+
const auto [first_nonmatching, error_condition] = std::from_chars(val.data(), val.data() + val.size(), result);
146+
if (first_nonmatching != val.data() + val.size() || error_condition != std::errc{}) {
147+
throw std::runtime_error("JSON integer out of range");
148+
}
149+
return result;
150+
}
151+
149152
enum jtokentype {
150153
JTOK_ERR = -1,
151154
JTOK_NONE = 0, // eof

0 commit comments

Comments
 (0)