Tag: default-constructor
-
Why do I need to specify the type of a default constructed object in this situation?
9 I don’t understand why in foobar below I need to specify std::vector<int>{} whereas in foobar2 I do not: #include <iostream> #include <memory> #include <vector> #include <tuple> std::tuple<std::unique_ptr<int>, std::vector<int>> foobar() { std::unique_ptr<int> test = std::make_unique<int>(42); return { std::move(test), {} }; // <= this is a syntax error // return { std::move(test), std::vector<int>{} } // <=…