nlohmann / json

JSON for Modern C++
https://json.nlohmann.me
MIT License
42.38k stars 6.67k forks source link

Initializing `json` by direct initialization and copy initialization invokes different constructors #4174

Closed FeignClaims closed 1 year ago

FeignClaims commented 1 year ago

Description

I think this behaviour is easy to make mistakes, so probably not an intentional design.

Reproduction steps

refer to description

Expected vs. actual results

The direct initialization code should behave as the same as the copy initialization one, which enables converting json back to std::map.

Minimal code example

No response

Error messages

No response

Compiler and operating system

x86-64 clang (trunk), x86-64 gcc (trunk)

Library version

35c0b3e54ce99716bf2a6bb6bdbd346f3e6d398b

Validation

gregmarr commented 1 year ago

This is the very first item in the FAQ. https://json.nlohmann.me/home/faq/

FeignClaims commented 1 year ago

I see, only searched in issue, sorry for the bother