std::vector constructor from nlohmann::json vs. assignment #3512
Replies: 3 comments 5 replies
-
Can you show some code? |
Beta Was this translation helpful? Give feedback.
-
#include "nlohmann/json.hpp" using DVect = std::vector; int main()
#if 0 compiled with g++ -Wall -o dvect dvect.cc on x86-64 Linux g++ version 10.3 |
Beta Was this translation helpful? Give feedback.
-
So I implemented using the get<>() and it worked well except for one case where |
Beta Was this translation helpful? Give feedback.
-
All,
I converted some classes that used Poco::JSON to nlohmann::json and it sure is a lot "cleaner"; kudos to all. The classes use std::vector for some member vars and I noticed that the assignment from nlohmann::json to the std:vector didn't compile while the assignment at construction worked as expected.
The vectors in question are quite large and I don't really want to create a copy just to then assign it to the member variable (obviously I can build the vector w/ a for loop and push_back as a fallback).
Thanks for a great package.
Bill
Beta Was this translation helpful? Give feedback.
All reactions