ok..Let me give you better snippet

SM.hpp:

  struct TopState;
  struct PairingStateMachine : sc::state_machine< StateMachine, TopState >
  {
    unsigned int  max;                       /**< Total number of devices which can be paired */
  };

  struct NotReady;
  struct TopState : sc::state< TopState, StateMachine, NotReady >
  {
    TopState(my_context ctx) : my_base( ctx )
    {
    }
    ~TopState() { std::cout << "Leave and desctruct TopState state!\n"; }

    typedef TopstateList reactions;

    template< class MostDerived >
    sc::result react( const PairingBaseEvents< MostDerived > & );
  };

  template< class MostDerived, class Context >
  struct StateBase : sc::state< MostDerived, Context>
  {
      typedef sc::state< MostDerived, Context> base_type;
      typedef typename base_type::my_context my_context;
      typedef StateBase my_base;

      StateBase( my_context ctx ) : base_type( ctx )
      {
          std::cout << "StateBase cst" << std::endl;
      }
  };

  struct NotReady : StateBase< NotReady, TopState >
  {

    typedef NotReadystateList reactions;
    NotReady (my_context ctx) : my_base( ctx ){
    
      }

    template< class MostDerived >
    sc::result react( const PairingBaseEvents< MostDerived > & );
      
  };

SM.cpp:

template< class MostDerived >
sc::result NotReady::react( const PairingBaseEvents< MostDerived > & PAEvent){
   if (typeid(EntryEvent).name() == typeid(PAEvent).name())
   {
      outermost_context().maxPairedDevices++;
      return discard_event();
    }
 }

regards
Rahul


On Tue, Nov 5, 2013 at 4:18 PM, Igor R <boost.lists@gmail.com> wrote:
>>
>> Where do you define the above "react" member function template?

> *.cpp file
>
> template< class MostDerived >
> sc::result NotReady::react( const PairingBaseEvents< MostDerived > &
> PAEvent){
> if (typeid(EntryEvent).name() == typeid(PAEvent).name())
> {
> outermost_context().maxPairedDevices++;
> return discard_event();
> }
> }
>
> i Have a mpl:list defined in another header file.


If you define a function template in cpp (not in the header), you have
to instantiate this definition manually for all the types that the
declaration gets instantiated for.
If you want to rely on automatic template instantiation, define the
function in the header file.
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users