6

void_t is a template discovered by Walter Brown and first introduced by him at CppCon 2014 in the presentation of "Modern Template Metaprogramming: A Compendium, Part II". It is defined as follows:

template <typename ...> using void_t = void;

Its purpose is to map any well formed type into the type void, which provides means to check for well-formedness during template instantiation at compile time. Besides providing means specialize templates based on whether a type, function, variable or a member of some type exists, what other fundamental uses does void_t or checking for well-formedness have, if any? In other words, are there any other uses for void_t which do not fall into the "concepts lite" categories and were not presented by Walter Brown at CppCon 2014?

PS: Further information and explanations about void_t can be found under these StackOverflow questions:

jotik
  • 17,044
  • 13
  • 58
  • 123
  • 1
    Close to a duplicate too: http://stackoverflow.com/questions/26513095/void-t-can-implement-concepts and http://stackoverflow.com/questions/27687389/how-does-void-t-work. – david.pfx Mar 08 '16 at 13:04
  • @david.pfx Huh? I added those to "See also" just to refer to people what `void_t` is and how it works. I'm asking whether there is something else that can be done with `void_t` other than "concepts lite" and general use-cases like the ones presented by Walter Brown. I find it awkward (at minimum) that neither You nor any of the 5 people who put this question on hold (more than 14 hours ago!) have been able to comment on what exactly is unclear about my question or why You think this is a duplicate... – jotik Mar 08 '16 at 13:21
  • 1
    @jotik. I have to agree with you that this is actually a legitimate question. – Mad Physicist Mar 08 '16 at 15:08
  • 1
    @jotik: Fair point. The problem is that your question invites the quick reader to get the wrong impression (as I did). I suggest you edit so (a) your bolded question is either just the one in the title, or split into two; and (b) make it clear what relationship your bullet points and links have to your question(s). [see also implies they are part of the question]. – david.pfx Mar 08 '16 at 23:17
  • @david.pfx Thank you for this feedback! English is not my native language, but I'm trying my best. I edited the question a bit. Any further feedback or edits are welcome. – jotik Mar 09 '16 at 08:40
  • 3
    The point of checking whether something is well-formed is of course that you can do things differently, or "specialize", based on the answer. But if you exclude the whole thing then there's not much left. – T.C. Mar 09 '16 at 09:20
  • 2
    @jotik: I think I didn't vote unclear, IIRC I voted primarily opinion based. IMO these jeopardy-style "here's the answer, now what's the question?" questions are generally a poor fit for SO. I also voted to close questions like "what is the purpose of `std::stringstream`". This question isn't even an "XY"-question, I mean there's no hint of an actual application anywhere. I doubt that listing the "known purposes" of any language feature is actually useful to anyone programming anything, instead its more productive to ask (how to / what is a better way to) do something – Chris Beck Mar 09 '16 at 14:58
  • @T.C. Just to be clear, *"there's nothing else you can do with `void_t`"* is a valid answer if one provides a solid argument to go with that. This is why I ended my question with *", if any?"*. – jotik Mar 09 '16 at 22:21
  • 1
    I chose to leave this closed from reopen review; I would have closed it as 'too broad'. I think any clever unintended uses of `void_t` are better off as answers to "How do I do X?" (which may be a new self-answered question) than "What other uses does void_t have?". People looking to solve problems generally search for terms related to their problem, not its solution (because they don't _know_ the solution yet). – Jeffrey Bosboom Mar 14 '16 at 03:14

0 Answers0