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-14 17:54:26 +0100
commitb0448cfbd14b19ca660caa9cb3422de4004dac96 (patch)
tree68bdd65571c2330bdbb90a87c120552cb2487b49
parentc1f76e42cc55f10ec5dcfedb90783dd7182075f7 (diff)
downloadpaludis-b0448cfbd14b19ca660caa9cb3422de4004dac96.tar.gz
paludis-b0448cfbd14b19ca660caa9cb3422de4004dac96.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);
}
}