|
Boost : |
From: Hugo.Duncan_at_[hidden]
Date: 2002-03-19 09:06:07
I am trying to specialise some code for shared pinters without using
partial specialisation, so need a is_shared_ptr<T>.
The best I have come up with so far is below, which works with gcc-2.95.3-5
(cygwin), borland 5.5.1, msvc 6.
Is it worth adding an is_shared_ptr<T> to type_traits somewhere ?
Hugo
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template <typename T>
struct is_shared_ptr
{
BOOST_STATIC_CONSTANT( bool , value=false );
};
template <typename T>
struct is_shared_ptr<boost::shared_ptr<T> >
{
BOOST_STATIC_CONSTANT( bool , value=true );
};
#else
template <typename T>
struct is_shared_ptr
{
enum { value=boost::is_convertible<T,::boost::shared_ptr<void> >::value };
};
#endif
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk