diff --git a/far/PluginA.cpp b/far/PluginA.cpp index 96b5a09c21..f4e5492faf 100644 --- a/far/PluginA.cpp +++ b/far/PluginA.cpp @@ -2665,7 +2665,7 @@ static intptr_t WINAPI FarSendDlgMessageA(HANDLE hDlg, int OldMsg, int Param1, v FarDialogItemData did{ sizeof(did), static_cast(didA->PtrLength), text.data() }; intptr_t ret = pluginapi::apiSendDlgMessage(hDlg, DM_GETTEXT, Param1, &did); didA->PtrLength = static_cast(did.PtrLength); - (void)encoding::oem::get_bytes({ text.data(), did.PtrLength }, { didA->PtrData, static_cast(didA->PtrLength + 1) }); + (void)encoding::oem::get_bytes({ text.data(), did.PtrLength }, { didA->PtrData, static_cast(didA->PtrLength) + 1 }); return ret; } case oldfar::DM_GETTEXTLENGTH: Msg = DM_GETTEXT; break; @@ -3206,7 +3206,7 @@ static int WINAPI FarDialogExA(intptr_t PluginNumber, int X1, int Y1, int X2, in NewDialogData.di = di.data(); NewDialogData.l = l.data(); - Dialogs().emplace(hDlg, NewDialogData); + Dialogs().try_emplace(hDlg, NewDialogData); SCOPE_EXIT{ Dialogs().erase(hDlg); }; const auto ret = pluginapi::apiDialogRun(hDlg); @@ -3706,7 +3706,7 @@ static intptr_t WINAPI FarAdvControlA(intptr_t ModuleNumber, oldfar::ADVANCED_CO { std::vector Color(PaletteSize + 1); pluginapi::apiAdvControl(GetPluginUuid(ModuleNumber), ACTL_GETARRAYCOLOR, Color.size(), Color.data()); - Color.insert(Color.begin() + oldfar::COL_RESERVED0, FarColor{}); + Color.emplace(Color.begin() + oldfar::COL_RESERVED0); const auto OldColors = static_cast(Param); std::ranges::transform(Color, OldColors, colors::FarColorToConsoleColor); } diff --git a/far/colormix.cpp b/far/colormix.cpp index e228a69c6c..8f9bf98c12 100644 --- a/far/colormix.cpp +++ b/far/colormix.cpp @@ -506,7 +506,7 @@ namespace colors ); }; - return Map.emplace(Color, std::ranges::min_element(Palette.begin() + Skip, Palette.end(), {}, distance) - Palette.begin()).first->second; + return Map.try_emplace(Color, std::ranges::min_element(Palette.begin() + Skip, Palette.end(), {}, distance) - Palette.begin()).first->second; } struct index_color_16 diff --git a/far/console.cpp b/far/console.cpp index 44f1032256..fed5e98318 100644 --- a/far/console.cpp +++ b/far/console.cpp @@ -1066,7 +1066,7 @@ namespace console_detail static bool layout_has_altgr(HKL const Layout) { static std::unordered_map LayoutState; - const auto [Iterator, Inserted] = LayoutState.emplace(Layout, false); + const auto [Iterator, Inserted] = LayoutState.try_emplace(Layout, false); if (!Inserted) return Iterator->second; @@ -1906,7 +1906,7 @@ namespace console_detail return ::console.Write(CSI L"m"sv); } - class cursor_suppressor: public hide_cursor + class cursor_suppressor: hide_cursor { public: NONCOPYABLE(cursor_suppressor); @@ -2941,7 +2941,6 @@ namespace console_detail LOGINFO(L"Reinitializing"sv); initialize(); - return 1; } DWORD Written; diff --git a/far/diskmenu.cpp b/far/diskmenu.cpp index b768ecaf4a..f5e3c2ebf4 100644 --- a/far/diskmenu.cpp +++ b/far/diskmenu.cpp @@ -195,7 +195,7 @@ static void AddPluginItems(VMenu2 &ChDisk, int Pos, int DiskCount, bool SetSelec #endif // NO_WRAPPER LIF_NONE; - MenuInitItems.push_back({ std::move(strPluginText), Flags, HotKey, { pPlugin, Uuid } }); + MenuInitItems.emplace_back(std::move(strPluginText), Flags, HotKey, plugin_item{ pPlugin, Uuid }); } } } diff --git a/far/edit.cpp b/far/edit.cpp index b5c9e2dca0..5e33477062 100644 --- a/far/edit.cpp +++ b/far/edit.cpp @@ -86,7 +86,7 @@ class positions_cache return *Value; } - const auto [Iterator, IsNew] = m_BigPositions.emplace(Position, 0); + const auto [Iterator, IsNew] = m_BigPositions.try_emplace(Position, 0); if (IsNew) Iterator->second = m_Accessor(Position, &m_State); diff --git a/far/filefilter.cpp b/far/filefilter.cpp index 4790e56402..39de10d094 100644 --- a/far/filefilter.cpp +++ b/far/filefilter.cpp @@ -175,7 +175,7 @@ static void ParseAndAddMasks(std::map& E return; const auto Ext = name_ext(FileName).second; - Extensions.emplace(Ext.empty()? L"*."s : concat(L'*', Ext), Check); + Extensions.emplace(Ext.empty()? L"*."sv : concat(L'*', Ext), Check); } static wchar_t GetCheck(filter_area const Type, const FileFilterParams& FFP) @@ -555,7 +555,7 @@ static void ProcessSelection(VMenu2* const FilterList, filter_area const Area) NewFilter.SetMask(true, Mask.find_first_of(L",;"sv, L"*."sv.size()) == string::npos? Mask : quote(Mask)); //Авто фильтры они только для файлов, папки не должны к ним подходить NewFilter.SetAttr(true, 0, FILE_ATTRIBUTE_DIRECTORY); - const auto NewIterator = TempFilterData().emplace(Mask, std::move(NewFilter)).first; + const auto NewIterator = TempFilterData().try_emplace(Mask, std::move(NewFilter)).first; CurFilterData = &NewIterator->second; } } @@ -964,7 +964,7 @@ void filters::InitFilters() } } - TempFilterData().emplace(unquote(std::move(Mask)), std::move(NewItem)); + TempFilterData().try_emplace(unquote(std::move(Mask)), std::move(NewItem)); } } diff --git a/far/filelist.cpp b/far/filelist.cpp index 1a301906dc..88241e0afa 100644 --- a/far/filelist.cpp +++ b/far/filelist.cpp @@ -511,8 +511,8 @@ FileList::FileList(private_tag, window_ptr Owner): { if (const auto& data = msg(lng::MPanelBracketsForLongName); data.size() > 1) { - *openBracket = data[0]; - *closeBracket = data[1]; + openBracket = data[0]; + closeBracket = data[1]; } m_CurDir = os::fs::get_current_directory(); diff --git a/far/filelist.hpp b/far/filelist.hpp index 1ce08ffd0f..0e36886f3b 100644 --- a/far/filelist.hpp +++ b/far/filelist.hpp @@ -318,7 +318,7 @@ class FileList final: public Panel Открывающий и закрывающий символ, которые используются для показа имени, которое не помещается в панели. По умолчанию - фигурные скобки. */ - wchar_t openBracket[2]{L'{'}, closeBracket[2]{L'}'}; + wchar_t openBracket{L'{'}, closeBracket{L'}'}; string strOriginalCurDir; string strPluginDizName; diff --git a/far/filemasks.cpp b/far/filemasks.cpp index 3245a7488e..84aa18e1cb 100644 --- a/far/filemasks.cpp +++ b/far/filemasks.cpp @@ -421,7 +421,7 @@ bool filemasks::masks::operator==(const string_view FileName) const Data.Match.assign(ALL_CONST_RANGE(Match.Matches)); for (const auto& [k, v]: NamedMatch.Matches) - Data.NamedMatch.emplace(k, v); + Data.NamedMatch.try_emplace(k, v); return true; } }, m_Masks); diff --git a/far/filetype.cpp b/far/filetype.cpp index 917c18d8bc..c8ed02989c 100644 --- a/far/filetype.cpp +++ b/far/filetype.cpp @@ -105,7 +105,7 @@ bool ProcessLocalFileTypes(string_view const Name, string_view const ShortName, { for (const auto& i: Data.Matches) { - Context.Variables.emplace( + Context.Variables.try_emplace( far::format(L"RegexGroup{}"sv, &i - Data.Matches.data()), get_match(Context.Name, i) ); @@ -114,7 +114,7 @@ bool ProcessLocalFileTypes(string_view const Name, string_view const ShortName, for (const auto& [GroupName, GroupNumber]: Data.NamedMatches) { const auto& Match = Data.Matches[GroupNumber]; - Context.Variables.emplace( + Context.Variables.try_emplace( far::format(L"RegexGroup{{{}}}"sv, GroupName), get_match(Context.Name, Match) ); diff --git a/far/fnparce.cpp b/far/fnparce.cpp index ca8af5652a..2fd5e1a14e 100644 --- a/far/fnparce.cpp +++ b/far/fnparce.cpp @@ -872,7 +872,7 @@ static bool InputVariablesDialog(string& strStr, subst_data& SubstData, string_v if (!i.strHistory.empty() && i.strHistory != GenerateHistoryName(Index)) { replace_icase(strTmpStr, L'%' + i.strHistory, i.strData); - SubstData.Variables->emplace(i.strHistory, i.strData); + SubstData.Variables->try_emplace(i.strHistory, i.strData); } } diff --git a/far/language.cpp b/far/language.cpp index de1829862b..8f85c8ee06 100644 --- a/far/language.cpp +++ b/far/language.cpp @@ -342,7 +342,7 @@ static void LoadCustomStrings(string_view const FileName, unordered_string_map(get_match(i.Str, m[1]), {}, 16); - Symbols.emplace(Address, std::move(Line)); + Symbols.try_emplace(Address, std::move(Line)); continue; } @@ -292,7 +292,7 @@ static void read_gcc(std::istream& Stream, unordered_string_set& Files, std::map Line.Name = get_match(i.Str, m[2]); Line.File = std::to_address(Files.emplace(FileName).first); const auto Address = from_string(get_match(i.Str, m[1]), {}, 16) + BaseAddress; - Symbols.emplace(Address, std::move(Line)); + Symbols.try_emplace(Address, std::move(Line)); continue; } diff --git a/far/notification.cpp b/far/notification.cpp index ae8150c1b8..cdd86a1806 100644 --- a/far/notification.cpp +++ b/far/notification.cpp @@ -185,7 +185,7 @@ bool message_manager::dispatch() const auto [Begin, End] = Handlers.equal_range(EventId); for (const auto& [Key, Value]: std::ranges::subrange(Begin, End)) { - EligibleHandlers.emplace(Value, false); + EligibleHandlers.try_emplace(Value, false); } }; diff --git a/far/platform.cpp b/far/platform.cpp index 42d6b1b34c..e1bcc6484d 100644 --- a/far/platform.cpp +++ b/far/platform.cpp @@ -808,7 +808,7 @@ static auto keyboard_layout_list_hr(std::span const List) if (!from_string(*LayoutIdStr, LayoutId, {}, 16)) continue; - SpecialLayouts.emplace(LayoutId, Key); + SpecialLayouts.try_emplace(LayoutId, Key); } } } diff --git a/far/platform.debug.cpp b/far/platform.debug.cpp index a8eae8fedd..1430abb247 100644 --- a/far/platform.debug.cpp +++ b/far/platform.debug.cpp @@ -303,7 +303,7 @@ namespace os::debug const auto handler = [&](uintptr_t const Address, DWORD const InlineFrameContext) { - Result.push_back({ Address, InlineFrameContext }); + Result.emplace_back(Address, InlineFrameContext); }; if (imports.StackWalkEx) diff --git a/far/platform.fs.cpp b/far/platform.fs.cpp index 550ec4d8d7..9988686e20 100644 --- a/far/platform.fs.cpp +++ b/far/platform.fs.cpp @@ -1125,7 +1125,7 @@ namespace os::fs // Mapped drives resolve to \Device\WinDfs\X:\server\share if (const auto DfsPrefix = L"\\Device\\WinDfs\\"sv; NtPath.starts_with(DfsPrefix)) { - const auto ServerStart = NtPath.find(L"\\", DfsPrefix.size()); + const auto ServerStart = NtPath.find(L'\\', DfsPrefix.size()); FinalFilePath = NtPath.replace(0, ServerStart, 1, L'\\'); return true; } @@ -2395,7 +2395,7 @@ namespace os::fs return true; if (ElevationRequired(ELEVATION_READ_REQUEST)) - return elevation::instance().get_disk_free_space(strPath.c_str(), UserFree, UserTotal, TotalFree); + return elevation::instance().get_disk_free_space(strPath, UserFree, UserTotal, TotalFree); return false; } diff --git a/far/stddlg.cpp b/far/stddlg.cpp index 19f759a3c5..07df5991ba 100644 --- a/far/stddlg.cpp +++ b/far/stddlg.cpp @@ -1303,7 +1303,7 @@ void regex_playground() for (const auto& [i, Index] : enumerate(Match.Matches)) { ListStrings.emplace_back(far::format(L"${}: {}"sv, Index, match_str(i))); - ListItems.push_back({ i.start < 0? LIF_GRAYED : LIF_NONE, ListStrings.back().c_str(), 0, 0 }); + ListItems.emplace_back(i.start < 0? LIF_GRAYED : LIF_NONE, ListStrings.back().c_str(), 0, 0); } for (const auto& [k, v] : NamedMatch.Matches) diff --git a/far/treelist.cpp b/far/treelist.cpp index a0d5f60062..780fe65c19 100644 --- a/far/treelist.cpp +++ b/far/treelist.cpp @@ -1351,7 +1351,7 @@ int TreeList::GetNextNavPos() const { int NextPos=m_CurFile; - if (static_cast(m_CurFile + 1) < m_ListData.size()) + if (static_cast(m_CurFile) + 1 < m_ListData.size()) { const auto CurDepth = m_ListData[m_CurFile].Depth; diff --git a/far/vmenu.cpp b/far/vmenu.cpp index 2f99ed76f4..a10e3aa2ce 100644 --- a/far/vmenu.cpp +++ b/far/vmenu.cpp @@ -2207,7 +2207,7 @@ bool VMenu::AlignAnnotations() if (!CheckFlags(VMENU_ENABLEALIGNANNOTATIONS)) return false; const auto TextAreaWidth{ CalculateTextAreaWidth() }; - if (TextAreaWidth <= 0 || TextAreaWidth + 2 <= 0) return false; + if (TextAreaWidth <= 0) return false; const auto AlignPos{ (TextAreaWidth + 2) / 4 }; return SetAllItemsHPos( @@ -2437,7 +2437,7 @@ void VMenu::DrawMenu() if (Layout.Scrollbar) { set_color(Colors, color_indices::ScrollBar); - ScrollBar(Layout.Scrollbar.value(), Layout.ClientRect.top, Layout.ClientRect.height(), VisualTopPos, GetShowItemCount()); + ScrollBar(*Layout.Scrollbar, Layout.ClientRect.top, Layout.ClientRect.height(), VisualTopPos, GetShowItemCount()); } } @@ -2608,7 +2608,7 @@ void VMenu::DrawRegularItem(const MenuItemEx& Item, const menu_layout& Layout, c { if (!Layout.TextArea) return; - const auto [TextAreaBegin, TextAreaWidth] { Layout.TextArea.value() }; + const auto [TextAreaBegin, TextAreaWidth] { *Layout.TextArea }; GotoXY(TextAreaBegin, Y); @@ -2671,16 +2671,16 @@ void VMenu::DrawRegularItem(const MenuItemEx& Item, const menu_layout& Layout, c }; if (Layout.CheckMark) - DrawDecorator(Layout.CheckMark.value(), get_item_check_mark(Item, ColorIndices)); + DrawDecorator(*Layout.CheckMark, get_item_check_mark(Item, ColorIndices)); if (Layout.LeftHScroll) - DrawDecorator(Layout.LeftHScroll.value(), get_item_left_hscroll(Item.HorizontalPosition < 0, ColorIndices)); + DrawDecorator(*Layout.LeftHScroll, get_item_left_hscroll(Item.HorizontalPosition < 0, ColorIndices)); if (Layout.SubMenu) - DrawDecorator(Layout.SubMenu.value(), get_item_submenu(Item, ColorIndices)); + DrawDecorator(*Layout.SubMenu, get_item_submenu(Item, ColorIndices)); if (Layout.RightHScroll) - DrawDecorator(Layout.RightHScroll.value(), get_item_right_hscroll(Item.HorizontalPosition + ItemTextSize > TextAreaWidth, ColorIndices)); + DrawDecorator(*Layout.RightHScroll, get_item_right_hscroll(Item.HorizontalPosition + ItemTextSize > TextAreaWidth, ColorIndices)); } int VMenu::CheckHighlights(wchar_t CheckSymbol, int StartPos) const @@ -3263,7 +3263,7 @@ void VMenu::EnableFilter(bool const Enable) int VMenu::CalculateTextAreaWidth() const { const auto TextArea = menu_layout{ *this }.TextArea; - return TextArea ? TextArea.value().second : 0; + return TextArea? TextArea->second : 0; } size_t VMenu::Text(string_view const Str) const