
-----BEGIN PGP SIGNED MESSAGE----- Hash: RIPEMD160 Hello, I tried to declare a boost:shared_ptr as a static member of a template function. If I compile the program with Visual Studio all are Ok. If I try to compile the code with gcc, gcc failed with: t1.cpp:71: error: too few template-parameter-lists t1.cpp:72: error: too few template-parameter-lists There is a small mistake in my code but I can't find the error. Can someone help me? Bye Bernd - ------------------ code ----------------------------- #include <boost/thread/mutex.hpp> #include <boost/shared_ptr.hpp> template <class T> class SimpleSingleton { public: SimpleSingleton() { } ~SimpleSingleton() { } T * instance() { boost::mutex::scoped_lock sp_lock(inst_mutex); if (!as.get()) { boost::shared_ptr<T> temp(new T); as=temp; } return as.get(); } protected: static boost::shared_ptr<T>(as); static boost::mutex inst_mutex; }; class test { protected: test(void) { a_=0; } public: ~test(void) { } int Get(void) { return a_; } void Set(int a) { a_ = a; } protected: int a_; friend class SimpleSingleton<test>; }; boost::shared_ptr<test> SimpleSingleton<test>::as; boost::mutex SimpleSingleton<test>::inst_mutex; int main(void) { SimpleSingleton<test> t; t.instance()->Set(45); int b=t.instance()->Get(); return b; } - ------------------ code ----------------------------- - -- TRIOPTICS GmbH Bernd Martin Wollny Software Designer Hafenstrasse 39, 22880 Wedel/GERMANY phone / fax: +49 (0)4103 18006-26 /-20 e-mail: bm.wollny@trioptics.com All E-Mails from bm.wollny@trioptics.com are digital signed. If you get a unsigned E-Mail, this E-Mail are a fake. Look at http://www.gnupg.org . -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Cygwin) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDdKc4CjfVnTPD3b4RA+0HAKC4jcBEeYvc75ZqJj4q2cNALGFElwCfZANJ X2i8t+fFa5o/rQQyha0KDqs= =BUfl -----END PGP SIGNATURE-----