Commit 1217ee06 by François Dumont

set.h (set): Implement C++11 allocator-aware container requirements.

2014-01-17  François Dumont  <fdumont@gcc.gnu.org>

	* include/profile/set.h (set): Implement C++11 allocator-aware
	container requirements.
	* include/profile/map.h (map): Likewise.
	* include/profile/multiset.h (multiset): Likewise.
	* include/profile/multimap.h (multimap): Likewise.
	* include/profile/set.h
	(set::operator=(const set&)): Define as default in C++11 mode.
	(set::operator=(set&&)): Likewise.
	* include/profile/map.h
	(map::operator=(const map&)): Likewise.
	(map::operator=(map&&)): Likewise.
	* include/profile/multiset.h
	(multiset::operator=(const multiset&)): Likewise.
	(multiset::operator=(multiset&&)): Likewise.
	* include/profile/multimap.h
	(multimap::operator=(const multimap&)): Likewise.
	(multimap::operator=(multimap&&)): Likewise.
	* include/profile/set.h (set::operator=(std::initializer_list<>)):
	Rely on the same operator from normal mode.
	* include/profile/map.h (map::operator=(std::initializer_list<>)):
	Likewise.
	* include/profile/multiset.h
	(multiset::operator=(std::initializer_list<>)): Likewise.
	* include/profile/multimap.h
	(multimap::operator=(std::initializer_list<>)): Likewise.
	* include/profile/set.h (set::swap(set&)): Add noexcept
	specification.
	* include/profile/map.h (map::swap(map&)): Likewise.
	* include/profile/multiset.h (multiset::swap(multiset&)): Likewise.
	* include/profile/multimap.h (multimap::swap(multimap&)): Likewise.

