Replies: 1 comment
-
There is no safe way to write |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello!
I have some data structures that contain
const
members in order to maintain a level of thread safety within the application.When writing
from/to_json
functions, I have run into a couple of problems that I am unable to navigate currently.Here is what I have:
and
In the
to_json
method, I am getting an error when I try to assign dictionaryName:C++ no operator matches these operands: operand types are: const nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::string, bool, int64_t, uint64_t, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<uint8_t, std::allocator<uint8_t>>> = const std::string
And a similar error for the
suggestion
type alsoHow can I assign a
const std::string
to thenlohmann::json
object?Note: I am aware that const_cast can lead to undefined behaviour, but I am not sure if there is another way to accomplish what we are trying to do, so it may be a necessary evil for the time being. If anyone can suggest another approach, I'd be happy to hear it.
Beta Was this translation helpful? Give feedback.
All reactions