I don't agree on the general usage of "using namespace std", so that part does not bother me.
For an even shorter init:
> std::vector<unsigned> counts(sevens.size());
For an even shorter init:
> std::vector<unsigned> counts(sevens.size());
But again, personal opinion - it can definitely be used in some contexts (just be consistent in your project!).
What is idiomatic is explicitly importing individual symbols into a name peace.
#include <iostream>
#include <vector>
#include <string>
using std::cout;
using std::vector;
using std::string;
int main() {
vector<string> v {"explicit ", "is better ", "than implicit\n" };
for (auto p: v) cout << p;
return 0;
}
I'm on mobile so please forgive errors.It should: we're comparing to Rust, whose namespace system seems very similar to a "using namespace std".
Not at all; only if you use globs ("use foo::*"). D's namespace system is like that, but not Rust's.