[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Toon-members] TooN/internal operators.hh
From: |
Edward Rosten |
Subject: |
[Toon-members] TooN/internal operators.hh |
Date: |
Wed, 25 Mar 2009 17:51:34 +0000 |
CVSROOT: /cvsroot/toon
Module name: TooN
Changes by: Edward Rosten <edrosten> 09/03/25 17:51:34
Modified files:
internal : operators.hh
Log message:
Better way of feeding types to typeof
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/internal/operators.hh?cvsroot=toon&r1=1.20&r2=1.21
Patches:
Index: operators.hh
===================================================================
RCS file: /cvsroot/toon/TooN/internal/operators.hh,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- operators.hh 20 Mar 2009 17:21:31 -0000 1.20
+++ operators.hh 25 Mar 2009 17:51:34 -0000 1.21
@@ -115,11 +115,13 @@
struct Multiply{ template<class A, class B, class C> static A op(const
B& b, const C& c){return b*c;} };
struct Divide{ template<class A, class B, class C> static A op(const
B& b, const C& c){return b/c;} };
+ template<class C> C gettype();
+
//Automatic type deduction of return types
- template<class L, class R> struct AddType { typedef TOON_TYPEOF(
(*static_cast<L*>(0) + *static_cast<R*>(0))) type;};
- template<class L, class R> struct SubtractType { typedef TOON_TYPEOF(
(*static_cast<L*>(0) - *static_cast<R*>(0))) type;};
- template<class L, class R> struct MultiplyType { typedef TOON_TYPEOF(
(*static_cast<L*>(0) * *static_cast<R*>(0))) type;};
- template<class L, class R> struct DivideType { typedef TOON_TYPEOF(
(*static_cast<L*>(0) / *static_cast<R*>(0))) type;};
+ template<class L, class R> struct AddType { typedef
TOON_TYPEOF(gettype<L>()+gettype<R>()) type;};
+ template<class L, class R> struct SubtractType { typedef
TOON_TYPEOF(gettype<L>()-gettype<R>()) type;};
+ template<class L, class R> struct MultiplyType { typedef
TOON_TYPEOF(gettype<L>()*gettype<R>()) type;};
+ template<class L, class R> struct DivideType { typedef
TOON_TYPEOF(gettype<L>()/gettype<R>()) type;};
//Output size, given input size. Be static if possible.
template<int i, int j> struct Sizer{static const int size=i;};
- [Toon-members] TooN/internal operators.hh, Edward Rosten, 2009/03/06
- [Toon-members] TooN/internal operators.hh, Tom Drummond, 2009/03/09
- [Toon-members] TooN/internal operators.hh, Edward Rosten, 2009/03/10
- [Toon-members] TooN/internal operators.hh, Tom Drummond, 2009/03/10
- [Toon-members] TooN/internal operators.hh, Tom Drummond, 2009/03/10
- [Toon-members] TooN/internal operators.hh, Tom Drummond, 2009/03/10
- [Toon-members] TooN/internal operators.hh, Tom Drummond, 2009/03/10
- [Toon-members] TooN/internal operators.hh, Tom Drummond, 2009/03/10
- [Toon-members] TooN/internal operators.hh,
Edward Rosten <=
- [Toon-members] TooN/internal operators.hh, Gerhard Reitmayr, 2009/03/26