My question was an attempt to understand how to read a std::optional
variable value using member functions, and what the use of emplace()
is.
But these are two questions, not the one! Because of that, in the current state your question post is simply "too broad".
If you want to fix "too broad" aspect of your question, and focus only on the "first question" (how to read std::optional
), then I find How to print std::optional < T > for any T assuming `std::ostream << T()` is well defined? to be the actual duplicate of your question, so the current close reason is the proper one.
You may want to edit your question and focus only on the "second question" (usage of emplace
). I have not searched existed questions on that topic. I am not sure whether the question "Why emplace()
without arguments returns 0" will be a useful question. But this will be definitely a valid (on-topic) question.
As for deleting, I found the question as not deserving the deletion. Even if comparing your "first question" ("how to read a std::optional
") to the duplicate question, yours one contains the error message caused by the very fair attempt of solving the problem. I find such error message as definite improvement, so the delete reason
Delete it if the duplicate does not add terminology or alternate phrasing to find the question.
is not applied.
emplace
, I couldn't find one in the linked questions.