]> git.lyx.org Git - features.git/commitdiff
Fix a strange warning in QtCreator:
authorRichard Kimberly Heck <rikiheck@lyx.org>
Fri, 14 Feb 2020 16:11:12 +0000 (11:11 -0500)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:52 +0000 (15:48 +0200)
/cvs/lyx/lyx-devel/src/frontends/qt/TocModel.cpp:356: warning: loop variable 'toc' has type 'const pair<std::string, shared_ptr<lyx::Toc> > &' (aka 'const pair<basic_string<char>, shared_ptr<vector<lyx::TocItem> > > &') but is initialized with type 'const std::pair<const std::__cxx11::basic_string<char>, std::shared_ptr<std::vector<lyx::TocItem, std::allocator<lyx::TocItem> > > >' resulting in a copy

/cvs/lyx/lyx-devel/src/frontends/qt/TocModel.cpp:356: use non-reference type 'pair<std::string, shared_ptr<lyx::Toc> >' (aka 'pair<basic_string<char>, shared_ptr<vector<lyx::TocItem> > >') to keep the copy or type 'const std::pair<const std::__cxx11::basic_string<char>, std::shared_ptr<std::vector<lyx::TocItem, std::allocator<lyx::TocItem> > > > &' to prevent copying

Easier just to use 'auto'.

src/frontends/qt/TocModel.cpp

index 51365311aa9eba703bfeda79a7243a7e114f8db2..e43b3df445e792650a531bd1b72342b7480817c5 100644 (file)
@@ -353,7 +353,7 @@ void TocModels::reset(BufferView const * bv)
        names_->insertColumns(0, 1);
        // In the outliner, add Tocs from the master document
        TocBackend const & backend = bv->buffer().masterBuffer()->tocBackend();
-       for (pair<string, shared_ptr<Toc>> const & toc : backend.tocs()) {
+       for (auto const & toc : backend.tocs()) {
                QString const type = toqstr(toc.first);
 
                // First, fill in the toc models.