SOURCES: rtorrent-convert_fn.patch (NEW) - fix for gcc4 (I hope)
charles
charles at pld-linux.org
Mon May 8 16:45:32 CEST 2006
Author: charles Date: Mon May 8 14:45:32 2006 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- fix for gcc4 (I hope)
---- Files affected:
SOURCES:
rtorrent-convert_fn.patch (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: SOURCES/rtorrent-convert_fn.patch
diff -u /dev/null SOURCES/rtorrent-convert_fn.patch:1.1
--- /dev/null Mon May 8 16:45:32 2006
+++ SOURCES/rtorrent-convert_fn.patch Mon May 8 16:45:27 2006
@@ -0,0 +1,63 @@
+--- rtorrent-0.5.1/rak/functional_fun.h.orig 2006-05-01 18:29:59.000000000 +0200
++++ rtorrent-0.5.1/rak/functional_fun.h 2006-05-08 16:33:48.000000000 +0200
+@@ -343,32 +343,42 @@
+ return new value_fn0_t<Result>(val);
+ }
+
++template <typename A, typename B>
++struct equal_types_t {
++ typedef A first_type;
++ typedef B second_type;
++
++ const static int result = 0;
++};
++
++template <typename A>
++struct equal_types_t<A, A> {
++ typedef A first_type;
++ typedef A second_type;
++
++ const static int result = 1;
++};
++
+ template <typename Result, typename SrcResult>
+ inline function_base0<Result>*
+ convert_fn(function_base0<SrcResult>* src) {
+- return new convert_fn0_t<Result, SrcResult>(src);
+-}
+-
+-// This overload ensures that if we try to convert to the same type,
+-// it will optimize away the unneeded layer.
+-template <typename Result>
+-inline function_base0<Result>*
+-convert_fn(function_base0<Result>* src) {
+- return src;
++ if (equal_types_t<function_base0<Result>, function_base0<SrcResult> >::result)
++ // The pointer cast never gets done if the types are different,
++ // but needs to be here to pleasant the compiler.
++ return reinterpret_cast<typename equal_types_t<function_base0<Result>, function_base0<SrcResult> >::first_type*>(src);
++ else
++ return new convert_fn0_t<Result, SrcResult>(src);
+ }
+
+ template <typename Result, typename Arg1, typename SrcResult, typename SrcArg1>
+ inline function_base1<Result, Arg1>*
+ convert_fn(function_base1<SrcResult, SrcArg1>* src) {
+- return new convert_fn1_t<Result, Arg1, SrcResult, SrcArg1>(src);
+-}
+-
+-// This overload ensures that if we try to convert to the same type,
+-// it will optimize away the unneeded layer.
+-template <typename Result, typename Arg1>
+-inline function_base1<Result, Arg1>*
+-convert_fn(function_base1<Result, Arg1>* src) {
+- return src;
++ if (equal_types_t<function_base1<Result, Arg1>, function_base1<SrcResult, SrcArg1> >::result)
++ // The pointer cast never gets done if the types are different,
++ // but needs to be here to pleasant the compiler.
++ return reinterpret_cast<typename equal_types_t<function_base1<Result, Arg1>, function_base1<SrcResult, SrcArg1> >::first_type*>(src);
++ else
++ return new convert_fn1_t<Result, Arg1, SrcResult, SrcArg1>(src);
+ }
+
+ }
================================================================
More information about the pld-cvs-commit
mailing list