Mirror reflection library 0.5.13
|
00001 00011 #ifndef MIRROR_META_PROG_UNIQUE_1011291729_HPP 00012 #define MIRROR_META_PROG_UNIQUE_1011291729_HPP 00013 00014 00015 #include <mirror/meta_prog/range.hpp> 00016 00017 MIRROR_NAMESPACE_BEGIN 00018 namespace mp { 00019 00020 #ifdef MIRROR_DOCUMENTATION_ONLY 00021 00022 00027 template <class Range> 00028 struct unique 00029 { 00031 typedef UniqueRange type; 00032 }; 00033 #endif 00034 00035 namespace aux { 00036 00037 // declaration of the internal helper for the unique meta-function 00038 template <class UniqueRange, class TailRange> 00039 struct unique_helper; 00040 00041 // specialization ending the filtering 00042 template <typename ... UniqueP> 00043 struct unique_helper<range<UniqueP...>, range<> > 00044 { 00045 typedef range<UniqueP...> type; 00046 }; 00047 00048 // specialization of the unique_helper for non-empty 00049 template <typename ... UniqueP, typename T, typename ... P> 00050 struct unique_helper<range<UniqueP...>, range<T, P...> > 00051 { 00052 typedef typename if_< 00053 typename empty<find<range<UniqueP...>, T> >::type, 00054 typename unique_helper< 00055 range<UniqueP..., T>, 00056 range<P...> 00057 >::type, 00058 typename unique_helper< 00059 range<UniqueP...>, 00060 range<P...> 00061 >::type 00062 >::type type; 00063 }; 00064 00065 } // namespace aux 00066 00067 // Implementation of the unique meta-function 00068 template <typename ... P> 00069 struct unique<range<P...> > 00070 { 00071 // use the internale helper to remove the duplicities 00072 typedef typename aux::unique_helper< 00073 // at first the unique range is empty 00074 range<>, 00075 // and the remaining range is the range passes 00076 // as template parameter 00077 range<P...> 00078 >::type type; 00079 }; 00080 00081 00082 } // namespace mp 00083 MIRROR_NAMESPACE_END 00084 00085 #endif //include guard 00086