00001 #ifndef DVUTIL_CSLISTTAG_H
00002 #define DVUTIL_CSLISTTAG_H
00003
00004 #include <functional>
00005
00006 namespace Dv {
00007 namespace Util {
00008 template <typename T>
00009 struct identity: public std::unary_function<T,T> {
00010 const T& operator()(const T& t) const {
00011 return t;
00012 }
00013 T& operator()(T& t) const {
00014 return t;
00015 }
00016 };
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 template <typename Container,
00043 typename Elem = typename Container::value_type,
00044 typename Fun = identity<Elem> >
00045 struct CsListTag {
00046 CsListTag(const Fun& f = Fun()): fun(f) {}
00047 Container c;
00048 CsListTag& operator=(const Elem& v) {
00049 c.clear();
00050 c.push_back(fun(v));
00051 return *this;
00052 }
00053 CsListTag& operator,(const Elem& v) {
00054 c.push_back(fun(v));
00055 return *this;
00056 }
00057 operator Container() { return c; }
00058 Fun fun;
00059 };
00060 }
00061 }
00062 #endif