I wrote a simple code.
source file:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include <iostream>
#include <string>
using namespace std;
namespace sc=boost::statechart;
namespace mpl=boost::mpl;
struct EvtEat:sc::event<EvtEat>{};
struct EvtStop:sc::event<EvtStop>{};
struct Eating;
struct Idle;
class Human:public sc::state_machine< Human, Idle >
{
public:
void show(void)
{
cout<<__FUNCTION__<
{
Idle(my_context ctx):my_base(ctx)
{
context<Human>().show(); //ok
};
~Idle(void)
{
context<Human>().show(); //assert failed
};
};
struct Eating:sc::state< Eating, Human >
{
Eating(my_context ctx):my_base(ctx)
{
};
~Eating(void)
{
context<Human>();
}
};
int main(int argc, char* argv[])
{
Human human;
human.initiate();
return 0;
}
/*
In debug mode.It output
Human::show
Assertion failed: dynamic_cast<Target>(x) == x, file
p:\programme\libs\boost\include\boost-1_35\boost\cast.hpp, line 97
*/
Why does it assert failed and how to modify the source?
Thank you.