This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3, libstdcxx_so_7] Finish fixing container constructors + signatures


Hi,

tested x86-linux, committed to libstdcxx_so_7-branch.

Paolo.

///////////////
2004-10-08  Paolo Carlini  <pcarlini@suse.de>

	* include/bits/stl_map.h (map::map(const _Compare&,
	const allocator_type&), map::map(_InputIterator, _InputIterator,
	const _Compare&, const allocator_type&)): Implement according to
	the letter of the standard, i.e., don't use two overloads.
	* include/bits/stl_multimap.h: Likewise for multimap.
	* include/bits/stl_multiset.h: Likewise for multiset.
	* include/bits/stl_set.h: Likewise for set.

	* include/bits/stl_bvector.h (vector::vector(size_type, bool,
	const allocator_type&)): Don't use two overloads; fix the
	signature, the second argument is by const ref.

	* include/bits/stl_bvector.h (assign(size_t, bool)): Fix the
	signature: according to the standard the second argument is by
	const ref.
	(insert(iterator, bool)): Likewise.
	(insert(iterator, size_type, bool)): Likewise for the third arg.

	
diff -urN libstdc++-v3-orig/include/bits/stl_bvector.h libstdc++-v3/include/bits/stl_bvector.h
--- libstdc++-v3-orig/include/bits/stl_bvector.h	2004-08-17 16:48:47.000000000 +0200
+++ libstdc++-v3/include/bits/stl_bvector.h	2004-10-08 14:17:32.000000000 +0200
@@ -626,7 +626,8 @@
     vector(const allocator_type& __a = allocator_type())
     : _Bvector_base<_Alloc>(__a) { }
 
-    vector(size_type __n, bool __value, 
+    explicit
+    vector(size_type __n, const bool& __value = bool(), 
 	   const allocator_type& __a = allocator_type())
     : _Bvector_base<_Alloc>(__a)
     {
@@ -635,15 +636,6 @@
 		__value ? ~0 : 0);
     }
 
-    explicit
-    vector(size_type __n)
-    : _Bvector_base<_Alloc>(allocator_type())
-    {
-      _M_initialize(__n);
-      std::fill(this->_M_impl._M_start._M_p, 
-		this->_M_impl._M_end_of_storage, 0);
-    }
-
     vector(const vector& __x)
     : _Bvector_base<_Alloc>(__x.get_allocator())
     {
@@ -717,7 +709,7 @@
     }
 
     void
-    assign(size_t __n, bool __x)
+    assign(size_type __n, const bool& __x)
     { _M_fill_assign(__n, __x); }
 
     template<class _InputIterator>
@@ -831,7 +823,7 @@
     }
 
     iterator
-    insert(iterator __position, bool __x = bool())
+    insert(iterator __position, const bool& __x = bool())
     {
       const difference_type __n = __position - begin();
       if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_of_storage
@@ -895,7 +887,7 @@
     }
 
     void
-    insert(iterator __position, size_type __n, bool __x)
+    insert(iterator __position, size_type __n, const bool& __x)
     { _M_fill_insert(__position, __n, __x); }
 
     void
diff -urN libstdc++-v3-orig/include/bits/stl_map.h libstdc++-v3/include/bits/stl_map.h
--- libstdc++-v3-orig/include/bits/stl_map.h	2004-08-17 16:48:48.000000000 +0200
+++ libstdc++-v3/include/bits/stl_map.h	2004-10-08 16:14:36.000000000 +0200
@@ -144,15 +144,9 @@
       /**
        *  @brief  Default constructor creates no elements.
        */
-      map()
-      : _M_t(_Compare(), allocator_type()) { }
-
-      // for some reason this was made a separate function
-      /**
-       *  @brief  Default constructor creates no elements.
-       */
       explicit
-      map(const _Compare& __comp, const allocator_type& __a = allocator_type())
+      map(const _Compare& __comp = _Compare(),
+	  const allocator_type& __a = allocator_type())
       : _M_t(__comp, __a) { }
 
       /**
@@ -169,20 +163,6 @@
        *  @brief  Builds a %map from a range.
        *  @param  first  An input iterator.
        *  @param  last  An input iterator.
-       *
-       *  Create a %map consisting of copies of the elements from [first,last).
-       *  This is linear in N if the range is already sorted, and NlogN
-       *  otherwise (where N is distance(first,last)).
-       */
-      template <typename _InputIterator>
-        map(_InputIterator __first, _InputIterator __last)
-	: _M_t(_Compare(), allocator_type())
-        { _M_t.insert_unique(__first, __last); }
-
-      /**
-       *  @brief  Builds a %map from a range.
-       *  @param  first  An input iterator.
-       *  @param  last  An input iterator.
        *  @param  comp  A comparison functor.
        *  @param  a  An allocator object.
        *
@@ -192,7 +172,8 @@
        */
       template <typename _InputIterator>
         map(_InputIterator __first, _InputIterator __last,
-	    const _Compare& __comp, const allocator_type& __a = allocator_type())
+	    const _Compare& __comp = _Compare(),
+	    const allocator_type& __a = allocator_type())
 	: _M_t(__comp, __a)
         { _M_t.insert_unique(__first, __last); }
 
diff -urN libstdc++-v3-orig/include/bits/stl_multimap.h libstdc++-v3/include/bits/stl_multimap.h
--- libstdc++-v3-orig/include/bits/stl_multimap.h	2004-08-17 16:48:48.000000000 +0200
+++ libstdc++-v3/include/bits/stl_multimap.h	2004-10-08 16:00:55.000000000 +0200
@@ -159,15 +159,8 @@
       /**
        *  @brief  Default constructor creates no elements.
        */
