-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
使用c++新标准 #1
Labels
enhancement
New feature or request
Comments
|
对于已知类型,可以使用 optional<bool> ret_boolean = j["boolean"].get_boolean();
optional<string> ret_string = j["string"].get_string();
optional<double> ret_number = j["number"].get_number(); 这样可以获取更高的确定性和可读性 如果你想使用泛型,可以用 std::variant<double,std::string,bool/*other type*/> ret_unknow_type = j["unknow type"].get_vulan(); 这同样是来自标准库的方法 |
貌似 README 里面的 |
@chhdao 感谢建议,没有使用optional的原因是不想让这个库c++17起步,对用户的要求低一些,暂时保留这个issue吧 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
我注意到README个段代码:
c++在新标准中已经对这种情况做出标准做法:使用std::optional.
修改成标准代码:
如果没有什么特殊需求,都应该使用标准库中的方法.
The text was updated successfully, but these errors were encountered: