Skip to content

Commit

Permalink
BUG: Second argument to stream operator<< as const
Browse files Browse the repository at this point in the history
The second argument to the stream insertion operator
should be a constant reference or pointer.

operator<<(std::ostream & os, const EventObject & e)

Stream insertion should not modify the object
being inserted.
  • Loading branch information
hjmjohnson authored and dzenanz committed Dec 14, 2019
1 parent 0cf2baf commit 5a0c06a
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkAutoPointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class AutoPointer

template <typename T>
std::ostream &
operator<<(std::ostream & os, AutoPointer<T> p)
operator<<(std::ostream & os, const AutoPointer<T> p)
{
p.Print(os);
os << "Owner: " << p.IsOwner() << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkEventObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class ITKCommon_EXPORT EventObject

/** Generic inserter operator for EventObject and its subclasses. */
inline std::ostream &
operator<<(std::ostream & os, EventObject & e)
operator<<(std::ostream & os, const EventObject & e)
{
(&e)->Print(os);
return os;
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkExceptionObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class ITKCommon_EXPORT ExceptionObject : public std::exception

/** Generic inserter operator for ExceptionObject and its subclasses. */
inline std::ostream &
operator<<(std::ostream & os, ExceptionObject & e)
operator<<(std::ostream & os, const ExceptionObject & e)
{
(&e)->Print(os);
return os;
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkSmartPointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ operator>=(const SmartPointer<T> & l, const SmartPointer<TU> & r) noexcept

template <typename T>
std::ostream &
operator<<(std::ostream & os, SmartPointer<T> p)
operator<<(std::ostream & os, const SmartPointer<T> p)
{
p.Print(os);
return os;
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkTreeIteratorClone.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class TreeIteratorClone

template <typename T>
std::ostream &
operator<<(std::ostream & os, TreeIteratorClone<T> p)
operator<<(std::ostream & os, const TreeIteratorClone<T> p)
{
p.Print(os);
return os;
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkWeakPointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class WeakPointer

template <typename T>
std::ostream &
operator<<(std::ostream & os, WeakPointer<T> p)
operator<<(std::ostream & os, const WeakPointer<T> p)
{
p.Print(os);
return os;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,6 @@ class ITKPolynomials_EXPORT MultivariateLegendrePolynomial
}; // end of class

ITKPolynomials_EXPORT std::ostream &
operator<<(std::ostream & os, MultivariateLegendrePolynomial & poly);
operator<<(std::ostream & os, const MultivariateLegendrePolynomial & poly);
} // end of namespace itk
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ MultivariateLegendrePolynomial ::GetNumberOfCoefficients()
}

std::ostream &
operator<<(std::ostream & os, MultivariateLegendrePolynomial & poly)
operator<<(std::ostream & os, const MultivariateLegendrePolynomial & poly)
{
poly.Print(os);
return os;
Expand Down

0 comments on commit 5a0c06a

Please sign in to comment.