SpeCter, that's really nice of you, thanks!
I'd like to track down the problem to a minimal complete example with just a
main() function, and without Thor. So if it is indeed a VS 2015 problem, I could report it at Microsoft Connect, and they can hopefully fix it for the full release.
The original code in
thor::ResourceHolder::load() is a bit convoluted because of genericity with multiple ownership strategies. Simplified, it's roughly equivalent to these lines:
#include <map>
#include <memory>
struct R {};
typedef std::map<int, std::unique_ptr<R>> Map;
R& load(Map& map, int id)
{
std::unique_ptr<R> original = std::make_unique<R>();
auto inserted = map.insert(std::make_pair(id, nullptr)).first;
std::unique_ptr<R> loaded = std::move(original);
R& returned = *loaded;
inserted->second = std::move(loaded);
return returned;
}
int main()
{
Map map;
load(map, 3);
}
Can you tell me if this still reproduces the error (I guess not
). If it does, can you further minimize it? That is, try as many of the following omissions as possible, as long as the code still reproduces the error:
- std::move()
- std::unique_ptr
- Use basic type (e.g. short) instead of R
- load() function -> everything in main()