I'm trying to save myself some time and use boost's singleton class instead of writing my own... but it's giving me some weird error that I can't resolve:Code:#include <iostream> #include <string> #include <map> #include <exception> #include "boost/shared_ptr.hpp" #include "boost/pool/detail/singleton.hpp" class Surface { public: Surface() { std::cout << "Loaded a surface." << std::endl; } }; class Surface_Cache : public boost::details::pool::singleton_default<Surface_Cache> { public: typedef boost::shared_ptr<Surface> Surface_Ptr; typedef std::map<const std::string, Surface_Ptr> surface_cache; typedef surface_cache::iterator cache_it; Surface_Ptr Load_Surface(const std::string& file_name) { cache_it it = cache.find(file_name); if(it == cache.end()) { // Add surface. Surface_Ptr s(new Surface()); cache.insert(std::make_pair(file_name, s)); return s; } return it->second; } private: surface_cache cache; }; int main() { Surface_Cache::instance().Load_Surface("example.png"); return 0; }Why is it complaining?Code:1>c:\documents and settings\bill\my documents\visual studio 2005\projects\test\test\main.cpp(39) : error C2248: 'boost::details::pool::singleton_default<T>::singleton_default' : cannot access private member declared in class 'boost::details::pool::singleton_default<T>' 1> with 1> [ 1> T=Surface_Cache 1> ] 1> e:\everything\programs\boost\boost\pool\detail\singleton.hpp(71) : see declaration of 'boost::details::pool::singleton_default<T>::singleton_default' 1> with 1> [ 1> T=Surface_Cache 1> ] 1> This diagnostic occurred in the compiler generated function 'Surface_Cache::Surface_Cache(void)'
Cheers.




Reply With Quote