| [29] | 1 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 2 | // Copyright 2005-2006 Andreas Huber Doenni |
|---|
| 3 | // Distributed under the Boost Software License, Version 1.0. (See accompany- |
|---|
| 4 | // ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
|---|
| 5 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | #include <boost/statechart/state_machine.hpp> |
|---|
| 10 | #include <boost/statechart/event.hpp> |
|---|
| 11 | #include <boost/statechart/simple_state.hpp> |
|---|
| 12 | #include <boost/statechart/custom_reaction.hpp> |
|---|
| 13 | #include <boost/statechart/result.hpp> |
|---|
| 14 | |
|---|
| 15 | #include <boost/static_assert.hpp> |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | namespace sc = boost::statechart; |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | struct E : sc::event< E > {}; |
|---|
| 24 | |
|---|
| 25 | struct A; |
|---|
| 26 | struct InvalidResultAssignTest : |
|---|
| 27 | sc::state_machine< InvalidResultAssignTest, A > {}; |
|---|
| 28 | |
|---|
| 29 | struct A : sc::simple_state< A, InvalidResultAssignTest > |
|---|
| 30 | { |
|---|
| 31 | typedef sc::custom_reaction< E > reactions; |
|---|
| 32 | |
|---|
| 33 | sc::result react( const E & ) |
|---|
| 34 | { |
|---|
| 35 | sc::result r( discard_event() ); |
|---|
| 36 | // sc::result must not be assignmable |
|---|
| 37 | r = discard_event(); |
|---|
| 38 | return r; |
|---|
| 39 | } |
|---|
| 40 | }; |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | int main() |
|---|
| 45 | { |
|---|
| 46 | InvalidResultAssignTest machine; |
|---|
| 47 | machine.initiate(); |
|---|
| 48 | |
|---|
| 49 | #ifdef NDEBUG |
|---|
| 50 | // Test only fails in DEBUG mode. Forcing failure... |
|---|
| 51 | BOOST_STATIC_ASSERT( false ); |
|---|
| 52 | #endif |
|---|
| 53 | |
|---|
| 54 | return 0; |
|---|
| 55 | } |
|---|