donbock, thank you.
"Are you asking the question or are you offering advice?"
I put this here for me as part of a repository for some of my worked through code.
Of all the sites that I have been using, this is the site that has had the most of the directly useful "applied" code discussions for me. What does some syntax mean = I go here and elsewhere and read about the meaning. How to actually make the code do something that I find useful = I like to read what is said here. It seemed logical to me to place some of my own worked through code logic on this one site where I can find it later.
I am writing (coding in C++11) a program, and I have have been testing various examples of applied code that I have found on the internet, and I have found almost all of those from other sites (strictly viewed via C and up to C++11) to not be useful. Not just un-useful, but aggressively anti-useful. I have not seen that propensity here on this site. A lot of Visual Basic and Visual C++ and .net and ActiveX examples show up here, but I have learned (to some extent) how to filter those out. Thus, this is where I have been occasionally placing some of my worked through code and worked through logic. Plus, I get the added benefit of people like you fixing what I thought was correct to become correct. Thank you all so much.
Your statement of "The only technique that comes to mind as being always and invariably wrong is using the returned pointer to a variable after that variable has gone out-of-scope." is a compelling logic to not return a pointer to an array of values. Within my limited understanding, and I do still consider myself a beginner at C++, I agree with you.
But, Stroustrup has published some amazing updates to C++, and if he tells the ISO how to do this safely, then that is a future possibility of which I did not want to forget to be aware. "If Bjarne Stroustrup (or ISO) publishes a version of C++ that includes functions that can return multiple values, then that could be an option."
You mentioned qsort. I do not understand how to use this to return multiple values from a function.
Reference [
X]:
Return value
1) (none)
2) zero on success, non-zero if a runtime constraints violation was detected
You mentioned div and ldiv. I do not understand how to use these to return multiple values from a function.
Reference[
X]
Thank you donbock.