-      multimap()
-      : _M_t(_Compare(), allocator_type()) { }
-
-      // for some reason this was made a separate function
-      /**
-       *  @brief  Default constructor creates no elements.
-       */
       explicit
-      multimap(const _Compare& __comp,
+      multimap(const _Compare& __comp = _Compare(),
 	       const allocator_type& __a = allocator_type())
       : _M_t(__comp, __a) { }
 
@@ -185,20 +178,6 @@
        *  @brief  Builds a %multimap from a range.
        *  @param  first  An input iterator.
        *  @param  last  An input iterator.
-       *
-       *  Create a %multimap consisting of copies of the elements from
-       *  [first,last).  This is linear in N if the range is already sorted,
-       *  and NlogN otherwise (where N is distance(first,last)).
-       */
-      template <typename _InputIterator>
-        multimap(_InputIterator __first, _InputIterator __last)
-	: _M_t(_Compare(), allocator_type())
-        { _M_t.insert_equal(__first, __last); }
-
-      /**
-       *  @brief  Builds a %multimap from a range.
-       *  @param  first  An input iterator.
-       *  @param  last  An input iterator.
        *  @param  comp  A comparison functor.
        *  @param  a  An allocator object.
        *
@@ -208,7 +187,7 @@
        */
       template <typename _InputIterator>
         multimap(_InputIterator __first, _InputIterator __last,
-		 const _Compare& __comp,
+		 const _Compare& __comp = _Compare(),
 		 const allocator_type& __a = allocator_type())
         : _M_t(__comp, __a)
         { _M_t.insert_equal(__first, __last); }
diff -urN libstdc++-v3-orig/include/bits/stl_multiset.h libstdc++-v3/include/bits/stl_multiset.h
--- libstdc++-v3-orig/include/bits/stl_multiset.h	2004-04-16 21:04:03.000000000 +0200
+++ libstdc++-v3/include/bits/stl_multiset.h	2004-10-08 15:59:19.000000000 +0200
@@ -144,11 +144,8 @@
     /**
      *  @brief  Default constructor creates no elements.
      */
-      multiset()
-      : _M_t(_Compare(), allocator_type()) { }
-
       explicit
-      multiset(const _Compare& __comp,
+      multiset(const _Compare& __comp = _Compare(),
 	       const allocator_type& __a = allocator_type())
       : _M_t(__comp, __a) { }
 
@@ -156,20 +153,6 @@
        *  @brief  Builds a %multiset from a range.
        *  @param  first  An input iterator.
        *  @param  last  An input iterator.
-       *
-       *  Create a %multiset consisting of copies of the elements from
-       *  [first,last).  This is linear in N if the range is already sorted,
-       *  and NlogN otherwise (where N is distance(first,last)).
-       */
-      template <class _InputIterator>
-        multiset(_InputIterator __first, _InputIterator __last)
-	: _M_t(_Compare(), allocator_type())
-        { _M_t.insert_equal(__first, __last); }
-
-      /**
-       *  @brief  Builds a %multiset from a range.
-       *  @param  first  An input iterator.
-       *  @param  last  An input iterator.
        *  @param  comp  A comparison functor.
        *  @param  a  An allocator object.
        *
@@ -179,7 +162,7 @@
        */
       template <class _InputIterator>
         multiset(_InputIterator __first, _InputIterator __last,
-		 const _Compare& __comp,
+		 const _Compare& __comp = _Compare(),
 		 const allocator_type& __a = allocator_type())
 	: _M_t(__comp, __a)
         { _M_t.insert_equal(__first, __last); }
diff -urN libstdc++-v3-orig/include/bits/stl_set.h libstdc++-v3/include/bits/stl_set.h
--- libstdc++-v3-orig/include/bits/stl_set.h	2004-04-16 21:04:03.000000000 +0200
+++ libstdc++-v3/include/bits/stl_set.h	2004-10-08 15:58:41.000000000 +0200
@@ -145,38 +145,21 @@
       //@}
 
       // allocation/deallocation
-      ///  Default constructor creates no elements.
-      set()
-      : _M_t(_Compare(), allocator_type()) {}
-
       /**
        *  @brief  Default constructor creates no elements.
        *
        *  @param  comp  Comparator to use.
        *  @param  a  Allocator to use.
        */
-      explicit set(const _Compare& __comp,
-		   const allocator_type& __a = allocator_type())
+      explicit
+      set(const _Compare& __comp = _Compare(),
+	  const allocator_type& __a = allocator_type())
       : _M_t(__comp, __a) {}
 
       /**
        *  @brief  Builds a %set from a range.
        *  @param  first  An input iterator.
        *  @param  last  An input iterator.
-       *
-       *  Create a %set consisting of copies of the elements from [first,last).
-       *  This is linear in N if the range is already sorted, and NlogN
-       *  otherwise (where N is distance(first,last)).
-       */
-      template<class _InputIterator>
-        set(_InputIterator __first, _InputIterator __last)
-        : _M_t(_Compare(), allocator_type())
-        { _M_t.insert_unique(__first, __last); }
-
-      /**
-       *  @brief  Builds a %set from a range.
-       *  @param  first  An input iterator.
-       *  @param  last  An input iterator.
        *  @param  comp  A comparison functor.
        *  @param  a  An allocator object.
        *
@@ -186,7 +169,7 @@
        */
       template<class _InputIterator>
         set(_InputIterator __first, _InputIterator __last,
-	    const _Compare& __comp,
+	    const _Compare& __comp = _Compare(),
 	    const allocator_type& __a = allocator_type())
 	: _M_t(__comp, __a)
         { _M_t.insert_unique(__first, __last); }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]