4

Here is a link to my question. There are a couple of other questions on the same topic as mine, but they don't answer my question. 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.

Similar questions on Stack Overflow are:

  1. How to print std::optional < T > for any T assuming `std::ostream << T()` is well defined?
  2. How should one use std::optional?

These questions do help to understand std::optional but do not answer my specific question.

Now, I see my question is closed and hidden (deleted). Can it be undeleted and reopened?

7
  • 7
    Personally, I'm unsure why your question was deleted; it almost feels like the users used their delete votes as "super downvotes". Your question has a couple (very) well received answers and deletion of good content isn't what delete votes are for... As for the VTCs, that isn't something I can comment on completely, as a non-SME.
    – Thom A
    Commented Jul 19 at 15:07
  • 2
    If none of the linked questions that detail how to unwrap an optional apply, then I'm not sure how you expect your question answered beyond "no". Commented Jul 19 at 17:08
  • @StoryTeller-UnslanderMonica can you link an answer which explains emplace, I couldn't find one in the linked questions.
    – cafce25
    Commented Jul 19 at 17:55
  • 1
    @cafce25 - Can you point out where in the deleted post OP asks about emplace and not as an afterthought? The only actual focused question there is how how to "typecast" an optional, grouped with a whole lot of unclarity that now more than ever seems like pre-emptive shifting of the goalposts. Commented Jul 19 at 18:08
  • 1
    @StoryTeller-UnslanderMonica in the title?
    – cafce25
    Commented Jul 19 at 18:08
  • 2
    And if how to use emplace is a genuine question, then we have 2 questions in ones, making the post overly broad and closeworthy just the same. Commented Jul 19 at 18:09
  • 1
    @thirdeye Just ask a new separate question that concerns only with one problem at a time. Mixing two problems in one post/question isn't recommended. Remember the rule/recommendation: "One clear question per post." Commented Jul 20 at 3:15

1 Answer 1

11

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.

7
  • thanks @Tsyvarev, I have modified my question as you suggested. The codebase I was working with had emplace() where it was supposed to read the variable so I wrote the question regarding both how to read an std::optional variable and what is the purpose of emplace() in that regard.
    – thirdeye
    Commented Jul 20 at 3:02
  • 1
    @thirdeye Note that you have not selected "This edit resolves the original close reason and the question should be considered for reopening.". You must do that if you want your question to be put in the queue to be considered for reopening.
    – Ryan M Mod
    Commented Jul 20 at 3:11
  • 1
    @thirdeye Just ask a new separate question that concerns only with one problem at a time. Mixing two problems in one post/question isn't recommended. Remember the rule/recommendation: "One clear question per post." Commented Jul 20 at 3:14
  • @RyanM thanks I didn't notice that option. I have selected it now.
    – thirdeye
    Commented Jul 20 at 6:02
  • @user12002570 I will keep it in mind while posting questions, now I have modified the question again. thanks.
    – thirdeye
    Commented Jul 20 at 6:03
  • @thirdeye: But now your question post is even more confusing and unfocused. In the title your ask two questions: "Why does emplace() without arguments return 0" and "can we use emplace to read a std::optional<unsigned> variable?". And in the question body you state the third question "Is there a way to typecast an optional unsigned std::optional<unsigned> variable to unsigned?". Well, that third question could be viewed as a rephrasing of the second question (how to use emplace for that purpose), but again, you ask two separate questions, not a one.
    – Tsyvarev
    Commented Jul 21 at 7:10
  • 1
    Oh, now I see the problem with salvaging your question: On Stack Overflow we avoid modifications of a question which invalidates existing answers. Because that answer already covers both your sub-questions, I hardly can imaging an edit which both makes the question post focused and doesn't invalidate that answer. So, a user12002570' suggestion to abandon the current question and asking a new question has a sense. But again, make sure to ask focused question, not a series of sub-questions.
    – Tsyvarev
    Commented Jul 21 at 7:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .