This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[patch, v7] Finish simplifying container constructors
- From: Paolo Carlini <pcarlini at suse dot de>
- To: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Fri, 08 Oct 2004 14:31:08 +0200
- Subject: [patch, v7] Finish simplifying container constructors
Hi,
this is the last, final, part of the work started a couple of weeks
ago and solicited by the issue with non default constructible Ts:
as Matt explained, currently there are no real reasons anymore to
overload the constructors.
As happens, poor vector<bool> had some signatures wrong, fixed
that too.
Tested x86-linux, if nobody objects will apply to v7 later today.
Paolo.
////////////
2004-10-08 Paolo Carlini <pcarlini@suse.de>
* include/bits/stl_map.h (map::map(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: Likewise for vector<bool>.
* include/bits/stl_bvector.h (assign(size_t, bool)): Fix 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 13:44:50.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) { }
/**
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 13:45:48.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) { }
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 13:47:33.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) { }
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 13:46:35.000000000 +0200
@@ -145,18 +145,15 @@
//@}
// 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) {}
/**