[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Toon-members] TooN internal/operators.hh internal/vector.hh t...
From: |
Edward Rosten |
Subject: |
[Toon-members] TooN internal/operators.hh internal/vector.hh t... |
Date: |
Tue, 17 Feb 2009 13:47:31 +0000 |
CVSROOT: /cvsroot/toon
Module name: TooN
Changes by: Edward Rosten <edrosten> 09/02/17 13:47:31
Modified files:
internal : operators.hh vector.hh
test : test2.cc
Log message:
Move operator/= to inside Vector. This allows for:
v.slice<>() /= 2;
Otherwise, it requires a temporary (the result of .slice()) to be passed
as a non-const reference to operator/=(Vector&, double), which is
disallowed
in C++.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/internal/operators.hh?cvsroot=toon&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/TooN/internal/vector.hh?cvsroot=toon&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/TooN/test/test2.cc?cvsroot=toon&r1=1.1&r2=1.2
Patches:
Index: internal/operators.hh
===================================================================
RCS file: /cvsroot/toon/TooN/internal/operators.hh,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- internal/operators.hh 17 Feb 2009 13:40:32 -0000 1.2
+++ internal/operators.hh 17 Feb 2009 13:47:30 -0000 1.3
@@ -86,16 +86,6 @@
return lhs;
}
-// operator /= double
-template<int Size, typename Precision, typename Base>
-Vector<Size, Precision, Base>& operator /= (Vector<Size, Precision, Base>&
lhs, double rhs){
- const int s=lhs.size();
- for(int i=0; i<s; i++){
- lhs[i]/=rhs;
- }
- return lhs;
-}
-
// output operator <<
template <int Size, typename Precision, typename Base>
inline std::ostream& operator<< (std::ostream& os, const
Vector<Size,Precision,Base>& v){
Index: internal/vector.hh
===================================================================
RCS file: /cvsroot/toon/TooN/internal/vector.hh,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- internal/vector.hh 17 Feb 2009 13:40:32 -0000 1.10
+++ internal/vector.hh 17 Feb 2009 13:47:30 -0000 1.11
@@ -60,4 +60,13 @@
return *this;
}
+
+ Vector& operator/=(const Precision& rhs)
+ {
+ for(int i=0; i<Base::size(); i++)
+ (*this)[i]/=rhs;
+ return *this;
+ }
+
+
};
Index: test/test2.cc
===================================================================
RCS file: /cvsroot/toon/TooN/test/test2.cc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- test/test2.cc 17 Feb 2009 13:40:32 -0000 1.1
+++ test/test2.cc 17 Feb 2009 13:47:30 -0000 1.2
@@ -10,6 +10,7 @@
cout << v1 + v2 << endl;
-
+ v1.slice<0, 2>() /= 2;
+ cout << v1 << endl;
}
- [Toon-members] TooN internal/operators.hh internal/vector.hh t...,
Edward Rosten <=