diff --git a/aegisub/libaegisub/common/cajun/reader.cpp b/aegisub/libaegisub/common/cajun/reader.cpp index e7a0061fb..5c3fde3ac 100644 --- a/aegisub/libaegisub/common/cajun/reader.cpp +++ b/aegisub/libaegisub/common/cajun/reader.cpp @@ -58,8 +58,8 @@ public: } bool EOS() { - m_iStr.peek(); // apparently eof flag isn't set until a character read is attempted. whatever. - return m_iStr.eof(); + // libc++ doesn't set eof when a peek fails + return m_iStr.peek() == EOF || m_iStr.eof(); } Location const& GetLocation() const { return m_Location; } diff --git a/aegisub/libaegisub/common/option.cpp b/aegisub/libaegisub/common/option.cpp index 2911293b6..92aa60924 100644 --- a/aegisub/libaegisub/common/option.cpp +++ b/aegisub/libaegisub/common/option.cpp @@ -61,9 +61,9 @@ namespace { template void put_array(json::Object &obj, const std::string &path, const char *element_key, std::vector const& value) { json::Array array; - for (typename std::vector::const_iterator it = value.begin(); it != value.end(); ++it) { + for (T const& elem : value) { array.push_back(json::Object()); - static_cast(array.back())[element_key] = (json::UnknownElement)*it; + static_cast(array.back())[element_key] = (json::UnknownElement)elem; } put_option(obj, path, array); diff --git a/aegisub/src/base_grid.cpp b/aegisub/src/base_grid.cpp index feccc7538..50c3c844d 100644 --- a/aegisub/src/base_grid.cpp +++ b/aegisub/src/base_grid.cpp @@ -272,7 +272,7 @@ void BaseGrid::UpdateMaps(bool preserve_selected_rows) { if (preserve_selected_rows) { sel_rows.reserve(selection.size()); transform(selection.begin(), selection.end(), back_inserter(sel_rows), - std::bind(&BaseGrid::GetDialogueIndex, this)); + [this](AssDialogue *diag) { return GetDialogueIndex(diag); }); } index_line_map.clear(); diff --git a/aegisub/src/dialog_automation.cpp b/aegisub/src/dialog_automation.cpp index 48d6931e6..3abb295fc 100644 --- a/aegisub/src/dialog_automation.cpp +++ b/aegisub/src/dialog_automation.cpp @@ -140,8 +140,8 @@ void DialogAutomation::RebuildList() script_info.clear(); list->DeleteAllItems(); - for_each(local_manager->GetScripts(), bind(&DialogAutomation::AddScript, this, _1, false)); - for_each(global_manager->GetScripts(), bind(&DialogAutomation::AddScript, this, _1, true)); + for_each(local_manager->GetScripts(), std::bind(&DialogAutomation::AddScript, this, _1, false)); + for_each(global_manager->GetScripts(), std::bind(&DialogAutomation::AddScript, this, _1, true)); UpdateDisplay(); } @@ -182,7 +182,7 @@ template static bool has_file(Container const& c, wxFileName const& fn) { return find_if(c.begin(), c.end(), - bind(&wxFileName::SameAs, fn, bind(&Automation4::Script::GetFilename, _1), wxPATH_NATIVE)) != c.end(); + std::bind(&wxFileName::SameAs, fn, std::bind(&Automation4::Script::GetFilename, _1), wxPATH_NATIVE)) != c.end(); } void DialogAutomation::OnAdd(wxCommandEvent &) @@ -276,7 +276,7 @@ void DialogAutomation::OnInfo(wxCommandEvent &) ei->script->GetFilename(), ei->script->GetLoadedState() ? _("Correctly loaded") : _("Failed to load"))); - transform(ei->script->GetMacros(), append_info, bind(cmd_to_str, _1, context)); + transform(ei->script->GetMacros(), append_info, std::bind(cmd_to_str, _1, context)); transform(ei->script->GetFilters(), append_info, filt_to_str); transform(ei->script->GetFormats(), append_info, form_to_str); } diff --git a/aegisub/src/dialog_fonts_collector.cpp b/aegisub/src/dialog_fonts_collector.cpp index d5eddc776..75208a0b2 100644 --- a/aegisub/src/dialog_fonts_collector.cpp +++ b/aegisub/src/dialog_fonts_collector.cpp @@ -78,7 +78,7 @@ class FontsCollectorThread : public wxThread { void Collect() { using namespace std::placeholders; - FontCollectorStatusCallback callback(bind(&FontsCollectorThread::AppendText, this, _1, _2)); + FontCollectorStatusCallback callback(std::bind(&FontsCollectorThread::AppendText, this, _1, _2)); #ifdef WITH_FONTCONFIG FontConfigFontFileLister lister(callback); diff --git a/aegisub/src/dialog_log.cpp b/aegisub/src/dialog_log.cpp index e956d72f9..98648c148 100644 --- a/aegisub/src/dialog_log.cpp +++ b/aegisub/src/dialog_log.cpp @@ -59,7 +59,7 @@ public: : text_ctrl(t) { const agi::log::Sink *sink = agi::log::log->GetSink(); - for_each(sink->begin(), sink->end(), bind(&EmitLog::log, this, std::placeholders::_1)); + for_each(sink->begin(), sink->end(), std::bind(&EmitLog::log, this, std::placeholders::_1)); } void log(agi::log::SinkMessage *sm) { diff --git a/aegisub/src/dialog_resample.cpp b/aegisub/src/dialog_resample.cpp index a1797d1d3..374a446cd 100644 --- a/aegisub/src/dialog_resample.cpp +++ b/aegisub/src/dialog_resample.cpp @@ -248,7 +248,7 @@ void ResampleResolution(AssFile *ass, ResampleSettings const& settings) { if (settings.change_ar) state.ar = state.rx / state.ry; - for_each(ass->Line.begin(), ass->Line.end(), bind(resample_line, &state, std::placeholders::_1)); + for_each(ass->Line.begin(), ass->Line.end(), std::bind(resample_line, &state, std::placeholders::_1)); ass->SetScriptInfo("PlayResX", wxString::Format("%d", settings.script_x)); ass->SetScriptInfo("PlayResY", wxString::Format("%d", settings.script_y)); diff --git a/aegisub/src/dialog_selection.cpp b/aegisub/src/dialog_selection.cpp index 2afc738b3..122ef7256 100644 --- a/aegisub/src/dialog_selection.cpp +++ b/aegisub/src/dialog_selection.cpp @@ -82,17 +82,17 @@ std::function get_predicate(int mode, wxRegEx *re, bool match_c switch (mode) { case MODE_REGEXP: - return bind(static_cast(&wxRegEx::Matches), re, _1, 0); + return [=](wxString str) { return re->Matches(str); }; case MODE_EXACT: if (match_case) - return bind(std::equal_to(), match_text, _1); + return std::bind(std::equal_to(), match_text, _1); else - return bind(std::equal_to(), match_text.Lower(), bind(&wxString::Lower, _1)); + return bind(std::equal_to(), match_text.Lower(), std::bind(&wxString::Lower, _1)); case MODE_CONTAINS: if (match_case) - return bind(&wxString::Contains, _1, match_text); + return std::bind(&wxString::Contains, _1, match_text); else - return bind(&wxString::Contains, bind(&wxString::Lower, _1), match_text.Lower()); + return bind(&wxString::Contains, std::bind(&wxString::Lower, _1), match_text.Lower()); break; default: throw agi::InternalError("Bad mode", 0); } diff --git a/aegisub/src/dialog_style_editor.cpp b/aegisub/src/dialog_style_editor.cpp index 98b7a5e9c..b71e76058 100644 --- a/aegisub/src/dialog_style_editor.cpp +++ b/aegisub/src/dialog_style_editor.cpp @@ -405,7 +405,7 @@ DialogStyleEditor::DialogStyleEditor(wxWindow *parent, AssStyle *style, agi::Con Bind(wxEVT_COMMAND_BUTTON_CLICKED, std::bind(&HelpButton::OpenPage, "Style Editor"), wxID_HELP); for (int i = 0; i < 4; ++i) - colorButton[i]->Bind(wxEVT_COMMAND_BUTTON_CLICKED, bind(&DialogStyleEditor::OnSetColor, this, i + 1, std::placeholders::_1)); + colorButton[i]->Bind(wxEVT_COMMAND_BUTTON_CLICKED, std::bind(&DialogStyleEditor::OnSetColor, this, i + 1, std::placeholders::_1)); } DialogStyleEditor::~DialogStyleEditor() { diff --git a/aegisub/src/dialog_style_manager.cpp b/aegisub/src/dialog_style_manager.cpp index a67083140..08243e5cd 100644 --- a/aegisub/src/dialog_style_manager.cpp +++ b/aegisub/src/dialog_style_manager.cpp @@ -476,16 +476,16 @@ void DialogStyleManager::CopyToClipboard(wxListBox *list, T const& v) { void DialogStyleManager::PasteToCurrent() { add_styles( - bind(&AssFile::GetStyle, c->ass, _1), - bind(&AssFile::InsertStyle, c->ass, _1)); + std::bind(&AssFile::GetStyle, c->ass, _1), + std::bind(&AssFile::InsertStyle, c->ass, _1)); c->ass->Commit(_("style paste"), AssFile::COMMIT_STYLES); } void DialogStyleManager::PasteToStorage() { add_styles( - bind(&AssStyleStorage::GetStyle, &Store, _1), - bind(&AssStyleStorage::push_back, &Store, _1)); + std::bind(&AssStyleStorage::GetStyle, &Store, _1), + std::bind(&AssStyleStorage::push_back, &Store, _1)); UpdateStorage(); StorageList->SetStringSelection(Store.back()->name); @@ -516,7 +516,7 @@ void DialogStyleManager::OnStorageCopy() { if (sel == -1) return; ShowStorageEditor(Store[sel], - unique_name(bind(&AssStyleStorage::GetStyle, &Store, _1), Store[sel]->name)); + unique_name(std::bind(&AssStyleStorage::GetStyle, &Store, _1), Store[sel]->name)); } void DialogStyleManager::OnStorageDelete() { @@ -554,7 +554,7 @@ void DialogStyleManager::OnCurrentCopy() { if (sel == -1) return; ShowCurrentEditor(styleMap[sel], - unique_name(bind(&AssFile::GetStyle, c->ass, _1), styleMap[sel]->name)); + unique_name(std::bind(&AssFile::GetStyle, c->ass, _1), styleMap[sel]->name)); } void DialogStyleManager::OnCurrentDelete() { diff --git a/aegisub/src/ffmpegsource_common.cpp b/aegisub/src/ffmpegsource_common.cpp index 59dcc0aff..a2678b913 100644 --- a/aegisub/src/ffmpegsource_common.cpp +++ b/aegisub/src/ffmpegsource_common.cpp @@ -90,12 +90,6 @@ static int FFMS_CC UpdateIndexingProgress(int64_t Current, int64_t Total, void * return ps->IsCancelled(); } -/// A wrapper around FFMS_DoIndexing to make the signature void -> void -static void DoIndexingWrapper(FFMS_Index **Ret, FFMS_Indexer *Indexer, int IndexMask, int ErrorHandling, void *ICPrivate, FFMS_ErrorInfo *ErrorInfo) { - *Ret = FFMS_DoIndexing(Indexer, IndexMask, FFMS_TRACKMASK_NONE, NULL, NULL, ErrorHandling, - UpdateIndexingProgress, ICPrivate, ErrorInfo); -} - /// @brief Does indexing of a source file /// @param Indexer A pointer to the indexer object representing the file to be indexed /// @param CacheName The filename of the output index file @@ -117,7 +111,9 @@ FFMS_Index *FFmpegSourceProvider::DoIndexing(FFMS_Indexer *Indexer, const wxStri // index all audio tracks FFMS_Index *Index; - Progress.Run(std::bind(DoIndexingWrapper, &Index, Indexer, Trackmask, IndexEH, std::placeholders::_1, &ErrInfo)); + Progress.Run([&](agi::ProgressSink *ps) { + Index = FFMS_DoIndexing(Indexer, Trackmask, FFMS_TRACKMASK_NONE, nullptr, nullptr, IndexEH, UpdateIndexingProgress, ps, &ErrInfo); + }); if (Index == NULL) { MsgString.Append("Failed to index: ").Append(wxString(ErrInfo.Buffer, wxConvUTF8)); diff --git a/aegisub/src/mkv_wrap.cpp b/aegisub/src/mkv_wrap.cpp index 3150b792f..76a1c0757 100644 --- a/aegisub/src/mkv_wrap.cpp +++ b/aegisub/src/mkv_wrap.cpp @@ -220,7 +220,7 @@ void MatroskaWrapper::GetSubtitles(wxString const& filename, AssFile *target) { // Progress bar double totalTime = double(segInfo->Duration) / timecodeScale; DialogProgress progress(NULL, _("Parsing Matroska"), _("Reading subtitles from Matroska file.")); - progress.Run(bind(read_subtitles, std::placeholders::_1, file, &input, srt, totalTime, &parser)); + progress.Run(std::bind(read_subtitles, std::placeholders::_1, file, &input, srt, totalTime, &parser)); } catch (...) { mkv_Close(file); diff --git a/aegisub/src/spellchecker_hunspell.cpp b/aegisub/src/spellchecker_hunspell.cpp index fa8af2cb0..05e10d5b6 100644 --- a/aegisub/src/spellchecker_hunspell.cpp +++ b/aegisub/src/spellchecker_hunspell.cpp @@ -86,7 +86,7 @@ void HunspellSpellChecker::AddWord(std::string const& word) { ++agi::line_iterator(*stream), agi::line_iterator(), inserter(words, words.end()), - mem_fun_ref(&std::string::empty)); + [](std::string const& str) { return str.empty(); }); } catch (agi::FileNotFoundError&) { LOG_I("dictionary/hunspell/add") << "User dictionary not found; creating it"; diff --git a/aegisub/src/subs_edit_ctrl.cpp b/aegisub/src/subs_edit_ctrl.cpp index f2bac0146..566ab9707 100644 --- a/aegisub/src/subs_edit_ctrl.cpp +++ b/aegisub/src/subs_edit_ctrl.cpp @@ -197,7 +197,7 @@ SubsTextEditCtrl::SubsTextEditCtrl(wxWindow* parent, wxSize wsize, long style, a OPT_SUB("Subtitle/Highlight/Syntax", &SubsTextEditCtrl::UpdateStyle, this); static wxStyledTextEvent evt; - OPT_SUB("App/Call Tips", &SubsTextEditCtrl::UpdateCallTip, this, ref(evt)); + OPT_SUB("App/Call Tips", &SubsTextEditCtrl::UpdateCallTip, this, std::ref(evt)); } SubsTextEditCtrl::~SubsTextEditCtrl() { @@ -269,7 +269,7 @@ void SubsTextEditCtrl::SetStyles() { void SubsTextEditCtrl::UpdateStyle() { StartStyling(0,255); - std::string text = GetTextRaw(); + std::string text = GetTextRaw().data(); if (!OPT_GET("Subtitle/Highlight/Syntax")->GetBool()) { SetStyling(text.size(), 0); diff --git a/aegisub/src/subtitle_format.cpp b/aegisub/src/subtitle_format.cpp index 1280511db..98d52c463 100644 --- a/aegisub/src/subtitle_format.cpp +++ b/aegisub/src/subtitle_format.cpp @@ -244,7 +244,7 @@ void SubtitleFormat::RecombineOverlaps(AssFile &file) { newdlg->End = curdlg->Start; newdlg->Text = prevdlg->Text; - file.Line.insert(find_if(next, file.Line.end(), bind(dialog_start_lt, _1, newdlg)), *newdlg); + file.Line.insert(find_if(next, file.Line.end(), std::bind(dialog_start_lt, _1, newdlg)), *newdlg); } // Overlapping A+B part @@ -255,7 +255,7 @@ void SubtitleFormat::RecombineOverlaps(AssFile &file) { // Put an ASS format hard linewrap between lines newdlg->Text = curdlg->Text + "\\N" + prevdlg->Text; - file.Line.insert(find_if(next, file.Line.end(), bind(dialog_start_lt, _1, newdlg)), *newdlg); + file.Line.insert(find_if(next, file.Line.end(), std::bind(dialog_start_lt, _1, newdlg)), *newdlg); } // Is there an A part after the overlap? @@ -266,7 +266,7 @@ void SubtitleFormat::RecombineOverlaps(AssFile &file) { newdlg->End = prevdlg->End; newdlg->Text = prevdlg->Text; - file.Line.insert(find_if(next, file.Line.end(), bind(dialog_start_lt, _1, newdlg)), *newdlg); + file.Line.insert(find_if(next, file.Line.end(), std::bind(dialog_start_lt, _1, newdlg)), *newdlg); } // Is there a B part after the overlap? @@ -277,7 +277,7 @@ void SubtitleFormat::RecombineOverlaps(AssFile &file) { newdlg->End = curdlg->End; newdlg->Text = curdlg->Text; - file.Line.insert(find_if(next, file.Line.end(), bind(dialog_start_lt, _1, newdlg)), *newdlg); + file.Line.insert(find_if(next, file.Line.end(), std::bind(dialog_start_lt, _1, newdlg)), *newdlg); } next--; @@ -335,12 +335,12 @@ SubtitleFormat *find_or_throw(Cont &container, Pred pred) { const SubtitleFormat *SubtitleFormat::GetReader(wxString const& filename) { LoadFormats(); - return find_or_throw(formats, bind(&SubtitleFormat::CanReadFile, _1, filename)); + return find_or_throw(formats, std::bind(&SubtitleFormat::CanReadFile, _1, filename)); } const SubtitleFormat *SubtitleFormat::GetWriter(wxString const& filename) { LoadFormats(); - return find_or_throw(formats, bind(&SubtitleFormat::CanWriteFile, _1, filename)); + return find_or_throw(formats, std::bind(&SubtitleFormat::CanWriteFile, _1, filename)); } wxString SubtitleFormat::GetWildcards(int mode) { @@ -355,7 +355,7 @@ wxString SubtitleFormat::GetWildcards(int mode) { wxArrayString cur = mode == 0 ? format->GetReadWildcards() : format->GetWriteWildcards(); if (cur.empty()) continue; - for_each(cur.begin(), cur.end(), bind(&wxString::Prepend, _1, "*.")); + for_each(cur.begin(), cur.end(), std::bind(&wxString::Prepend, _1, "*.")); copy(cur.begin(), cur.end(), std::back_inserter(all)); final += "|" + format->GetName() + " (" + wxJoin(cur, ',') + ")|" + wxJoin(cur, ';'); } diff --git a/aegisub/src/visual_tool.cpp b/aegisub/src/visual_tool.cpp index df4dc57a9..08696016e 100644 --- a/aegisub/src/visual_tool.cpp +++ b/aegisub/src/visual_tool.cpp @@ -218,9 +218,9 @@ void VisualTool::OnMouseEvent(wxMouseEvent &event) { if (dragging) { // continue drag if (event.LeftIsDown()) { - for_each(sel_features, bind(&FeatureType::UpdateDrag, _1, + for_each(sel_features, std::bind(&FeatureType::UpdateDrag, _1, mouse_pos - drag_start, shift_down)); - for_each(sel_features, bind(&VisualTool::UpdateDrag, this, _1)); + for_each(sel_features, std::bind(&VisualTool::UpdateDrag, this, _1)); Commit(); need_render = true; } @@ -273,7 +273,7 @@ void VisualTool::OnMouseEvent(wxMouseEvent &event) { c->selectionController->SetActiveLine(active_feature->line); if (InitializeDrag(active_feature)) { - for_each(sel_features, bind(&VisualDraggableFeature::StartDrag, _1)); + for_each(sel_features, std::bind(&VisualDraggableFeature::StartDrag, _1)); dragging = true; parent->CaptureMouse(); } @@ -553,7 +553,7 @@ wxString VisualToolBase::GetLineVectorClip(AssDialogue *diag, int &scale, bool & void VisualToolBase::SetSelectedOverride(wxString const& tag, wxString const& value) { for_each(c->selectionController->GetSelectedSet(), - bind(&VisualToolBase::SetOverride, this, _1, tag, value)); + std::bind(&VisualToolBase::SetOverride, this, _1, tag, value)); } void VisualToolBase::SetOverride(AssDialogue* line, wxString const& tag, wxString const& value) {