mirror of
https://github.com/boostorg/mpl.git
synced 2025-08-03 14:54:30 +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$
|
// $Revision$
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
namespace fsm { namespace aux {
|
namespace fsm { namespace aux {
|
||||||
|
|
||||||
@@ -25,13 +26,32 @@ struct base_event
|
|||||||
public:
|
public:
|
||||||
virtual ~base_event() {};
|
virtual ~base_event() {};
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_SMART_PTR)
|
||||||
|
|
||||||
std::auto_ptr<base_event> clone() const
|
std::auto_ptr<base_event> clone() const
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
std::unique_ptr<base_event> clone() const
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
return do_clone();
|
return do_clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_SMART_PTR)
|
||||||
|
|
||||||
virtual std::auto_ptr<base_event> do_clone() const = 0;
|
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;
|
typedef base_event base_t;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_SMART_PTR)
|
||||||
|
|
||||||
virtual std::auto_ptr<base_event> do_clone() const
|
virtual std::auto_ptr<base_event> do_clone() const
|
||||||
{
|
{
|
||||||
return std::auto_ptr<base_event>(
|
return std::auto_ptr<base_event>(
|
||||||
new Derived(static_cast<Derived const&>(*this))
|
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)
|
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()));
|
m_events_queue.push(base_event_ptr_t(evt.release()));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user