У меня есть следующий класс:Удалена функция, станд :: пара <станд :: строка Asset> ссылка
class AssetManager
{
public:
AssetManager();
AssetManager(std::vector<const char *> sources);
~AssetManager();
bool addSource(const char *file);
std::vector<char> getAsset(const char *name);
private:
class Asset
{
public:
Asset(const char *name, std::size_t size, std::size_t location, std::ifstream &inputStream);
~Asset();
const char *getName();
std::size_t getSize();
std::size_t getLocation();
std::ifstream &getInputStream();
//makes the name 16 bytes and filled with 0's
static const char *makeName(const char *name);
private:
char name_[ASSET_NAME_LENGTH];
std::size_t size_;
std::size_t location_;
std::ifstream &inputStream_;
};
Asset *findAssetByName(std::string &name, std::size_t start, std::size_t end);
std::vector<std::pair<std::string, Asset>> sortedNames_;
std::vector<std::ifstream> inputStreams_;
};
Часть кода, который вызывает проблему:
AssetManager::AssetManager(std::vector<const char*> sources) : inputStreams_(sources.size())
{
//some code....
std::sort(sortedNames_.begin(), sortedNames_.end(),
[](std::pair<std::string, Asset> const& a,
std::pair<std::string, Asset> const& b){return a.first.compare(b.first) < 0;});
}
я получаю следующая ошибка при попытке скомпилировать
Severity Code Description Project File Line
Error C2280 'AssetManager::Asset &AssetManager::Asset::operator =(const AssetManager::Asset &)': attempting to reference a deleted function c:\program files (x86)\microsoft visual studio 14.0\vc\include\utility 175
Я знаю, проблема в параметре, но я не понимаю, почему. Если const std::pair<std::string, Asset> const& a
является ссылкой на пару строк и Asset, то почему оператор присваивания называется?
Возможный дубликат [Правило-тройка становится Правилом пяти с C++ 11?] (Http://stackoverflow.com/questions/4782757/rule-of-three-becomes-rule-of- пять-с-C11) – Pradhan