aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-14 17:54:26 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-17 14:50:38 +0100
commite79eb9df7057cbef884e50525323ef0bd91e0c3b (patch)
treec459f5ed55bb806305d3f4e08283f904340ad3fa
parentbf6cfe9d43403c955ed521821d18c5aef99c8675 (diff)
downloadpaludis-e79eb9df7057cbef884e50525323ef0bd91e0c3b.tar.gz
paludis-e79eb9df7057cbef884e50525323ef0bd91e0c3b.tar.xz
More flexible visitor_casts
-rw-r--r--paludis/util/simple_visitor.hh3
-rw-r--r--paludis/util/simple_visitor_cast.hh16
2 files changed, 16 insertions, 3 deletions
diff --git a/paludis/util/simple_visitor.hh b/paludis/util/simple_visitor.hh
index 0920524..8c3877e 100644
--- a/paludis/util/simple_visitor.hh
+++ b/paludis/util/simple_visitor.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2008, 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -125,6 +125,7 @@ namespace paludis
public:
typedef VisitableTypeList_ VisitableTypeList;
+ typedef BaseClass_ VisitableBaseClass;
template <typename UnwrappedVisitor_>
void accept(UnwrappedVisitor_ & v)
diff --git a/paludis/util/simple_visitor_cast.hh b/paludis/util/simple_visitor_cast.hh
index 5337a0f..2f8eaef 100644
--- a/paludis/util/simple_visitor_cast.hh
+++ b/paludis/util/simple_visitor_cast.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2008, 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -51,6 +51,18 @@ namespace paludis
typedef int IsOK;
};
+ template <typename C_, typename T_>
+ struct CopyConst
+ {
+ typedef T_ Type;
+ };
+
+ template <typename C_, typename T_>
+ struct CopyConst<const C_, T_>
+ {
+ typedef const T_ Type;
+ };
+
template <typename To_, typename From_>
To_ * simple_visitor_cast(From_ & from)
{
@@ -58,7 +70,7 @@ namespace paludis
* could potentially be true */
typedef typename VerifySimpleVisitorCastType<To_, From_, std::tr1::is_base_of<From_, To_>::value>::IsOK TypeIsOK;
- SimpleVisitorCaster<To_, From_> q;
+ SimpleVisitorCaster<To_, typename CopyConst<From_, typename From_::VisitableBaseClass>::Type> q;
return from.template accept_returning<To_ *>(q);
}
}