So you want to do C++ w/o using the std namespace or do you mean stl in which case it would contradict the phrase 'modern version' since the standard library (as the erstwhile stl has come to be known) is one of the bedrocks of 'modern c++'?
I can think of at least five ways of sorting the std::vector:
- a C-style array sort as I think you're trying to do in your code-link
- sort using the std::sort() algorithm (Peter87 refers to these 2 in his reply)
- using a functor with (a) a named object or (b) by calling its default ctor
- writing a lambda function
Underlying each of these would be some of the basic sorting algorithms but the user interface would vary in each case. Perhaps there are yet other ways I haven't covered
You can find information about all of these on-line, if something is unclear after search come back here.
@gunnerfunner, you know when people use std::cout and some stuff like that. I am not use to that, so in case if some users actually posted their code, I wanted them to write it in this way which I call "modern version" cout << .
Also thank you for the information you provided.
At worst, the use of usingnamespace xxx can cause the behavior of your program to silently change.
This happens when (e.g.) code in a third-party module introduces a colliding name (an anaphor) which is more preferable the overload resolution rules than your own.
Prefer introducing only specific names (i.e., write using std::cout;), if you absolutely must use them. Do not place file-scope using-declarations of any sort in a header file, but instead limit using-declarations locally if you choose to use them at all.
Even restricted to introducing only particular names in a local scope, they're still subject to the same problems. In the case of ambiguity the programmer has to know about overload resolution and all the participating candidates. That's not always easy especially in the case where participating overloads are eliminated by a metaprogram or some other sorts of SFINAE techniques. If that's not enough, the programmer needs to actually read the using statement in order to consider this.
For good reason, the consensus is that it's simpler and easier to just type the full name, or at least an alias of that full name.