Opened 12 years ago

Closed 12 years ago

#5253 closed Tasks (fixed)

provide a const version of 'get_state'

Reported by: jan.vogelgesang@… Owned by: Christophe Henry
Milestone: Boost 1.47.0 Component: msm
Version: Boost 1.47.0 Severity: Problem
Keywords: Cc:

Description

The current implementation of 'get_state' doesn't compile when used on a const reference to a state machine. It would be nice to have a const version of 'get_state' (for people believing in 'const correctness' this is even an essential extension ;-) )

This ticket is opend as result of a discussion on the boost users list, subject "[Boost-users] [MSM] test if state machine is in a given state /const get_state" so i refer to this posting if further details are required.

Change History (1)

comment:1 by Christophe Henry, 12 years ago

Milestone: To Be DeterminedBoost 1.47.0
Resolution: fixed
Status: newclosed
Version: Boost 1.45.0Boost 1.47.0

Fixed in trunk (70832). Will be merged in 1.47. Following is now possible:

void test(const player& p)
{
   const player_::Stopped& s1 = p.get_state<const player_::Stopped&>();
   s1.cfoo(); //const
   player_::Stopped& s2 = p.get_state<player_::Stopped&>();
   s2.foo(); // not const

   const player_::Stopped* sp1 = p.get_state<const player_::Stopped*>();
   sp1->cfoo(); //const
   player_::Stopped* sp2 = p.get_state<player_::Stopped*>();
   sp2->foo(); // not const
}
Note: See TracTickets for help on using tickets.