Commit ea2c005e authored by Mathieu Baudet's avatar Mathieu Baudet Committed by Facebook Github Bot

add missing const to fix `folly::toDynamic` on `std::vector<bool>`

Summary: [folly] add missing const to fix `folly::toDynamic` on `std::vector<bool>`

Reviewed By: ender-wieczorek, yfeldblum

Differential Revision: D5039403

fbshipit-source-id: edd052c7d1d832d424166cba15fcd9f4f8bd219c
parent 31751bbf
......@@ -317,7 +317,7 @@ struct DynamicConstructor<
dynamicconverter_detail::is_map<C>::value>::type> {
static dynamic construct(const C& x) {
dynamic d = dynamic::object;
for (auto& pair : x) {
for (const auto& pair : x) {
d.insert(toDynamic(pair.first), toDynamic(pair.second));
}
return d;
......@@ -335,7 +335,7 @@ struct DynamicConstructor<
dynamicconverter_detail::is_range<C>::value>::type> {
static dynamic construct(const C& x) {
dynamic d = dynamic::array;
for (auto& item : x) {
for (const auto& item : x) {
d.push_back(toDynamic(item));
}
return d;
......
......@@ -382,6 +382,12 @@ TEST(DynamicConverter, construct) {
dynamic::array(3, 4, 5));
EXPECT_EQ(d, toDynamic(c));
}
{
vector<bool> vb{true, false};
dynamic d = dynamic::array(true, false);
EXPECT_EQ(d, toDynamic(vb));
}
}
TEST(DynamicConverter, errors) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment