Sign in to follow this  

Template problem trying to use boost::signals

This topic is 3499 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
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

This topic is 3499 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this