From ef60815c66407836d5a95f53bc119874d799963b Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Sat, 26 Aug 2017 15:06:30 -0400 Subject: [PATCH] Updated examples to use unique_ptr when available rather than auto_ptr, which is being deprecated. --- example/fsm/aux_/base_event.hpp | 20 ++++++++++++++++++++ example/fsm/aux_/event.hpp | 15 +++++++++++++++ example/fsm/state_machine.hpp | 10 ++++++++++ 3 files changed, 45 insertions(+) diff --git a/example/fsm/aux_/base_event.hpp b/example/fsm/aux_/base_event.hpp index 8248a06..99df7d9 100644 --- a/example/fsm/aux_/base_event.hpp +++ b/example/fsm/aux_/base_event.hpp @@ -15,6 +15,7 @@ // $Revision$ #include +#include namespace fsm { namespace aux { @@ -25,13 +26,32 @@ struct base_event public: virtual ~base_event() {}; +#if defined(BOOST_NO_CXX11_SMART_PTR) + std::auto_ptr clone() const + +#else + + std::unique_ptr clone() const + +#endif + { return do_clone(); } private: + +#if defined(BOOST_NO_CXX11_SMART_PTR) + virtual std::auto_ptr do_clone() const = 0; + +#else + + virtual std::unique_ptr do_clone() const = 0; + +#endif + }; }} diff --git a/example/fsm/aux_/event.hpp b/example/fsm/aux_/event.hpp index a27e9d6..895bd7a 100644 --- a/example/fsm/aux_/event.hpp +++ b/example/fsm/aux_/event.hpp @@ -26,12 +26,27 @@ struct event typedef base_event base_t; private: + +#if defined(BOOST_NO_CXX11_SMART_PTR) + virtual std::auto_ptr do_clone() const { return std::auto_ptr( new Derived(static_cast(*this)) ); } + +#else + + virtual std::unique_ptr do_clone() const + { + return std::unique_ptr( + new Derived(static_cast(*this)) + ); + } + +#endif + }; }} diff --git a/example/fsm/state_machine.hpp b/example/fsm/state_machine.hpp index 4f4e616..4bfd016 100644 --- a/example/fsm/state_machine.hpp +++ b/example/fsm/state_machine.hpp @@ -83,7 +83,17 @@ class state_machine { } + +#if defined(BOOST_NO_CXX11_SMART_PTR) + void post_event(std::auto_ptr evt) + +#else + + void post_event(std::unique_ptr evt) + +#endif + { m_events_queue.push(base_event_ptr_t(evt.release())); }