diff --git a/aegisub/src/subs_edit_box.cpp b/aegisub/src/subs_edit_box.cpp index 3c9debfd6..a8dda2805 100644 --- a/aegisub/src/subs_edit_box.cpp +++ b/aegisub/src/subs_edit_box.cpp @@ -67,14 +67,6 @@ #include namespace { -template -struct field_setter : public std::binary_function { - T AssDialogue::*field; - field_setter(T AssDialogue::*field) : field(field) { } - void operator()(AssDialogue* obj, T const& value) { - obj->*field = value; - } -}; /// Work around wxGTK's fondness for generating events from ChangeValue void change_value(wxTextCtrl *ctrl, wxString const& value) { @@ -386,7 +378,7 @@ void SubsEditBox::OnUndoTimer(wxTimerEvent&) { } template -void SubsEditBox::SetSelectedRows(setter set, T value, wxString desc, int type, bool amend) { +void SubsEditBox::SetSelectedRows(setter set, T value, wxString const& desc, int type, bool amend) { for_each(sel.begin(), sel.end(), bind(set, std::placeholders::_1, value)); file_changed_slot.Block(); @@ -399,8 +391,8 @@ void SubsEditBox::SetSelectedRows(setter set, T value, wxString desc, int type, } template -void SubsEditBox::SetSelectedRows(T AssDialogue::*field, T value, wxString desc, int type, bool amend) { - SetSelectedRows(field_setter(field), value, desc, type, amend); +void SubsEditBox::SetSelectedRows(T AssDialogue::*field, T value, wxString const& desc, int type, bool amend) { + SetSelectedRows([=](AssDialogue *d, T const& v) { d->*field = v; }, value, desc, type, amend); } void SubsEditBox::CommitText(wxString const& desc) { diff --git a/aegisub/src/subs_edit_box.h b/aegisub/src/subs_edit_box.h index 1e82c10f7..12361241b 100644 --- a/aegisub/src/subs_edit_box.h +++ b/aegisub/src/subs_edit_box.h @@ -173,7 +173,7 @@ class SubsEditBox : public wxPanel { /// @param type Commit type to use /// @param amend Coalesce sequences of commits of the same type template - void SetSelectedRows(setter set, T value, wxString desc, int type, bool amend = false); + void SetSelectedRows(setter set, T value, wxString const& desc, int type, bool amend = false); /// @brief Set a field in each selected line to a specified value /// @param field Field to set @@ -182,7 +182,7 @@ class SubsEditBox : public wxPanel { /// @param type Commit type to use /// @param amend Coalesce sequences of commits of the same type template - void SetSelectedRows(T AssDialogue::*field, T value, wxString desc, int type, bool amend = false); + void SetSelectedRows(T AssDialogue::*field, T value, wxString const& desc, int type, bool amend = false); /// @brief Reload the current line from the file /// @param type AssFile::CommitType