Hello gurus!
I need some help understanding template template parameters.
Outline of what I'm trying to do is to pass a template vector which is stored in a map,
to a template class that is expecting a vector.
Sort of like,
PsuedoSimplifying it only using vector works,Code:template class Foo<A, vector V, B, std::map M>; In Foo, create M<std::string, V<B<A > > > X; Define B like; template class<A, vector V> B; Pass X::iterator-second to C; // error here
but when I adapt this workable solution to the model I want,
I get a compilation error (minGW g++).
I spent all night last night and this morning, but I'm stump.
cut down version of class Foo is
and start() member function is a simple initialization prcedure, likeCode:template < typename Device, template<typename> class Container = std::vector, template<typename> class Configure = Config, template<typename, typename> class Registry = std::map > class BasicSystem { template <typename DeviceTrait> friend std::ostream& operator<<(std::ostream&, const BasicSystem<DeviceTrait*>&); public: BasicSystem(); // UI ResultCode start(); private: typedef Registry<Input, Container<Configure<Device*> > > iComponent; iComponent iDevice; };
and the template class that I'm trying to pass to isCode://////////////////////////////////////////////////////////////////////////////80 // start method template < typename Device, template<typename> class Container, template<typename> class Configure, template<typename, typename> class Registry > ResultCode BasicSystem<Device, Container, Configure, Registry>::start() { // temporary test typename iComponent::iterator iter = iDevice.begin(); iter->second.at(0).load("loadme.conf"); ///// error here ///// iter->second.at(0).initDevice(iter->second.at(0)); return 0; }
and initDevice method is defined likeCode:template <typename DeviceTrait, template<typename> class Container = std::vector> class Config { public: Config(); // UI Bool load(CRString); ResultCode initDevice(Container<DeviceTrait*>&, Bool doShow = true); };
The compiler keeps telling me that there's no matching functioncall to initDevice(),Code:template <typename DeviceTrait, template<typename> class Container> ResultCode Config<DeviceTrait, Container>::initDevice(Container<DeviceTrait*>& ref, Bool doShow) { std::for_each(ref.begin(), ref.end(), std::bind2nd(std::mem_fun(&DeviceTrait::init), doShow)); return 19; }
but it is myunderstanding that I'm correctly (but apparently wrong) passing a vector.
I'd appreciate if anyone can help.
Thanks
Edit: All these classes are defined in a namespace, if that matters... I'm not sure.




Reply With Quote