Код: Выделить всё
#include
struct A{};
int main() {
std::vectora;
a.emplace_back(0, 0);
}
Код: Выделить всё
/usr/include/c++/13/bits/new_allocator.h:187:11: error: new initializer expression list treated as compound expression [-fpermissive]
187 | { ::new((void *)__p) _Up(std::forward(__args)...); }
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/new_allocator.h:187:11: error: no matching function for call to ‘A::A(int)’
a.cpp:2:8: note: candidate: ‘constexpr A::A()’
2 | struct A{};
| ^
Однако после того, как я предоставил A(int) вместо A компиляторы пытались вызвать A::A(int, int):
Код: Выделить всё
/usr/include/c++/13/bits/new_allocator.h:187:11: error: no matching function for call to ‘A::A(int, int)’
187 | { ::new((void *)__p) _Up(std::forward(__args)...); }
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cpp:3:5: note: candidate: ‘A::A(int)’
3 | A(int x) {}
| ^
Подробнее здесь: https://stackoverflow.com/questions/784 ... int-when-c