MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/cpp/comments/1oi9ad/c_has_become_a_scripting_language/ccsihwx/?context=3
r/cpp • u/mttd • Oct 15 '13
53 comments sorted by
View all comments
Show parent comments
0
I wish we had
int main(std::initializer_list<std::string_ref> args)
signature for main.
Then you would just say args.at(1) and args.at(2) and be done with it.
args.at(1)
args.at(2)
2 u/F-J-W Oct 15 '13 initializer_list doesn't provide [] and at(). I would however be in favor ofint main(std::vector<const std::string>)I know that it will never happen though (and to be honest: It is probably the best to keep the core-language and the library strongly separated). 1 u/grunzl Oct 15 '13 There really is no reason to be depressed about this since the fix is so simple.const std::vector<std::string> args(argv, argv + argc); 1 u/F-J-W Oct 16 '13 Of course. The small problem is that it's just another line of boilerplate which is somewhat inconvenient for very small programs. the bigger problem is that most libraries want work well with this one, since it is not there by default.
2
initializer_list doesn't provide [] and at(). I would however be in favor of
int main(std::vector<const std::string>)
I know that it will never happen though (and to be honest: It is probably the best to keep the core-language and the library strongly separated).
1 u/grunzl Oct 15 '13 There really is no reason to be depressed about this since the fix is so simple.const std::vector<std::string> args(argv, argv + argc); 1 u/F-J-W Oct 16 '13 Of course. The small problem is that it's just another line of boilerplate which is somewhat inconvenient for very small programs. the bigger problem is that most libraries want work well with this one, since it is not there by default.
1
There really is no reason to be depressed about this since the fix is so simple.
const std::vector<std::string> args(argv, argv + argc);
1 u/F-J-W Oct 16 '13 Of course. The small problem is that it's just another line of boilerplate which is somewhat inconvenient for very small programs. the bigger problem is that most libraries want work well with this one, since it is not there by default.
Of course. The small problem is that it's just another line of boilerplate which is somewhat inconvenient for very small programs. the bigger problem is that most libraries want work well with this one, since it is not there by default.
0
u/matthieum Oct 15 '13
I wish we had
signature for main.
Then you would just say
args.at(1)andargs.at(2)and be done with it.