Ticket #1113: shared_array.patch
File shared_array.patch, 1.5 KB (added by , 13 years ago) |
---|
-
shared_array.hpp
35 35 namespace boost 36 36 { 37 37 38 namespace detail 39 { 40 template <class T> struct sa_wrap {}; 41 42 //is T a const-qualified version of Y? 43 template< class T, class Y > struct is_const_version_impl 44 { 45 typedef char (&yes) [1]; 46 typedef char (&no) [2]; 47 48 static yes f( const sa_wrap<Y const>& ); 49 static no f( ... ); 50 51 enum _vt { value = sizeof( f( sa_wrap<T>() ) ) == sizeof(yes) }; 52 }; 53 54 struct sa_empty {}; 55 56 template <bool> struct sa_is_const; 57 58 template <> struct sa_is_const<true> 59 { 60 typedef sa_empty type; 61 }; 62 63 template <> struct sa_is_const<false> 64 {}; 65 66 template <class T, class Y> 67 struct sa_enable 68 : public sa_is_const<is_const_version_impl<T, Y>::value> 69 {}; 70 } 71 38 72 // 39 73 // shared_array 40 74 // … … 69 103 { 70 104 } 71 105 72 // generated copy constructor,assignment, destructor are fine106 // generated assignment, destructor are fine 73 107 108 template <class Y> 109 shared_array(shared_array<Y> const & other, 110 typename detail::sa_enable<T, Y>::type = detail::sa_empty()) // never throws 111 : px(other.px), 112 pn(other.pn) 113 {} 114 74 115 void reset(T * p = 0) 75 116 { 76 117 BOOST_ASSERT(p == 0 || p != px); … … 115 156 116 157 private: 117 158 159 template <class Y> friend class shared_array; 160 118 161 T * px; // contained pointer 119 162 detail::shared_count pn; // reference counter 120 163