21 #ifndef MULTI_POLICY_CONTAINER_H_
22 #define MULTI_POLICY_CONTAINER_H_
24 #include <boost/mpl/inherit_linearly.hpp>
25 #include <boost/mpl/at.hpp>
32 template<
class Base,
class Value >
39 template<
class Base,
class Super,
class Value >
45 update (
typename Base::iterator item)
47 Value::value_.update (item);
52 insert (
typename Base::iterator item)
54 bool ok = Value::value_.insert (item);
58 ok = Super::insert (item);
61 Value::value_.erase (item);
68 lookup (
typename Base::iterator item)
70 Value::value_.lookup (item);
75 erase (
typename Base::iterator item)
77 Value::value_.erase (item);
84 Value::value_.clear ();
89 template<
class Base >
94 void update (
typename Base::iterator item) {}
95 bool insert (
typename Base::iterator item) {
return true; }
96 void lookup (
typename Base::iterator item) {}
97 void erase (
typename Base::iterator item) {}
101 template<
class Base,
class Vector >
103 :
public boost::mpl::fold< Vector,
104 empty_policy_wrap<Base>,
105 inherit_with_base<Base,
107 policy_wrap<Base, boost::mpl::_2>>
110 typedef typename boost::mpl::fold< Vector,
117 typedef typename boost::mpl::at_c<Vector, 0>::type::iterator iterator;
118 typedef typename boost::mpl::at_c<Vector, 0>::type::const_iterator const_iterator;
120 iterator begin () {
return this->get<0> ().begin (); }
121 const_iterator begin ()
const {
return this->get<0> ().begin (); }
123 iterator end () {
return this->get<0> ().end (); }
124 const_iterator end ()
const {
return this->get<0> ().end (); }
126 size_t size ()
const {
return this->get<0> ().size (); }
135 typedef typename boost::mpl::at_c<Vector, N>::type type;
153 typename boost::mpl::at_c<Vector, N>::type &
156 typedef typename boost::mpl::at_c<Vector, N>::type T;
157 return static_cast< policy_wrap<Base, T> &
> (*this).value_;
161 const typename boost::mpl::at_c<Vector, N>::type &
164 typedef typename boost::mpl::at_c<Vector, N>::type T;
165 return static_cast< const policy_wrap<Base, T> &
> (*this).value_;
175 #endif // MULTI_POLICY_CONTAINER_H_