From 899c22fbf8e35c23635a49a8f9ec087e151bbb5d Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 2 Mar 2011 18:08:38 -0500 Subject: [PATCH] tr1 shared_ptr --- pvDataApp/Makefile | 1 + pvDataApp/misc/sharedPtr.h | 61 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 pvDataApp/misc/sharedPtr.h diff --git a/pvDataApp/Makefile b/pvDataApp/Makefile index 24e55dc..3db7ce6 100644 --- a/pvDataApp/Makefile +++ b/pvDataApp/Makefile @@ -26,6 +26,7 @@ INC += queue.h INC += messageQueue.h INC += destroyable.h INC += status.h +INC += sharedPtr.h LIBSRCS += CDRMonitor.cpp LIBSRCS += byteBuffer.cpp diff --git a/pvDataApp/misc/sharedPtr.h b/pvDataApp/misc/sharedPtr.h new file mode 100644 index 0000000..a4702b6 --- /dev/null +++ b/pvDataApp/misc/sharedPtr.h @@ -0,0 +1,61 @@ +/** + * Copyright - See the COPYRIGHT that is included with this distribution. + * EPICS pvDataCPP is distributed subject to a Software License Agreement found + * in file LICENSE that is included with this distribution. + */ + +#ifndef SHAREDPTR_H +#define SHAREDPTR_H + +/* + * Pulls in the std::tr1 namespace with the following names + * + * class shared_ptr + * class weak_ptr + * class bad_weak_ptr + * function static_pointer_cast; + * function dynamic_pointer_cast + * function const_pointer_cast + * function swap + * function get_deleter + * function enable_shared_from_this + */ + +// where should we look? + +#if defined(__GNUC__) && __GNUC__>=4 + // GCC >=4.0.0 +# define SHARED_FROM_TR1 + +#elif defined(_MSC_VER) && (_MSC_VER>1500 || defined(_HAS_TR1)) + // MSVC > 2008, or 2008 w/ SP1 +# define SHARED_FROM_TR1 + +#else +# define SHARED_FROM_BOOST +#endif + +// go and get it + +#if defined(SHARED_FROM_TR1) +# include + +#elif defined(SHARED_FROM_BOOST) +# include + +#else + // eventually... +# include +#endif + +// cleanup + +#ifdef SHARED_FROM_TR1 +# undef SHARED_FROM_TR1 +#endif + +#ifdef SHARED_FROM_BOOST +# undef SHARED_FROM_BOOST +#endif + +#endif // SHAREDPTR_H