This isn't an answer per se, but in case anyone comes across this question in the future after struggling as much as I just have, I decided to post it anyway.
I was facing a very similar issue to the OP for basically the same reason, although the error message that Visual C++ was giving me was 'ClassName::ClassName(const ClassName &)': attempting to reference a deleted function
. In my inexperienced mind, I was thinking "WTF, I'm not copying or assigning any copies anywhere!".
However, after an hour of screaming at the computer in frustration I was able to narrow the problem down to the ifstream
class member, which led me here. And thanks to the accepted answer, I was able to narrow the problem down even further to this single line of code:
list.emplace_back(objParam);
Little did I know that std::vector
objects need a copy constructor defined on their template parameter's type in order to reserve space for future emplace_back()
calls and the like!
So the solution comes from this SO answer courtesy of Bryan Chen (emphasis added by me):
So you can see emplace_back does use the desired constructor to create the element and call copy constructor when it need to grow the storage. You can call reserve with enough capacity upfront to avoid the need to call copy constructor.
Full credit and many thanks go to Bryan and molbdnilo for leading me to this discovery.