[LyX/master] Fix a strange warning in QtCreator:

Richard Kimberly Heck rikiheck at lyx.org
Mon Feb 17 17:16:28 UTC 2020


commit fb03f2a5ecb60dd029cf8f2a7cfe021fdcee7231
Author: Richard Kimberly Heck <rikiheck at lyx.org>
Date:   Fri Feb 14 11:11:12 2020 -0500

    Fix a strange warning in QtCreator:
    
    /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 |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/frontends/qt/TocModel.cpp b/src/frontends/qt/TocModel.cpp
index 5136531..e43b3df 100644
--- a/src/frontends/qt/TocModel.cpp
+++ b/src/frontends/qt/TocModel.cpp
@@ -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.


More information about the lyx-cvs mailing list