Jump to content
  • Advertisement
Sign in to follow this  
ElPeque2

Template problem trying to use boost::signals

This topic is 3718 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

(this is the multi threaded version of signals, but probably gives the same error with the regular one). this is my code:
template<class T>
	class CFade : public CUpdateable
		{
		typedef boost::signal<void (T)> TFadeSignal;
		typedef TFadeSignal::slot_type TFadeSlot;

		public:
			CFade(uint32 aTimeout, uint32 aIntervalTime, boost::function<T (float)> aIntepolate, const TFadeSlot& aSlot)
				:	muiTimeout(aTimeout),
					muiTime(0),
					muiIntervalTime(aIntervalTime <= aTimeout ? aIntervalTime : aTimeout),
					mInterpolate(aIntepolate),
					muiAccum(0)
				{
				mSignal.connect(aSlot);
				mSignal(mInterpolate(float(0)/muiTimeout));
				}

		void onUpdate(int32 aTime)
			{
			muiAccum += aTime;
			muiTime += aTime;

			if(muiTimeout && (muiTime >= muiTimeout))
				{
				mSignal(mInterpolate(1.0f));
				mpParent.lock()->tagForDetach(shared_from_this());
				return;
				}

			if(muiAccum >= muiIntervalTime)
				{
				if(muiIntervalTime) muiAccum %= muiIntervalTime;
				else muiAccum = 0;
				mSignal(mInterpolate(float(muiTime - muiAccum)/muiTimeout));
				}
			}

		private:
			TFadeSignal mSignal;
			boost::function<T (float)> mInterpolate;
			uint32 muiTimeout;
			uint32 muiIntervalTime;
			uint32 muiAccum;
			uint32 muiTime;
		};

and the error:
------ Build started: Project: Engine, Configuration: Debug Win32 ------
Compiling...
CLabel.cpp
c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\cscenestate.h(63) : warning C4244: 'argument' : conversion from 'cml::int32' to 'float', possible loss of data
c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\cscenestate.h(63) : warning C4244: 'argument' : conversion from 'cml::int32' to 'float', possible loss of data
c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\cscenestate.h(75) : warning C4244: 'initializing' : conversion from 'double' to 'float', possible loss of data
c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\cscenestate.h(98) : warning C4244: 'argument' : conversion from 'double' to 'float', possible loss of data
c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\cmessage.h(55) : warning C4346: 'boost::signal<void(T)>::slot_type' : dependent name is not a type
        prefix with 'typename' to indicate a type
        c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\cmessage.h(96) : see reference to class template instantiation 'CFade<T>' being compiled
c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\cmessage.h(55) : error C2146: syntax error : missing ';' before identifier 'TFadeSlot'
c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\cmessage.h(55) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\cmessage.h(58) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\cmessage.h(58) : error C2143: syntax error : missing ',' before '&'
c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\clabel.cpp(25) : warning C4244: 'argument' : conversion from 'float' to 'cml::int32', possible loss of data
c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\clabel.cpp(25) : warning C4244: 'argument' : conversion from 'float' to 'cml::int32', possible loss of data
c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\clabel.cpp(66) : warning C4244: '=' : conversion from 'float' to 'cml::int32', possible loss of data
c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\clabel.cpp(67) : warning C4244: '=' : conversion from 'float' to 'cml::int32', possible loss of data
c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\clabel.cpp(86) : warning C4018: '<' : signed/unsigned mismatch
Generating Code...
Compiling...
CGameMain.cpp
c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\cscenestate.h(63) : warning C4244: 'argument' : conversion from 'cml::int32' to 'float', possible loss of data
c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\cscenestate.h(63) : warning C4244: 'argument' : conversion from 'cml::int32' to 'float', possible loss of data
c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\cscenestate.h(75) : warning C4244: 'initializing' : conversion from 'double' to 'float', possible loss of data
c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\cscenestate.h(98) : warning C4244: 'argument' : conversion from 'double' to 'float', possible loss of data
c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\cmessage.h(55) : warning C4346: 'boost::signal<void(T)>::slot_type' : dependent name is not a type
        prefix with 'typename' to indicate a type
        c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\cmessage.h(96) : see reference to class template instantiation 'CFade<T>' being compiled
c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\cmessage.h(55) : error C2146: syntax error : missing ';' before identifier 'TFadeSlot'
c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\cmessage.h(55) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\cmessage.h(58) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\cmessage.h(58) : error C2143: syntax error : missing ',' before '&'
c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\cgamemain.cpp(29) : error C2514: 'CFade' : class has no constructors
        c:\documents and settings\usuario\mis documentos\visual studio 2005\projects\engine 4\engine\cmessage.h(52) : see declaration of 'CFade'
Generating Code...
Build log was saved at "file://c:\Documents and Settings\Usuario\Mis documentos\Visual Studio 2005\Projects\Engine 4\Engine\Debug\BuildLog.htm"
Engine - 9 error(s), 15 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


and line 55 is: typedef TFadeSignal::slot_type TFadeSlot; i don't know what is wrong. something with the parser i guess? if i eliminate the template<class T> and then substitute al "T"s with "int32"s for example, it compiles and runs all right. thanks for your time, im very frustrated with this one :S [Edited by - ElPeque2 on May 14, 2008 4:02:28 PM]

Share this post


Link to post
Share on other sites
Advertisement
great! it worked!

sneftel, i already owe you a couple of beers :P

my first commitment in life should be to raise my score to be able to rise yours with my kudos :P

thanks again :)

PD: i messed up the layout, what should be the bbcode to fix that? :?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!