From 961936ce9dcfcc978004aa7660816ea5f48731a8 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Mon, 23 Sep 2013 02:21:03 +0200 Subject: [PATCH] Clang-3.0(#932): workaround for a known problem of Clang-3.0 (Debian/stable) http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20121203/069267.html http://stackoverflow.com/questions/13521163/variadic-template-as-template-parameter-deduction-works-with-gcc-but-not-with-c Clang aborts the template type deduction due to different size of the argument lists; in fact the missmatching arguments can be filled in perfectly from the default template arguments. As a workaround, we'll include an unused placeholder type parameter into the templated function, to make the match succeed. --- src/lib/p.hpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/lib/p.hpp b/src/lib/p.hpp index 51979aa5d..2fe3c789c 100644 --- a/src/lib/p.hpp +++ b/src/lib/p.hpp @@ -98,29 +98,30 @@ namespace lib { private: /* === friend operators injected into enclosing namespace for ADL === */ - template + //////////////////TICKET #932 Clang is unable to fill in the default template argument. Resolved in newer versions of Clang. Temporary workaround: add second parameter B + template friend inline bool - operator== (P const& p, P<_O_> const& q) { return (p && q)? (*p == *q) : (!p && !q); } + operator== (P const& p, P<_O_, B> const& q) { return (p && q)? (*p == *q) : (!p && !q); } - template + template friend inline bool - operator!= (P const& p, P<_O_> const& q) { return (p && q)? (*p != *q) : !(!p && !q); } + operator!= (P const& p, P<_O_, B> const& q) { return (p && q)? (*p != *q) : !(!p && !q); } - template + template friend inline bool - operator< (P const& p, P<_O_> const& q) { REQUIRE (p && q); return *p < *q; } ///< @note deliberately not allowing comparison on NIL ////TICKET #307 : problem with equality test in associative containers, where equal(a,b) := !(a < b) && !(b < a) + operator< (P const& p, P<_O_, B> const& q) { REQUIRE (p && q); return *p < *q; } ///< @note deliberately not allowing comparison on NIL ////TICKET #307 : problem with equality test in associative containers, where equal(a,b) := !(a < b) && !(b < a) - template + template friend inline bool - operator> (P const& p, P<_O_> const& q) { REQUIRE (p && q); return *q < *p; } + operator> (P const& p, P<_O_, B> const& q) { REQUIRE (p && q); return *q < *p; } - template + template friend inline bool - operator<= (P const& p, P<_O_> const& q) { REQUIRE (p && q); return *p <= *q;} + operator<= (P const& p, P<_O_, B> const& q) { REQUIRE (p && q); return *p <= *q;} - template + template friend inline bool - operator>= (P const& p, P<_O_> const& q) { REQUIRE (p && q); return *p >= *q;} + operator>= (P const& p, P<_O_, B> const& q) { REQUIRE (p && q); return *p >= *q;} };