KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I observed the following vector constructors in the Standard C++ library explicit vector(size_type n); vector(size_type n, const T& value, const Allocator& = Allocator()); Is there a reason why the second constructor is not marked explicit ? This compiles, and makes me feel bad void f(vector<string>); int main() { f({10, "foo"}); } While if I omit the "foo" , it doesn't compile and that is what I expect when I pass a pair (compound) value of an int and a string to a function that wants a vector of strings.
Tags (comma-separated)
Save Edits
Cancel