00001 #ifndef ATLFAST_CASTAWAYCONST_H 00002 #define ATLFAST_CASTAWAYCONST_H 00003 00004 #ifndef STD_ALGORITHM_H 00005 #include <algorithm> 00006 #define STD_ALGORITHM_H 00007 #endif 00008 00011 namespace Atlfast{ 00012 template<class C> 00013 class CastAway{ 00014 public: 00015 CastAway(std::vector<C*>& nc):m_noConst(nc){} 00016 void operator()(const C* e){ 00017 m_noConst.push_back(const_cast<C*>(e)); 00018 } 00019 private: 00020 std::vector<C*>& m_noConst; 00021 }; 00022 template<class C> 00023 std::vector<C*> CastAwayConst(std::vector<const C*>& c ){ 00024 std::vector<C*> noConsts; 00025 std::for_each(c.begin(), c.end(), CastAway<C>(noConsts) ); 00026 return noConsts; 00027 }; 00028 } 00029 00030 #endif