diff --git a/STL_Extension/include/CGAL/Handle_for.h b/STL_Extension/include/CGAL/Handle_for.h index 3ea2fca597d..878b4cb9b2d 100644 --- a/STL_Extension/include/CGAL/Handle_for.h +++ b/STL_Extension/include/CGAL/Handle_for.h @@ -59,22 +59,22 @@ public: Handle_for() : ptr_(allocator.allocate(1)) { - new (&(ptr_->t)) T(); // we get the warning here + new (&(ptr_->t)) element_type(); // we get the warning here ptr_->count = 1; } - Handle_for(const T& t) + Handle_for(const element_type& t) : ptr_(allocator.allocate(1)) { - new (&(ptr_->t)) T(t); + new (&(ptr_->t)) element_type(t); ptr_->count = 1; } #ifndef CGAL_CFG_NO_CPP0X_RVALUE_REFERENCE - Handle_for(T && t) + Handle_for(element_type && t) : ptr_(allocator.allocate(1)) { - new (&(ptr_->t)) T(std::move(t)); + new (&(ptr_->t)) element_type(std::move(t)); ptr_->count = 1; } #endif @@ -95,7 +95,7 @@ public: Handle_for(T1 && t1, T2 && t2, Args && ... args) : ptr_(allocator.allocate(1)) { - new (&(ptr_->t)) T(std::forward(t1), std::forward(t2), std::forward(args)...); + new (&(ptr_->t)) element_type(std::forward(t1), std::forward(t2), std::forward(args)...); ptr_->count = 1; } #else @@ -103,7 +103,7 @@ public: Handle_for(const T1& t1, const T2& t2) : ptr_(allocator.allocate(1)) { - new (&(ptr_->t)) T(t1, t2); + new (&(ptr_->t)) element_type(t1, t2); ptr_->count = 1; } @@ -111,7 +111,7 @@ public: Handle_for(const T1& t1, const T2& t2, const T3& t3) : ptr_(allocator.allocate(1)) { - new (&(ptr_->t)) T(t1, t2, t3); + new (&(ptr_->t)) element_type(t1, t2, t3); ptr_->count = 1; } @@ -119,7 +119,7 @@ public: Handle_for(const T1& t1, const T2& t2, const T3& t3, const T4& t4) : ptr_(allocator.allocate(1)) { - new (&(ptr_->t)) T(t1, t2, t3, t4); + new (&(ptr_->t)) element_type(t1, t2, t3, t4); ptr_->count = 1; } #endif // CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES @@ -139,7 +139,7 @@ public: } Handle_for& - operator=(const T &t) + operator=(const element_type &t) { if (is_shared()) *this = Handle_for(t); @@ -161,7 +161,7 @@ public: } Handle_for& - operator=(T && t) + operator=(element_type && t) { if (is_shared()) *this = Handle_for(std::move(t)); @@ -183,7 +183,7 @@ public: } void - initialize_with(const T& t) + initialize_with(const element_type& t) { // kept for backward compatibility. Use operator=(t) instead. *this = t; @@ -196,7 +196,7 @@ public: // Ptr() is the "public" access to the pointer to the object. // The non-const version asserts that the instance is not shared. - const T * + const element_type * Ptr() const { return &(ptr_->t); @@ -244,7 +244,7 @@ protected: if ( is_shared() ) { pointer tmp_ptr = allocator.allocate(1); - new (&(tmp_ptr->t)) T(ptr_->t); + new (&(tmp_ptr->t)) element_type(ptr_->t); tmp_ptr->count = 1; --(ptr_->count); ptr_ = tmp_ptr; @@ -253,11 +253,11 @@ protected: // ptr() is the protected access to the pointer. Both const and non-const. // Redundant with Ptr(). - T * + element_type * ptr() { return &(ptr_->t); } - const T * + const element_type * ptr() const { return &(ptr_->t); } }; diff --git a/STL_Extension/include/CGAL/Handle_with_policy.h b/STL_Extension/include/CGAL/Handle_with_policy.h index 883f0f4e0cd..99955c4c354 100644 --- a/STL_Extension/include/CGAL/Handle_with_policy.h +++ b/STL_Extension/include/CGAL/Handle_with_policy.h @@ -182,18 +182,18 @@ class Handle_policy_union_and_reset; template class Reference_counted { public: - typedef T_ T; - typedef Reference_counted Self; - typedef T* Rep_pointer; + typedef T_ rep_type; + typedef Reference_counted Self; + typedef rep_type* Rep_pointer; private: mutable unsigned int count; // reference counter - T rep; + rep_type rep; public: Reference_counted() : count(1) {} - Reference_counted( const T& t) : count(1), rep(t) {} + Reference_counted( const rep_type& t) : count(1), rep(t) {} Reference_counted( const Self& r) : count(1), rep(r.rep) {} - void clear() { rep = T(); } + void clear() { rep = rep_type(); } Rep_pointer base_ptr() { return &rep; } void add_reference() { ++count; } void remove_reference() { --count; } @@ -209,25 +209,25 @@ public: template class Reference_counted_with_forwarding { public: - typedef T_ T; - typedef Reference_counted_with_forwarding Self; - typedef T* Rep_pointer; + typedef T_ rep_type; + typedef Reference_counted_with_forwarding Self; + typedef rep_type* Rep_pointer; friend class Handle_policy_union; friend class Handle_policy_union_and_reset; private: mutable unsigned int count; // reference counter mutable Self* next; // forwarding pointer to valid rep or 0 mutable int u_size; // union set size incl this rep and its handle - mutable T rep; + mutable rep_type rep; public: Reference_counted_with_forwarding() : count(1), next(0), u_size(2) {} - Reference_counted_with_forwarding( const T& t) + Reference_counted_with_forwarding( const rep_type& t) : count(1), next(0), u_size(2), rep(t) {} Reference_counted_with_forwarding( const Self& r) : count(1), next(0), u_size(2), rep(r.rep) {} - void clear() { rep = T(); } + void clear() { rep = rep_type(); } Rep_pointer base_ptr() { return &rep; } void add_reference() { ++count; } void remove_reference() { --count; } @@ -716,10 +716,10 @@ class Handle_with_policy { public: //! first template parameter - typedef T_ T; + typedef T_ Handled_type; //! the handle type itself. - typedef Handle_with_policy< T, HandlePolicy, Allocator_> Self; + typedef Handle_with_policy< Handled_type, HandlePolicy, Allocator_> Self; //! the instantiated model of the \c HandlePolicy concept. typedef HandlePolicy Handle_policy; @@ -728,10 +728,13 @@ public: typedef Allocator_ Allocator; enum { is_class_hierarchy = - ::CGAL::is_same_or_derived< Reference_counted_hierarchy_base, T>::value }; - typedef typename Handle_policy::template Rep_bind< T, is_class_hierarchy > Bind; + ::CGAL::is_same_or_derived< Reference_counted_hierarchy_base, Handled_type>::value }; + + typedef typename Handle_policy::template Rep_bind< Handled_type, is_class_hierarchy > Bind; + // instantiate Rep_bind to activate compile time check in there static Bind bind; + // Define type that is used for function matching typedef typename ::boost::mpl::if_c< is_class_hierarchy, @@ -766,7 +769,7 @@ private: static Rep* new_rep( const Rep& rep) { BOOST_STATIC_ASSERT( !( - ::CGAL::is_same_or_derived< Reference_counted_hierarchy_base, T >::value )); + ::CGAL::is_same_or_derived< Reference_counted_hierarchy_base, Handled_type >::value )); Rep* p = allocator.allocate(1); allocator.construct(p, rep); return p; @@ -801,7 +804,7 @@ private: template Rep* make_from_single_arg( const TT& t, ::CGAL::Tag_false ) { - return new_rep( Rep( T(t))); + return new_rep( Rep( Handled_type(t))); } template Rep* make_from_single_arg( TT t, ::CGAL::Tag_true ) { @@ -813,10 +816,10 @@ private: protected: //! protected access to the stored representation - T* ptr() { return static_cast(Handle_policy::find(*this));} + Handled_type* ptr() { return static_cast(Handle_policy::find(*this));} //! protected access to the stored representation - const T* ptr() const { - return static_cast(Handle_policy::find( *this)); + const Handled_type* ptr() const { + return static_cast(Handle_policy::find( *this)); } //! unify two representations. \pre The two representations describe @@ -861,7 +864,7 @@ protected: //! constructor will work for class hierarchies of representations. Handle_with_policy( Rep* p) : ptr_( p) { BOOST_STATIC_ASSERT(( - ::CGAL::is_same_or_derived< Reference_counted_hierarchy_base, T >::value )); + ::CGAL::is_same_or_derived< Reference_counted_hierarchy_base, Handled_type >::value )); //Bind bind_; // trigger compile-time check //(void)bind_; (void)Bind(); @@ -875,7 +878,7 @@ protected: //! the template version with one argument. void initialize_with( Rep* p) { BOOST_STATIC_ASSERT(( - ::CGAL::is_same_or_derived< Reference_counted_hierarchy_base, T >::value )); + ::CGAL::is_same_or_derived< Reference_counted_hierarchy_base, Handled_type >::value )); //Bind bind_; // trigger compile-time check //(void)bind_; (void)Bind(); @@ -903,7 +906,7 @@ protected: void initialize_with( const T1& t1, const T2& t2) { CGAL_precondition_msg( ptr_ == 0, "Handle_with_policy::initialize_with(): the " "representation has already been initialized."); - ptr_ = new_rep( Rep( T(t1,t2))); + ptr_ = new_rep( Rep( Handled_type(t1,t2))); } //! initializes the representation after the constructor from @@ -912,7 +915,7 @@ protected: void initialize_with( const T1& t1, const T2& t2, const T3& t3) { CGAL_precondition_msg( ptr_ == 0, "Handle_with_policy::initialize_with(): the " "representation has already been initialized."); - ptr_ = new_rep( Rep( T(t1,t2,t3))); + ptr_ = new_rep( Rep( Handled_type(t1,t2,t3))); } //! initializes the representation after the constructor from @@ -922,7 +925,7 @@ protected: const T4& t4) { CGAL_precondition_msg( ptr_ == 0, "Handle_with_policy::initialize_with(): the " "representation has already been initialized."); - ptr_ = new_rep( Rep( T(t1,t2,t3,t4))); + ptr_ = new_rep( Rep( Handled_type(t1,t2,t3,t4))); } //! initializes the representation after the constructor from @@ -932,7 +935,7 @@ protected: const T4& t4, const T5& t5) { CGAL_precondition_msg( ptr_ == 0, "Handle_with_policy::initialize_with(): the " "representation has already been initialized."); - ptr_ = new_rep( Rep( T(t1,t2,t3,t4,t5))); + ptr_ = new_rep( Rep( Handled_type(t1,t2,t3,t4,t5))); } //! initializes the representation after the constructor from @@ -942,7 +945,7 @@ protected: const T4& t4, const T5& t5, const T6& t6) { CGAL_precondition_msg( ptr_ == 0, "Handle_with_policy::initialize_with(): the " "representation has already been initialized."); - ptr_ = new_rep( Rep( T(t1,t2,t3,t4,t5,t6))); + ptr_ = new_rep( Rep( Handled_type(t1,t2,t3,t4,t5,t6))); } //! initializes the representation after the constructor from @@ -954,7 +957,7 @@ protected: const T7& t7) { CGAL_precondition_msg( ptr_ == 0, "Handle_with_policy::initialize_with(): the " "representation has already been initialized."); - ptr_ = new_rep( Rep( T(t1,t2,t3,t4,t5,t6,t7))); + ptr_ = new_rep( Rep( Handled_type(t1,t2,t3,t4,t5,t6,t7))); } //! initializes the representation after the constructor from @@ -966,7 +969,7 @@ protected: const T7& t7, const T8& t8) { CGAL_precondition_msg( ptr_ == 0, "Handle_with_policy::initialize_with(): the " "representation has already been initialized."); - ptr_ = new_rep( Rep( T(t1,t2,t3,t4,t5,t6,t7,t8))); + ptr_ = new_rep( Rep( Handled_type(t1,t2,t3,t4,t5,t6,t7,t8))); } //! initializes the representation after the constructor from @@ -978,7 +981,7 @@ protected: const T7& t7, const T8& t8, const T9& t9) { CGAL_precondition_msg( ptr_ == 0, "Handle_with_policy::initialize_with(): the " "representation has already been initialized."); - ptr_ = new_rep( Rep( T(t1,t2,t3,t4,t5,t6,t7,t8,t9))); + ptr_ = new_rep( Rep( Handled_type(t1,t2,t3,t4,t5,t6,t7,t8,t9))); } public: @@ -1008,33 +1011,33 @@ public: //! forwarding constructor passing its parameters to the representation //! constructor. template - Handle_with_policy( const T1& t1, const T2& t2) : ptr_( new_rep( Rep( T( t1, t2)))) {} + Handle_with_policy( const T1& t1, const T2& t2) : ptr_( new_rep( Rep( Handled_type( t1, t2)))) {} //! forwarding constructor passing its parameters to the representation //! constructor. template Handle_with_policy( const T1& t1, const T2& t2, const T3& t3) - : ptr_( new_rep( Rep( T( t1, t2, t3)))) {} + : ptr_( new_rep( Rep( Handled_type( t1, t2, t3)))) {} //! forwarding constructor passing its parameters to the representation //! constructor. template Handle_with_policy( const T1& t1, const T2& t2, const T3& t3, const T4& t4) - : ptr_( new_rep( Rep( T( t1, t2, t3, t4)))) {} + : ptr_( new_rep( Rep( Handled_type( t1, t2, t3, t4)))) {} //! forwarding constructor passing its parameters to the representation //! constructor. template Handle_with_policy( const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5) - : ptr_( new_rep( Rep( T( t1, t2, t3, t4, t5)))) {} + : ptr_( new_rep( Rep( Handled_type( t1, t2, t3, t4, t5)))) {} //! forwarding constructor passing its parameters to the representation //! constructor. template Handle_with_policy( const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6) - : ptr_( new_rep( Rep( T( t1, t2, t3, t4, t5, t6)))) {} + : ptr_( new_rep( Rep( Handled_type( t1, t2, t3, t4, t5, t6)))) {} //! forwarding constructor passing its parameters to the representation //! constructor. @@ -1042,7 +1045,7 @@ public: class T7> Handle_with_policy( const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7) - : ptr_( new_rep( Rep( T( t1, t2, t3, t4, t5, t6, t7)))) {} + : ptr_( new_rep( Rep( Handled_type( t1, t2, t3, t4, t5, t6, t7)))) {} //! forwarding constructor passing its parameters to the representation //! constructor. @@ -1050,7 +1053,7 @@ public: class T7, class T8> Handle_with_policy( const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8) - : ptr_( new_rep( Rep( T( t1, t2, t3, t4, t5, t6, t7, t8)))) {} + : ptr_( new_rep( Rep( Handled_type( t1, t2, t3, t4, t5, t6, t7, t8)))) {} //! forwarding constructor passing its parameters to the representation //! constructor. @@ -1059,7 +1062,7 @@ public: Handle_with_policy( const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9) - : ptr_( new_rep( Rep( T( t1, t2, t3, t4, t5, t6, t7, t8, t9)))) {} + : ptr_( new_rep( Rep( Handled_type( t1, t2, t3, t4, t5, t6, t7, t8, t9)))) {} //! destructor, decrements reference count. ~Handle_with_policy() { @@ -1144,10 +1147,10 @@ class Handle_with_policy { public: //! first template paramter - typedef T_ T; + typedef T_ Handled_type; //! the handle type itself. - typedef Handle_with_policy< T, Handle_policy_in_place, Allocator_> Self; + typedef Handle_with_policy< Handled_type, Handle_policy_in_place, Allocator_> Self; //! the model of the \c HandlePolicy concept. typedef Handle_policy_in_place Handle_policy; @@ -1156,7 +1159,7 @@ public: typedef Allocator_ Allocator; //! identify \c T with the internal representation \c Rep. - typedef T Rep; + typedef Handled_type Rep; //! integer type for identifying a representation. typedef std::ptrdiff_t Id_type; @@ -1166,9 +1169,9 @@ private: protected: //! protected access to the stored representation - T* ptr() { return &rep; } + Handled_type* ptr() { return &rep; } //! protected access to the stored representation - const T* ptr() const { return &rep; } + const Handled_type* ptr() const { return &rep; } //! unify two representations, a null op here. void unify( const Self&) const {} @@ -1330,7 +1333,7 @@ public: //! returns a unique id value. Two handles share their representation //! is their id values are identical. - Id_type id() const { return ptr() - static_cast(0); } + Id_type id() const { return ptr() - static_cast(0); } //! returns \c false since the representation is not shared for //! this specialization.