I have the following class:
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_;
};
The portion of code that causes the problem:
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;});
}
I get the following error when trying to compile
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
I know the problem is the parameter, but I don't understand why. If const std::pair<std::string, Asset> const& a
is a reference to a pair of string and Asset, why is the assignment operator called?