mirror of
https://github.com/boostorg/mpl.git
synced 2025-08-03 23:04:33 +02:00
Updated examples to use unique_ptr when available rather than auto_ptr, which is being deprecated.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
// $Revision$
|
||||
|
||||
#include <memory>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
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<base_event> clone() const
|
||||
|
||||
#else
|
||||
|
||||
std::unique_ptr<base_event> clone() const
|
||||
|
||||
#endif
|
||||
|
||||
{
|
||||
return do_clone();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
#if defined(BOOST_NO_CXX11_SMART_PTR)
|
||||
|
||||
virtual std::auto_ptr<base_event> do_clone() const = 0;
|
||||
|
||||
#else
|
||||
|
||||
virtual std::unique_ptr<base_event> do_clone() const = 0;
|
||||
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
}}
|
||||
|
@@ -26,12 +26,27 @@ struct event
|
||||
typedef base_event base_t;
|
||||
|
||||
private:
|
||||
|
||||
#if defined(BOOST_NO_CXX11_SMART_PTR)
|
||||
|
||||
virtual std::auto_ptr<base_event> do_clone() const
|
||||
{
|
||||
return std::auto_ptr<base_event>(
|
||||
new Derived(static_cast<Derived const&>(*this))
|
||||
);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
virtual std::unique_ptr<base_event> do_clone() const
|
||||
{
|
||||
return std::unique_ptr<base_event>(
|
||||
new Derived(static_cast<Derived const&>(*this))
|
||||
);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
}}
|
||||
|
@@ -83,7 +83,17 @@ class state_machine
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#if defined(BOOST_NO_CXX11_SMART_PTR)
|
||||
|
||||
void post_event(std::auto_ptr<base_event_t const> evt)
|
||||
|
||||
#else
|
||||
|
||||
void post_event(std::unique_ptr<base_event_t const> evt)
|
||||
|
||||
#endif
|
||||
|
||||
{
|
||||
m_events_queue.push(base_event_ptr_t(evt.release()));
|
||||
}
|
||||
|
Reference in New Issue
Block a user