I've got a question regarding template specializations in C++: I understand what this is, but do not understand when and why it should be used (examples that I have are not great). Quoting the last part (note that the question was significantly edited since then, here are old words):
My question being: when one should use template specialization in C++03/C++11? Alternative wording: what are some good examples of template specialization, like
std::swap
(if it is a good example at all)?
A person suggested that this question is off-topic and pointed me to Why do 'some examples' and 'list of things' questions get closed? question on meta. This Q&A refers to help center and states that these these question are off-topic "because there is no right answer" (not answers).
While I agree with the reasoning and there are things in my question which can be significantly improved, I was quite surprised that there is no place to ask about "when to use X" questions. So, I did some research. I started with Is there a less restrictive Stack Exchange site specially suited for not too specific questions? question and corresponding answer:
- Conceptual questions. That is covered on softwareengineering.stackexchange.com
I think that "when do I use X" is a conceptual question. Still, comments suggest that "Programmers" (old name of softwareengineering) has its own rules and questions should not be opinion-based. Ok, let's look at Meta:
- Is a “best practice” question off topic? on SO Meta. The answer suggests to ask "best practices" questions on Programmers.
- Making “best practices” questions more palatable: how to ask a “best practice” question that is acceptable to the community? on SE.SE Meta. Answers mainly suggest that one should ask for a solution of a specific situation, not about general "best practices".
Fair enough: looks like general questions are too board and opinion-based because different situations require different solutions.
However, I've found several open popular question on both StackOverflow and softwareengineering which are, I think, similar to mine (all of them are of form "when to use X" and do not provide any specify problems that OPs try to solve). From SO:
- Factory Pattern. When to use factory methods?, +181.
- When should I use the Visitor Design Pattern?, +209.
- When to use a Class vs. Function in PHP, +50.
There is a bunch of very general questions marked with c++-faq
(they probably went through some special process which lifts some restrictions), from SO:
- Operator overloading, +1537 - asks about idioms of operator overloading as well.
- What is a smart pointer and when should I use one?, +1046 - note the "when should I use one", which is probably "opinion-based".
And some questions closed for being either non-constructive or opinion-based:
- What is so bad about singletons? [closed], +1427.
- Naming Classes - How to avoid calling everything a “Manager”? [closed], +670.
- On Design Patterns: When to use the Singleton? [closed], +282.
And, finally, questions on SE:
- Does using == in JavaScript ever make sense?, +255.
- Are there real-life usage and applications for “do while” loops? [closed], +4.
So, it looks like some questions survive, become popular and are not closed. Moreover, there is a special "C++ FAQ" section on StackOverflow which aims at not-situation-specific questions. However, most questions I found were on StackOverflow and they're quite old, so rules and mood could have changed. Two question from softwareengineering were asked almost at the same time, but one lives and other is closed. I don't see what's essentially different between them.
Main question being: are questions "when do I use X" on-topic on SoftwareEngineering?