#include <vector>
struct Foo{
int i;
};
int main() {
Foo foo{42}; //fine
std::vector<Foo> v;
v.emplace_back(42); //not fine
}
I2luY2x1ZGUgPHZlY3Rvcj4KCnN0cnVjdCBGb297CglpbnQgaTsKfTsKCmludCBtYWluKCkgewoJRm9vIGZvb3s0Mn07IC8vZmluZQoJc3RkOjp2ZWN0b3I8Rm9vPiB2OwoJdi5lbXBsYWNlX2JhY2soNDIpOyAvL25vdCBmaW5lCn0=
In file included from /usr/include/i386-linux-gnu/c++/5/bits/c++allocator.h:33:0,
from /usr/include/c++/5/bits/allocator.h:46,
from /usr/include/c++/5/vector:61,
from prog.cpp:1:
/usr/include/c++/5/ext/new_allocator.h: In instantiation of 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = Foo; _Args = {int}; _Tp = Foo]':
/usr/include/c++/5/bits/alloc_traits.h:256:4: required from 'static std::_Require<typename std::allocator_traits<_Alloc>::__construct_helper<_Tp, _Args>::type> std::allocator_traits<_Alloc>::_S_construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp = Foo; _Args = {int}; _Alloc = std::allocator<Foo>; std::_Require<typename std::allocator_traits<_Alloc>::__construct_helper<_Tp, _Args>::type> = void]'
/usr/include/c++/5/bits/alloc_traits.h:402:16: required from 'static decltype (_S_construct(__a, __p, (forward<_Args>)(std::allocator_traits::construct::__args)...)) std::allocator_traits<_Alloc>::construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp = Foo; _Args = {int}; _Alloc = std::allocator<Foo>; decltype (_S_construct(__a, __p, (forward<_Args>)(std::allocator_traits::construct::__args)...)) = <type error>]'
/usr/include/c++/5/bits/vector.tcc:96:30: required from 'void std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int}; _Tp = Foo; _Alloc = std::allocator<Foo>]'
prog.cpp:10:19: required from here
/usr/include/c++/5/ext/new_allocator.h:120:4: error: no matching function for call to 'Foo::Foo(int)'
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
^
prog.cpp:3:8: note: candidate: Foo::Foo()
struct Foo{
^
prog.cpp:3:8: note: candidate expects 0 arguments, 1 provided
prog.cpp:3:8: note: candidate: constexpr Foo::Foo(const Foo&)
prog.cpp:3:8: note: no known conversion for argument 1 from 'int' to 'const Foo&'
prog.cpp:3:8: note: candidate: constexpr Foo::Foo(Foo&&)
prog.cpp:3:8: note: no known conversion for argument 1 from 'int' to 'Foo&&'