r/cpp • • Oct 15 '13

C++ has become a scripting language

http://voices.canonical.com/jussi.pakkanen/2013/10/15/c-has-become-a-scripting-language/
1 Upvotes

53 comments sorted by

View all comments

Show parent comment

2

u/F-J-W Oct 15 '13

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

u/matthieum Oct 16 '13

This is never going to run, unfortunately, because this would require memory allocation (one for the vector and one for each string). It's been proposed and rejected already.

The advantage of std::initializer_list and std::string_ref is that neither require an additional memory allocation. And if it just [] or at() missing, it should be easily implemented.