I would like to verify a certain number of command line arguments are given, but without using an if statement or similar. I want to change something like this:
1 2 3
if ( argv < 2 ) {
cerr << "Enter more command line arguments.";
}
Is there any way to achieve this without using an if statement?
You could use the ?: operator but why would you want to? An if statement is the correct way to do this and using anything else would decrease the readability of your program.
It does decrease the readability, but it takes a segment of code from O(n) down to O(1). Are there any standard functions built into C++ that could solve this?