Witam,
Mam strukturę, do której zapisuję dane pojedynczego pliku z folderu ze skanami. Wszystko trzymam w std::set<ScannedFile> files
. W trakcie programu zmieniam ich nazwy i na koniec zapisuję. W jaki sposób przeładować w moim przypadku funkcję find
tak żeby wyszukiwanie odbywało się zarówno dla old_name
jak i new_name
?
class ScannedFile
{
public:
std::wstring old_name{ L"" };
mutable std::wstring new_name{ L"" };
ScannedFile() {}
ScannedFile(const std::wstring &old_n, const std::wstring &new_n, const std::string &ext) :
old_name(old_n), new_name(new_n), extension(ext)
{
counter++;
if (new_n.empty())
this->new_name = L"pusta_nazwa" + std::to_wstring(counter);
}
void SetExtension(const std::string &s);
std::wstring GetExtension() const;
bool operator<(const ScannedFile &f) const
{
return (this->old_name < f.old_name) && (this->new_name < f.new_name);
}
private:
static int counter;
std::string extension;
};
Dodam, że takie przeładowanie operatora " < " działa (blokuje dodanie) gdy chcę wstawić do files
(istniejący już tam) plik skanu funkcją insert
, dlaczego więc nie działa dla find
lub count
?