I have a question about a compiler/language behaviour that I expected to behave differently. Why does the following code compile?
#include <vector>
class A { };
int main() {
A a(std::vector<int>());
}
It does not compile with std::vector<int>(0)
or other values. It does however compile if you give std::vector<int>(*)
a pointer. It also works with other types than "int
". I expected the code to not work at all. Can someone explain to me what's happening?
Here is a code snipped on cpp.sh for reference: http://cpp.sh/4l3a
I use gcc version 4.8.4.