00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef PALUDIS_GUARD_PALUDIS_UTIL_SIMPLE_VISITOR_CAST_HH
00021 #define PALUDIS_GUARD_PALUDIS_UTIL_SIMPLE_VISITOR_CAST_HH 1
00022
00023 #include <paludis/util/simple_visitor_cast-fwd.hh>
00024 #include <paludis/util/simple_visitor.hh>
00025 #include <tr1/type_traits>
00026
00027 namespace paludis
00028 {
00029 template <typename To_, typename From_>
00030 struct SimpleVisitorCaster
00031 {
00032 To_ * visit(const To_ & t)
00033 {
00034 return &t;
00035 }
00036
00037 To_ * visit(const From_ &)
00038 {
00039 return 0;
00040 }
00041 };
00042
00043 template <typename To_, typename From_>
00044 To_ * simple_visitor_cast(const From_ & from)
00045 {
00046 SimpleVisitorCaster<To_, From_> q;
00047 return from.template accept_returning<To_ *>(q);
00048 }
00049 }
00050
00051 #endif