From-SVN: r206733
parent 664ceb1e
2014-01-17 François Dumont <fdumont@gcc.gnu.org>
* include/profile/set.h (set): Implement C++11 allocator-aware
container requirements.
* include/profile/map.h (map): Likewise.
* include/profile/multiset.h (multiset): Likewise.
* include/profile/multimap.h (multimap): Likewise.
* include/profile/set.h
(set::operator=(const set&)): Define as default in C++11 mode.
(set::operator=(set&&)): Likewise.
* include/profile/map.h
(map::operator=(const map&)): Likewise.
(map::operator=(map&&)): Likewise.
* include/profile/multiset.h
(multiset::operator=(const multiset&)): Likewise.
(multiset::operator=(multiset&&)): Likewise.
* include/profile/multimap.h
(multimap::operator=(const multimap&)): Likewise.
(multimap::operator=(multimap&&)): Likewise.
* include/profile/set.h (set::operator=(std::initializer_list<>)):
Rely on the same operator from normal mode.
* include/profile/map.h (map::operator=(std::initializer_list<>)):
Likewise.
* include/profile/multiset.h
(multiset::operator=(std::initializer_list<>)): Likewise.
* include/profile/multimap.h
(multimap::operator=(std::initializer_list<>)): Likewise.
* include/profile/set.h (set::swap(set&)): Add noexcept
specification.
* include/profile/map.h (map::swap(map&)): Likewise.
* include/profile/multiset.h (multiset::swap(multiset&)): Likewise.
* include/profile/multimap.h (multimap::swap(multimap&)): Likewise.
2014-01-17 Tim Shen <timshen91@gmail.com> 2014-01-17 Tim Shen <timshen91@gmail.com>
* include/bits/regex_automaton.tcc (_StateSeq<>::_M_clone()): Do not * include/bits/regex_automaton.tcc (_StateSeq<>::_M_clone()): Do not
......
...@@ -43,6 +43,10 @@ namespace __profile ...@@ -43,6 +43,10 @@ namespace __profile
{ {
typedef _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Allocator> _Base; typedef _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Allocator> _Base;
#if __cplusplus >= 201103L
typedef __gnu_cxx::__alloc_traits<_Allocator> _Alloc_traits;
#endif
public: public:
// types: // types:
typedef _Key key_type; typedef _Key key_type;
...@@ -93,40 +97,61 @@ namespace __profile ...@@ -93,40 +97,61 @@ namespace __profile
map(map&& __x) map(map&& __x)
noexcept(is_nothrow_copy_constructible<_Compare>::value) noexcept(is_nothrow_copy_constructible<_Compare>::value)
: _Base(std::move(__x)) : _Base(std::move(__x))
{ } { __profcxx_map_to_unordered_map_construct(this); }
map(initializer_list<value_type> __l, map(initializer_list<value_type> __l,
const _Compare& __c = _Compare(), const _Compare& __c = _Compare(),
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
: _Base(__l, __c, __a) { } : _Base(__l, __c, __a)
{ __profcxx_map_to_unordered_map_construct(this); }
explicit
map(const allocator_type& __a)
: _Base(__a)
{ __profcxx_map_to_unordered_map_construct(this); }
map(const map& __x, const allocator_type& __a)
: _Base(__x, __a)
{ __profcxx_map_to_unordered_map_construct(this); }
map(map&& __x, const allocator_type& __a)
noexcept(is_nothrow_copy_constructible<_Compare>::value
&& _Alloc_traits::_S_always_equal())
: _Base(std::move(__x), __a)
{ __profcxx_map_to_unordered_map_construct(this); }
map(initializer_list<value_type> __l, const allocator_type& __a)
: _Base(__l, __a)
{ __profcxx_map_to_unordered_map_construct(this); }
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last,
const allocator_type& __a)
: _Base(__first, __last, __a)
{ __profcxx_map_to_unordered_map_construct(this); }
#endif #endif
~map() _GLIBCXX_NOEXCEPT ~map() _GLIBCXX_NOEXCEPT
{ __profcxx_map_to_unordered_map_destruct(this); } { __profcxx_map_to_unordered_map_destruct(this); }
#if __cplusplus < 201103L
map& map&
operator=(const map& __x) operator=(const map& __x)
{ {
*static_cast<_Base*>(this) = __x; _M_base() = __x;
return *this; return *this;
} }
#else
map&
operator=(const map&) = default;
#if __cplusplus >= 201103L
map& map&
operator=(map&& __x) operator=(map&&) = default;
{
// NB: DR 1204.
// NB: DR 675.
this->clear();
this->swap(__x);
return *this;
}
map& map&
operator=(initializer_list<value_type> __l) operator=(initializer_list<value_type> __l)
{ {
this->clear(); _M_base() = __l;
this->insert(__l);
return *this; return *this;
} }
#endif #endif
...@@ -393,6 +418,9 @@ namespace __profile ...@@ -393,6 +418,9 @@ namespace __profile
void void
swap(map& __x) swap(map& __x)
#if __cplusplus >= 201103L
noexcept(_Alloc_traits::_S_nothrow_swap())
#endif
{ _Base::swap(__x); } { _Base::swap(__x); }
void void
......
...@@ -43,6 +43,10 @@ namespace __profile ...@@ -43,6 +43,10 @@ namespace __profile
{ {
typedef _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Allocator> _Base; typedef _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Allocator> _Base;
#if __cplusplus >= 201103L
typedef __gnu_cxx::__alloc_traits<_Allocator> _Alloc_traits;
#endif
public: public:
// types: // types:
typedef _Key key_type; typedef _Key key_type;
...@@ -79,49 +83,62 @@ namespace __profile ...@@ -79,49 +83,62 @@ namespace __profile
const _Allocator& __a = _Allocator()) const _Allocator& __a = _Allocator())
: _Base(__first, __last, __comp, __a) { } : _Base(__first, __last, __comp, __a) { }
#if __cplusplus < 201103L
multimap(const multimap& __x) multimap(const multimap& __x)
: _Base(__x) { } : _Base(__x) { }
#else
multimap(const _Base& __x) multimap(const multimap&) = default;
: _Base(__x) { } multimap(multimap&&) = default;
#if __cplusplus >= 201103L
multimap(multimap&& __x)
noexcept(is_nothrow_copy_constructible<_Compare>::value)
: _Base(std::move(__x))
{ }
multimap(initializer_list<value_type> __l, multimap(initializer_list<value_type> __l,
const _Compare& __c = _Compare(), const _Compare& __c = _Compare(),
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
: _Base(__l, __c, __a) { } : _Base(__l, __c, __a) { }
explicit
multimap(const allocator_type& __a)
: _Base(__a) { }
multimap(const multimap& __x, const allocator_type& __a)
: _Base(__x, __a) { }
multimap(multimap&& __x, const allocator_type& __a)
noexcept(is_nothrow_copy_constructible<_Compare>::value
&& _Alloc_traits::_S_always_equal())
: _Base(std::move(__x), __a) { }
multimap(initializer_list<value_type> __l, const allocator_type& __a)
: _Base(__l, __a) { }
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last,
const allocator_type& __a)
: _Base(__first, __last, __a) { }
#endif #endif
multimap(const _Base& __x)
: _Base(__x) { }
~multimap() _GLIBCXX_NOEXCEPT { } ~multimap() _GLIBCXX_NOEXCEPT { }
#if __cplusplus < 201103L
multimap& multimap&
operator=(const multimap& __x) operator=(const multimap& __x)
{ {
*static_cast<_Base*>(this) = __x; _M_base() = __x;
return *this; return *this;
} }
#else
multimap&
operator=(const multimap&) = default;
#if __cplusplus >= 201103L
multimap& multimap&
operator=(multimap&& __x) operator=(multimap&&) = default;
{
// NB: DR 1204.
// NB: DR 675.
this->clear();
this->swap(__x);
return *this;
}
multimap& multimap&
operator=(initializer_list<value_type> __l) operator=(initializer_list<value_type> __l)
{ {
this->clear(); _M_base() = __l;
this->insert(__l);
return *this; return *this;
} }
#endif #endif
...@@ -289,6 +306,9 @@ namespace __profile ...@@ -289,6 +306,9 @@ namespace __profile
void void
swap(multimap& __x) swap(multimap& __x)
#if __cplusplus >= 201103L
noexcept(_Alloc_traits::_S_nothrow_swap())
#endif
{ _Base::swap(__x); } { _Base::swap(__x); }
void void
......
...@@ -43,6 +43,10 @@ namespace __profile ...@@ -43,6 +43,10 @@ namespace __profile
{ {
typedef _GLIBCXX_STD_C::multiset<_Key, _Compare, _Allocator> _Base; typedef _GLIBCXX_STD_C::multiset<_Key, _Compare, _Allocator> _Base;
#if __cplusplus >= 201103L
typedef __gnu_cxx::__alloc_traits<_Allocator> _Alloc_traits;
#endif
public: public:
// types: // types:
typedef _Key key_type; typedef _Key key_type;
...@@ -79,49 +83,62 @@ namespace __profile ...@@ -79,49 +83,62 @@ namespace __profile
const _Allocator& __a = _Allocator()) const _Allocator& __a = _Allocator())
: _Base(__first, __last, __comp, __a) { } : _Base(__first, __last, __comp, __a) { }
#if __cplusplus < 201103L
multiset(const multiset& __x) multiset(const multiset& __x)
: _Base(__x) { } : _Base(__x) { }
#else
multiset(const _Base& __x) multiset(const multiset&) = default;
: _Base(__x) { } multiset(multiset&&) = default;
#if __cplusplus >= 201103L
multiset(multiset&& __x)
noexcept(is_nothrow_copy_constructible<_Compare>::value)
: _Base(std::move(__x))
{ }
multiset(initializer_list<value_type> __l, multiset(initializer_list<value_type> __l,
const _Compare& __comp = _Compare(), const _Compare& __comp = _Compare(),
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
: _Base(__l, __comp, __a) { } : _Base(__l, __comp, __a) { }
explicit
multiset(const allocator_type& __a)
: _Base(__a) { }
multiset(const multiset& __x, const allocator_type& __a)
: _Base(__x, __a) { }
multiset(multiset&& __x, const allocator_type& __a)
noexcept(is_nothrow_copy_constructible<_Compare>::value
&& _Alloc_traits::_S_always_equal())
: _Base(std::move(__x), __a) { }
multiset(initializer_list<value_type> __l, const allocator_type& __a)
: _Base(__l, __a) { }
template<typename _InputIterator>
multiset(_InputIterator __first, _InputIterator __last,
const allocator_type& __a)
: _Base(__first, __last, __a) { }
#endif #endif
multiset(const _Base& __x)
: _Base(__x) { }
~multiset() _GLIBCXX_NOEXCEPT { } ~multiset() _GLIBCXX_NOEXCEPT { }
#if __cplusplus < 201103L
multiset& multiset&
operator=(const multiset& __x) operator=(const multiset& __x)
{ {
*static_cast<_Base*>(this) = __x; _M_base() = __x;
return *this; return *this;
} }
#else
multiset&
operator=(const multiset&) = default;
#if __cplusplus >= 201103L
multiset& multiset&
operator=(multiset&& __x) operator=(multiset&&) = default;
{
// NB: DR 1204.
// NB: DR 675.
this->clear();
this->swap(__x);
return *this;
}
multiset& multiset&
operator=(initializer_list<value_type> __l) operator=(initializer_list<value_type> __l)
{ {
this->clear(); _M_base() = __l;
this->insert(__l);
return *this; return *this;
} }
#endif #endif
...@@ -272,6 +289,9 @@ namespace __profile ...@@ -272,6 +289,9 @@ namespace __profile
void void
swap(multiset& __x) swap(multiset& __x)
#if __cplusplus >= 201103L
noexcept(_Alloc_traits::_S_nothrow_swap())
#endif
{ _Base::swap(__x); } { _Base::swap(__x); }
void void
......
...@@ -43,6 +43,10 @@ namespace __profile ...@@ -43,6 +43,10 @@ namespace __profile
{ {
typedef _GLIBCXX_STD_C::set<_Key, _Compare, _Allocator> _Base; typedef _GLIBCXX_STD_C::set<_Key, _Compare, _Allocator> _Base;
#if __cplusplus >= 201103L
typedef __gnu_cxx::__alloc_traits<_Allocator> _Alloc_traits;
#endif
public: public:
// types: // types:
typedef _Key key_type; typedef _Key key_type;
...@@ -79,49 +83,62 @@ namespace __profile ...@@ -79,49 +83,62 @@ namespace __profile
const _Allocator& __a = _Allocator()) const _Allocator& __a = _Allocator())
: _Base(__first, __last, __comp, __a) { } : _Base(__first, __last, __comp, __a) { }
#if __cplusplus < 201103L
set(const set& __x) set(const set& __x)
: _Base(__x) { } : _Base(__x) { }
#else
set(const _Base& __x) set(const set&) = default;
: _Base(__x) { } set(set&&) = default;
#if __cplusplus >= 201103L
set(set&& __x)
noexcept(is_nothrow_copy_constructible<_Compare>::value)
: _Base(std::move(__x))
{ }
set(initializer_list<value_type> __l, set(initializer_list<value_type> __l,
const _Compare& __comp = _Compare(), const _Compare& __comp = _Compare(),
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
: _Base(__l, __comp, __a) { } : _Base(__l, __comp, __a) { }
explicit
set(const allocator_type& __a)
: _Base(__a) { }
set(const set& __x, const allocator_type& __a)
: _Base(__x, __a) { }
set(set&& __x, const allocator_type& __a)
noexcept(is_nothrow_copy_constructible<_Compare>::value
&& _Alloc_traits::_S_always_equal())
: _Base(std::move(__x), __a) { }
set(initializer_list<value_type> __l, const allocator_type& __a)
: _Base(__l, __a) { }
template<typename _InputIterator>
set(_InputIterator __first, _InputIterator __last,
const allocator_type& __a)
: _Base(__first, __last, __a) { }
#endif #endif
set(const _Base& __x)
: _Base(__x) { }
~set() _GLIBCXX_NOEXCEPT { } ~set() _GLIBCXX_NOEXCEPT { }
#if __cplusplus < 201103L
set& set&
operator=(const set& __x) operator=(const set& __x)
{ {
*static_cast<_Base*>(this) = __x; _M_base() = __x;
return *this; return *this;
} }
#else
set&
operator=(const set&) = default;
#if __cplusplus >= 201103L
set& set&
operator=(set&& __x) operator=(set&&) = default;
{
// NB: DR 1204.
// NB: DR 675.
this->clear();
this->swap(__x);
return *this;
}
set& set&
operator=(initializer_list<value_type> __l) operator=(initializer_list<value_type> __l)
{ {
this->clear(); _M_base() = __l;
this->insert(__l);
return *this; return *this;
} }
#endif #endif
...@@ -286,6 +303,9 @@ namespace __profile ...@@ -286,6 +303,9 @@ namespace __profile
void void
swap(set& __x) swap(set& __x)
#if __cplusplus >= 201103L
noexcept(_Alloc_traits::_S_nothrow_swap())
#endif
{ _Base::swap(__x); } { _Base::swap(__x); }
void void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment