aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Saleem Abdulrasool <compnerd@compnerd.org> 2013-04-27 13:32:27 -0700
committerAvatar Saleem Abdulrasool <compnerd@compnerd.org> 2013-04-27 14:29:35 -0700
commiteb5bcb8eaf1a971491541ed646db224c3136063b (patch)
treefec98faaa3fb8e1a80f7312e44a0dcd2be8bb737
parent6ca518bb0665c9d32ef040fe027e04f403382389 (diff)
downloadpaludis-eb5bcb8eaf1a971491541ed646db224c3136063b.tar.gz
paludis-eb5bcb8eaf1a971491541ed646db224c3136063b.tar.xz
silence 'unused local typedef' warning
The local typedef used for type checking is unreferenced, and causes spurious warning with GCC 4.8. Use an inline std::enable_if return type munging to elide template instantiations for unrelated types. Signed-off-by: Saleem Abdulrasool <compnerd@compnerd.org>
-rw-r--r--paludis/util/visitor_cast-fwd.hh4
-rw-r--r--paludis/util/visitor_cast.hh20
2 files changed, 6 insertions, 18 deletions
diff --git a/paludis/util/visitor_cast-fwd.hh b/paludis/util/visitor_cast-fwd.hh
index 5fdfa29..06ea2e4 100644
--- a/paludis/util/visitor_cast-fwd.hh
+++ b/paludis/util/visitor_cast-fwd.hh
@@ -21,10 +21,12 @@
#define PALUDIS_GUARD_PALUDIS_UTIL_VISITOR_CAST_FWD_HH 1
#include <paludis/util/attributes.hh>
+#include <type_traits>
namespace paludis
{
- template <typename To_, typename From_>
+ template <typename To_, typename From_,
+ typename = typename std::enable_if<std::is_base_of<From_, To_>::value>::type>
To_ * visitor_cast(From_ &) PALUDIS_ATTRIBUTE((warn_unused_result));
}
diff --git a/paludis/util/visitor_cast.hh b/paludis/util/visitor_cast.hh
index 568de2d..3ef277d 100644
--- a/paludis/util/visitor_cast.hh
+++ b/paludis/util/visitor_cast.hh
@@ -40,17 +40,6 @@ namespace paludis
}
};
- template <typename To_, typename From_, bool ok_>
- struct VerifyVisitorCastType
- {
- };
-
- template <typename To_, typename From_>
- struct VerifyVisitorCastType<To_, From_, true>
- {
- typedef int IsOK;
- };
-
template <typename C_, typename T_>
struct CopyConst
{
@@ -63,13 +52,10 @@ namespace paludis
typedef const T_ Type;
};
- template <typename To_, typename From_>
- To_ * visitor_cast(From_ & from)
+ template <typename To_, typename From_, typename>
+ To_ *
+ visitor_cast(From_ & from)
{
- /* verify that we are attempting to visitor_cast something that
- * could potentially be true */
- typedef typename VerifyVisitorCastType<To_, From_, std::is_base_of<From_, To_>::value>::IsOK TypeIsOK;
-
VisitorCaster<To_, typename CopyConst<From_, typename From_::VisitableBaseClass>::Type> q;
return from.template accept_returning<To_ *>(q);
}