Commit d407ea90 authored by BRAMAS Berenger's avatar BRAMAS Berenger

Put a template for the stream operator and add a function in math.hpp

parent a5d07478
...@@ -222,7 +222,8 @@ public: ...@@ -222,7 +222,8 @@ public:
* @param[in] inCoordinate the coordinate to write out * @param[in] inCoordinate the coordinate to write out
* @return the output for multiple << operators * @return the output for multiple << operators
*/ */
friend std::ostream& operator<<(std::ostream& output, const FTreeCoordinate& inCoordinate){ template <class StreamClass>
friend StreamClass& operator<<(StreamClass& output, const FTreeCoordinate& inCoordinate){
output << "(" << inCoordinate.getX() << ", " << inCoordinate.getY() << ", " << inCoordinate.getZ() <<")"; output << "(" << inCoordinate.getX() << ", " << inCoordinate.getY() << ", " << inCoordinate.getZ() <<")";
return output; // for multiple << operators. return output; // for multiple << operators.
} }
......
...@@ -191,7 +191,8 @@ public: ...@@ -191,7 +191,8 @@ public:
* @param[in] inPosition the position to write out * @param[in] inPosition the position to write out
* @return the output for multiple << operators * @return the output for multiple << operators
*/ */
friend std::ostream& operator<<(std::ostream& output, const FComplexe& inC){ template <class StreamClass>
friend StreamClass& operator<<(StreamClass& output, const FComplexe& inC){
output << "(" << inC.getReal() << ", " << inC.getImag() << ")"; output << "(" << inC.getReal() << ", " << inC.getImag() << ")";
return output; // for multiple << operators. return output; // for multiple << operators.
} }
......
...@@ -81,7 +81,7 @@ struct FMath{ ...@@ -81,7 +81,7 @@ struct FMath{
/** To get pow */ /** To get pow */
template <class NumType> template <class NumType>
static NumType pow(const NumType inValue, long power){ static NumType pow(const NumType inValue, int power){
NumType result = 1; NumType result = 1;
while(power-- > 0) result *= inValue; while(power-- > 0) result *= inValue;
return result; return result;
......
...@@ -287,7 +287,8 @@ public: ...@@ -287,7 +287,8 @@ public:
* @param[in] inPosition the position to write out * @param[in] inPosition the position to write out
* @return the output for multiple << operators * @return the output for multiple << operators
*/ */
friend std::ostream& operator<<(std::ostream& output, const FPoint& inPosition){ template <class StreamClass>
friend StreamClass& operator<<(StreamClass& output, const FPoint& inPosition){
output << "(" << inPosition.getX() << ", " << inPosition.getY() << ", " << inPosition.getZ() <<")"; output << "(" << inPosition.getX() << ", " << inPosition.getY() << ", " << inPosition.getZ() <<")";
return output; // for multiple << operators. return output; // for multiple << operators.
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment