Skip to content

Commit

Permalink
make printNavType return std::string instead std::ostream
Browse files Browse the repository at this point in the history
The way `printNavType` is used in `test/ModuleNumbering.cc` it attempts
to put `std::ostream` into `std::ostream`, which is not allowed by
C++11 or above.

Refactor `printNavType` to return `std::string` instead and adjust
related `operator<<`.

Needed by GCC 5.3.0.

Signed-off-by: David Abdurachmanov <[email protected]>
  • Loading branch information
David Abdurachmanov authored and David Abdurachmanov committed Dec 11, 2015
1 parent 4d0e8c8 commit e5cacfd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
8 changes: 5 additions & 3 deletions DetectorDescription/Core/interface/DDExpandedView.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,13 @@ class DDExpandedView
std::vector<nav_type> nextBStack_;
};

std::ostream & printNavType(std::ostream &, int const * n, size_t sz);
std::string printNavType(int const * n, size_t sz);
inline std::ostream & operator<<(std::ostream & os, const DDExpandedView::nav_type & n) {
return printNavType(os,&n.front(),n.size());
os << printNavType(&n.front(),n.size());
return os;
}
inline std::ostream & operator<<(std::ostream & os, const DDExpandedView::NavRange & n) {
return printNavType(os,n.first,n.second);
os << printNavType(n.first,n.second);
return os;
}
#endif
11 changes: 6 additions & 5 deletions DetectorDescription/Core/src/DDExpandedView.cc
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,12 @@ DDExpandedView::nav_type DDExpandedView::copyNumbers() const
return result;
}

std::ostream & printNavType(std::ostream & os, int const * n, size_t sz){
os << '(' ;
std::string printNavType(int const * n, size_t sz){
std::ostringstream oss;
oss << '(' ;
for (int const * it=n; it != n+sz; ++it) {
os << *it << ',';
oss << *it << ',';
}
os << ')';
return os;
oss << ')';
return oss.str();
}
8 changes: 4 additions & 4 deletions Geometry/TrackerNumberingBuilder/test/ModuleNumbering.cc
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ ModuleNumbering::analyze( const edm::Event& iEvent, const edm::EventSetup& iSetu
GeometricDet::nav_type detNavType = mapDetIdToGeometricDet[myDetId]->navType();
//
Output << " raw Id = " << rawid << " (" << binary_detid << ")"
<< "\t nav type = " << printNavType(Output,&detNavType.front(),detNavType.size()) << std::endl;
<< "\t nav type = " << printNavType(&detNavType.front(),detNavType.size()) << std::endl;

// variables
fillModuleVariables(mapDetIdToGeometricDet[myDetId], polarRadius, phiRad, z);
Expand Down Expand Up @@ -492,7 +492,7 @@ ModuleNumbering::analyze( const edm::Event& iEvent, const edm::EventSetup& iSetu
GeometricDet::nav_type detNavType = mapDetIdToGeometricDet[myDetId]->navType();
//
Output << " raw Id = " << rawid << " (" << binary_detid << ")"
<< "\t nav type = " << printNavType(Output,&detNavType.front(),detNavType.size()) << std::endl;
<< "\t nav type = " << printNavType(&detNavType.front(),detNavType.size()) << std::endl;

// variables
fillModuleVariables(mapDetIdToGeometricDet[myDetId], polarRadius, phiRad, z);
Expand Down Expand Up @@ -669,7 +669,7 @@ ModuleNumbering::analyze( const edm::Event& iEvent, const edm::EventSetup& iSetu
GeometricDet::nav_type detNavType = mapDetIdToGeometricDet[myDetId]->navType();
//
Output << " raw Id = " << rawid << " (" << binary_detid << ")"
<< "\t nav type = " << printNavType(Output,&detNavType.front(),detNavType.size()) << std::endl;
<< "\t nav type = " << printNavType(&detNavType.front(),detNavType.size()) << std::endl;

// variables
fillModuleVariables(mapDetIdToGeometricDet[myDetId], polarRadius, phiRad, z);
Expand Down Expand Up @@ -880,7 +880,7 @@ ModuleNumbering::analyze( const edm::Event& iEvent, const edm::EventSetup& iSetu
GeometricDet::nav_type detNavType = mapDetIdToGeometricDet[myDetId]->navType();
//
Output << " raw Id = " << rawid << " (" << binary_detid << ")"
<< "\t nav type = " << printNavType(Output,&detNavType.front(),detNavType.size()) << std::endl;
<< "\t nav type = " << printNavType(&detNavType.front(),detNavType.size()) << std::endl;

// variables
fillModuleVariables(mapDetIdToGeometricDet[myDetId], polarRadius, phiRad, z);
Expand Down

0 comments on commit e5cacfd

Please sign in to comment.