mirror of git://gcc.gnu.org/git/gcc.git
array: Clean useless white chars.
2014-05-24 François Dumont <fdumont@gcc.gnu.org> * include/profile/array: Clean useless white chars. * include/profile/base.h: Likewise. * include/profile/iterator_tracker.h: Likewise. * include/profile/bitset: Code cleanup and remove not instrumented code. * include/profile/deque: Likewise. * include/profile/forward_list: Likewise. * include/profile/list (std::__profile::_List_profile<>): New. (std::__profile::list<>): Inherit from latter and adapt. * include/profile/impl/profiler_map_to_unordered_map.h: Generalize advise to match any ordered to unordered container conversion. * include/profile/ordered_base.h (std::__profile::_Ordered_profile<>): New. * include/Makefile.am: Add latter. * include/Makefile.in: Regenerate. * include/profile/map.h (std::__profile::map<>): Inherit from latter, remove not instrumented code. * include/profile/multimap.h (std::__profile::multimap<>): Likewise. * include/profile/set.h (std::__profile::set<>): Likewise. * include/profile/multiset.h (std::__profile::multiset<>): Likewise. * include/profile/unordered_base.h: Add some line feed. * include/profile/unordered_map: Clean useless white chars and replace spaces with tabs. * include/profile/unordered_set: Likewise. * include/profile/vector (std::__profile::_Vector_profile_pre<>): New. (std::__profile::_Vector_profile_post<>): New. (std::__profile::vector<>): Inherit from latter and adapt. From-SVN: r210900
This commit is contained in:
parent
1ebfdcab6b
commit
f3de79d43a
|
|
@ -1,3 +1,32 @@
|
||||||
|
2014-05-24 François Dumont <fdumont@gcc.gnu.org>
|
||||||
|
|
||||||
|
* include/profile/array: Clean useless white chars.
|
||||||
|
* include/profile/base.h: Likewise.
|
||||||
|
* include/profile/iterator_tracker.h: Likewise.
|
||||||
|
* include/profile/bitset: Code cleanup and remove not instrumented code.
|
||||||
|
* include/profile/deque: Likewise.
|
||||||
|
* include/profile/forward_list: Likewise.
|
||||||
|
* include/profile/list (std::__profile::_List_profile<>): New.
|
||||||
|
(std::__profile::list<>): Inherit from latter and adapt.
|
||||||
|
* include/profile/impl/profiler_map_to_unordered_map.h: Generalize
|
||||||
|
advise to match any ordered to unordered container conversion.
|
||||||
|
* include/profile/ordered_base.h (std::__profile::_Ordered_profile<>):
|
||||||
|
New.
|
||||||
|
* include/Makefile.am: Add latter.
|
||||||
|
* include/Makefile.in: Regenerate.
|
||||||
|
* include/profile/map.h (std::__profile::map<>): Inherit from latter,
|
||||||
|
remove not instrumented code.
|
||||||
|
* include/profile/multimap.h (std::__profile::multimap<>): Likewise.
|
||||||
|
* include/profile/set.h (std::__profile::set<>): Likewise.
|
||||||
|
* include/profile/multiset.h (std::__profile::multiset<>): Likewise.
|
||||||
|
* include/profile/unordered_base.h: Add some line feed.
|
||||||
|
* include/profile/unordered_map: Clean useless white chars and replace
|
||||||
|
spaces with tabs.
|
||||||
|
* include/profile/unordered_set: Likewise.
|
||||||
|
* include/profile/vector (std::__profile::_Vector_profile_pre<>): New.
|
||||||
|
(std::__profile::_Vector_profile_post<>): New.
|
||||||
|
(std::__profile::vector<>): Inherit from latter and adapt.
|
||||||
|
|
||||||
2014-05-23 Jonathan Wakely <jwakely@redhat.com>
|
2014-05-23 Jonathan Wakely <jwakely@redhat.com>
|
||||||
|
|
||||||
PR libstdc++/60793
|
PR libstdc++/60793
|
||||||
|
|
|
||||||
|
|
@ -816,6 +816,7 @@ profile_headers = \
|
||||||
${profile_srcdir}/map.h \
|
${profile_srcdir}/map.h \
|
||||||
${profile_srcdir}/multimap.h \
|
${profile_srcdir}/multimap.h \
|
||||||
${profile_srcdir}/multiset.h \
|
${profile_srcdir}/multiset.h \
|
||||||
|
${profile_srcdir}/ordered_base.h \
|
||||||
${profile_srcdir}/set \
|
${profile_srcdir}/set \
|
||||||
${profile_srcdir}/set.h \
|
${profile_srcdir}/set.h \
|
||||||
${profile_srcdir}/iterator_tracker.h
|
${profile_srcdir}/iterator_tracker.h
|
||||||
|
|
|
||||||
|
|
@ -1079,6 +1079,7 @@ profile_headers = \
|
||||||
${profile_srcdir}/map.h \
|
${profile_srcdir}/map.h \
|
||||||
${profile_srcdir}/multimap.h \
|
${profile_srcdir}/multimap.h \
|
||||||
${profile_srcdir}/multiset.h \
|
${profile_srcdir}/multiset.h \
|
||||||
|
${profile_srcdir}/ordered_base.h \
|
||||||
${profile_srcdir}/set \
|
${profile_srcdir}/set \
|
||||||
${profile_srcdir}/set.h \
|
${profile_srcdir}/set.h \
|
||||||
${profile_srcdir}/iterator_tracker.h
|
${profile_srcdir}/iterator_tracker.h
|
||||||
|
|
|
||||||
|
|
@ -83,19 +83,19 @@ namespace __profile
|
||||||
end() const noexcept
|
end() const noexcept
|
||||||
{ return const_iterator(data() + _Nm); }
|
{ return const_iterator(data() + _Nm); }
|
||||||
|
|
||||||
reverse_iterator
|
reverse_iterator
|
||||||
rbegin() noexcept
|
rbegin() noexcept
|
||||||
{ return reverse_iterator(end()); }
|
{ return reverse_iterator(end()); }
|
||||||
|
|
||||||
const_reverse_iterator
|
const_reverse_iterator
|
||||||
rbegin() const noexcept
|
rbegin() const noexcept
|
||||||
{ return const_reverse_iterator(end()); }
|
{ return const_reverse_iterator(end()); }
|
||||||
|
|
||||||
reverse_iterator
|
reverse_iterator
|
||||||
rend() noexcept
|
rend() noexcept
|
||||||
{ return reverse_iterator(begin()); }
|
{ return reverse_iterator(begin()); }
|
||||||
|
|
||||||
const_reverse_iterator
|
const_reverse_iterator
|
||||||
rend() const noexcept
|
rend() const noexcept
|
||||||
{ return const_reverse_iterator(begin()); }
|
{ return const_reverse_iterator(begin()); }
|
||||||
|
|
||||||
|
|
@ -107,22 +107,22 @@ namespace __profile
|
||||||
cend() const noexcept
|
cend() const noexcept
|
||||||
{ return const_iterator(data() + _Nm); }
|
{ return const_iterator(data() + _Nm); }
|
||||||
|
|
||||||
const_reverse_iterator
|
const_reverse_iterator
|
||||||
crbegin() const noexcept
|
crbegin() const noexcept
|
||||||
{ return const_reverse_iterator(end()); }
|
{ return const_reverse_iterator(end()); }
|
||||||
|
|
||||||
const_reverse_iterator
|
const_reverse_iterator
|
||||||
crend() const noexcept
|
crend() const noexcept
|
||||||
{ return const_reverse_iterator(begin()); }
|
{ return const_reverse_iterator(begin()); }
|
||||||
|
|
||||||
// Capacity.
|
// Capacity.
|
||||||
constexpr size_type
|
constexpr size_type
|
||||||
size() const noexcept { return _Nm; }
|
size() const noexcept { return _Nm; }
|
||||||
|
|
||||||
constexpr size_type
|
constexpr size_type
|
||||||
max_size() const noexcept { return _Nm; }
|
max_size() const noexcept { return _Nm; }
|
||||||
|
|
||||||
constexpr bool
|
constexpr bool
|
||||||
empty() const noexcept { return size() == 0; }
|
empty() const noexcept { return size() == 0; }
|
||||||
|
|
||||||
// Element access.
|
// Element access.
|
||||||
|
|
@ -157,23 +157,23 @@ namespace __profile
|
||||||
_AT_Type::_S_ref(_M_elems, 0));
|
_AT_Type::_S_ref(_M_elems, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
reference
|
reference
|
||||||
front() noexcept
|
front() noexcept
|
||||||
{ return *begin(); }
|
{ return *begin(); }
|
||||||
|
|
||||||
constexpr const_reference
|
constexpr const_reference
|
||||||
front() const noexcept
|
front() const noexcept
|
||||||
{ return _AT_Type::_S_ref(_M_elems, 0); }
|
{ return _AT_Type::_S_ref(_M_elems, 0); }
|
||||||
|
|
||||||
reference
|
reference
|
||||||
back() noexcept
|
back() noexcept
|
||||||
{ return _Nm ? *(end() - 1) : *end(); }
|
{ return _Nm ? *(end() - 1) : *end(); }
|
||||||
|
|
||||||
constexpr const_reference
|
constexpr const_reference
|
||||||
back() const noexcept
|
back() const noexcept
|
||||||
{
|
{
|
||||||
return _Nm ? _AT_Type::_S_ref(_M_elems, _Nm - 1)
|
return _Nm ? _AT_Type::_S_ref(_M_elems, _Nm - 1)
|
||||||
: _AT_Type::_S_ref(_M_elems, 0);
|
: _AT_Type::_S_ref(_M_elems, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pointer
|
pointer
|
||||||
|
|
@ -187,7 +187,7 @@ namespace __profile
|
||||||
|
|
||||||
// Array comparisons.
|
// Array comparisons.
|
||||||
template<typename _Tp, std::size_t _Nm>
|
template<typename _Tp, std::size_t _Nm>
|
||||||
inline bool
|
inline bool
|
||||||
operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
|
operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
|
||||||
{ return std::equal(__one.begin(), __one.end(), __two.begin()); }
|
{ return std::equal(__one.begin(), __one.end(), __two.begin()); }
|
||||||
|
|
||||||
|
|
@ -199,9 +199,9 @@ namespace __profile
|
||||||
template<typename _Tp, std::size_t _Nm>
|
template<typename _Tp, std::size_t _Nm>
|
||||||
inline bool
|
inline bool
|
||||||
operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
|
operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
|
||||||
{
|
{
|
||||||
return std::lexicographical_compare(__a.begin(), __a.end(),
|
return std::lexicographical_compare(__a.begin(), __a.end(),
|
||||||
__b.begin(), __b.end());
|
__b.begin(), __b.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Tp, std::size_t _Nm>
|
template<typename _Tp, std::size_t _Nm>
|
||||||
|
|
|
||||||
|
|
@ -40,9 +40,9 @@
|
||||||
* @namespace std::__profile
|
* @namespace std::__profile
|
||||||
* @brief GNU profile code, replaces standard behavior with profile behavior.
|
* @brief GNU profile code, replaces standard behavior with profile behavior.
|
||||||
*/
|
*/
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
{
|
{
|
||||||
namespace __profile { }
|
namespace __profile { }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,8 @@ namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
{
|
{
|
||||||
namespace __profile
|
namespace __profile
|
||||||
{
|
{
|
||||||
/// Class std::bitset wrapper with performance instrumentation.
|
/// Class std::bitset wrapper with performance instrumentation, none at the
|
||||||
|
/// moment.
|
||||||
template<size_t _Nb>
|
template<size_t _Nb>
|
||||||
class bitset
|
class bitset
|
||||||
: public _GLIBCXX_STD_C::bitset<_Nb>
|
: public _GLIBCXX_STD_C::bitset<_Nb>
|
||||||
|
|
@ -43,60 +44,13 @@ namespace __profile
|
||||||
typedef _GLIBCXX_STD_C::bitset<_Nb> _Base;
|
typedef _GLIBCXX_STD_C::bitset<_Nb> _Base;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// bit reference:
|
|
||||||
class reference
|
|
||||||
: private _Base::reference
|
|
||||||
{
|
|
||||||
typedef typename _Base::reference _Base_ref;
|
|
||||||
|
|
||||||
friend class bitset;
|
|
||||||
reference();
|
|
||||||
|
|
||||||
reference(const _Base_ref& __base, bitset* __seq) _GLIBCXX_NOEXCEPT
|
|
||||||
: _Base_ref(__base)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public:
|
|
||||||
reference(const reference& __x) _GLIBCXX_NOEXCEPT
|
|
||||||
: _Base_ref(__x)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
reference&
|
|
||||||
operator=(bool __x) _GLIBCXX_NOEXCEPT
|
|
||||||
{
|
|
||||||
*static_cast<_Base_ref*>(this) = __x;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
reference&
|
|
||||||
operator=(const reference& __x) _GLIBCXX_NOEXCEPT
|
|
||||||
{
|
|
||||||
*static_cast<_Base_ref*>(this) = __x;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
operator~() const _GLIBCXX_NOEXCEPT
|
|
||||||
{
|
|
||||||
return ~(*static_cast<const _Base_ref*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
operator bool() const _GLIBCXX_NOEXCEPT
|
|
||||||
{
|
|
||||||
return *static_cast<const _Base_ref*>(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
reference&
|
|
||||||
flip() _GLIBCXX_NOEXCEPT
|
|
||||||
{
|
|
||||||
_Base_ref::flip();
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 23.3.5.1 constructors:
|
// 23.3.5.1 constructors:
|
||||||
_GLIBCXX_CONSTEXPR bitset() _GLIBCXX_NOEXCEPT
|
#if __cplusplus < 201103L
|
||||||
|
bitset()
|
||||||
: _Base() { }
|
: _Base() { }
|
||||||
|
#else
|
||||||
|
constexpr bitset() = default;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
constexpr bitset(unsigned long long __val) noexcept
|
constexpr bitset(unsigned long long __val) noexcept
|
||||||
|
|
@ -106,8 +60,8 @@ namespace __profile
|
||||||
: _Base(__val) { }
|
: _Base(__val) { }
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits, typename _Alloc>
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
||||||
explicit
|
explicit
|
||||||
bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __str,
|
bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __str,
|
||||||
typename std::basic_string<_CharT, _Traits, _Alloc>::size_type
|
typename std::basic_string<_CharT, _Traits, _Alloc>::size_type
|
||||||
__pos = 0,
|
__pos = 0,
|
||||||
typename std::basic_string<_CharT, _Traits, _Alloc>::size_type
|
typename std::basic_string<_CharT, _Traits, _Alloc>::size_type
|
||||||
|
|
@ -129,8 +83,8 @@ namespace __profile
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
template<typename _CharT>
|
template<typename _CharT>
|
||||||
explicit
|
explicit
|
||||||
bitset(const _CharT* __str,
|
bitset(const _CharT* __str,
|
||||||
typename std::basic_string<_CharT>::size_type __n
|
typename std::basic_string<_CharT>::size_type __n
|
||||||
= std::basic_string<_CharT>::npos,
|
= std::basic_string<_CharT>::npos,
|
||||||
_CharT __zero = _CharT('0'), _CharT __one = _CharT('1'))
|
_CharT __zero = _CharT('0'), _CharT __one = _CharT('1'))
|
||||||
|
|
@ -221,92 +175,6 @@ namespace __profile
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// element access:
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 11. Bitset minor problems
|
|
||||||
reference
|
|
||||||
operator[](size_t __pos)
|
|
||||||
{
|
|
||||||
return reference(_M_base()[__pos], this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 11. Bitset minor problems
|
|
||||||
_GLIBCXX_CONSTEXPR bool
|
|
||||||
operator[](size_t __pos) const
|
|
||||||
{
|
|
||||||
return _Base::operator[](__pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
using _Base::to_ulong;
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
using _Base::to_ullong;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template <typename _CharT, typename _Traits, typename _Alloc>
|
|
||||||
std::basic_string<_CharT, _Traits, _Alloc>
|
|
||||||
to_string() const
|
|
||||||
{ return _M_base().template to_string<_CharT, _Traits, _Alloc>(); }
|
|
||||||
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 396. what are characters zero and one.
|
|
||||||
template<class _CharT, class _Traits, class _Alloc>
|
|
||||||
std::basic_string<_CharT, _Traits, _Alloc>
|
|
||||||
to_string(_CharT __zero, _CharT __one = _CharT('1')) const
|
|
||||||
{
|
|
||||||
return _M_base().template
|
|
||||||
to_string<_CharT, _Traits, _Alloc>(__zero, __one);
|
|
||||||
}
|
|
||||||
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 434. bitset::to_string() hard to use.
|
|
||||||
template<typename _CharT, typename _Traits>
|
|
||||||
std::basic_string<_CharT, _Traits, std::allocator<_CharT> >
|
|
||||||
to_string() const
|
|
||||||
{ return to_string<_CharT, _Traits, std::allocator<_CharT> >(); }
|
|
||||||
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 853. to_string needs updating with zero and one.
|
|
||||||
template<class _CharT, class _Traits>
|
|
||||||
std::basic_string<_CharT, _Traits, std::allocator<_CharT> >
|
|
||||||
to_string(_CharT __zero, _CharT __one = _CharT('1')) const
|
|
||||||
{ return to_string<_CharT, _Traits,
|
|
||||||
std::allocator<_CharT> >(__zero, __one); }
|
|
||||||
|
|
||||||
template<typename _CharT>
|
|
||||||
std::basic_string<_CharT, std::char_traits<_CharT>,
|
|
||||||
std::allocator<_CharT> >
|
|
||||||
to_string() const
|
|
||||||
{
|
|
||||||
return to_string<_CharT, std::char_traits<_CharT>,
|
|
||||||
std::allocator<_CharT> >();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class _CharT>
|
|
||||||
std::basic_string<_CharT, std::char_traits<_CharT>,
|
|
||||||
std::allocator<_CharT> >
|
|
||||||
to_string(_CharT __zero, _CharT __one = _CharT('1')) const
|
|
||||||
{
|
|
||||||
return to_string<_CharT, std::char_traits<_CharT>,
|
|
||||||
std::allocator<_CharT> >(__zero, __one);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
|
|
||||||
to_string() const
|
|
||||||
{
|
|
||||||
return to_string<char,std::char_traits<char>,std::allocator<char> >();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
|
|
||||||
to_string(char __zero, char __one = '1') const
|
|
||||||
{
|
|
||||||
return to_string<char, std::char_traits<char>,
|
|
||||||
std::allocator<char> >(__zero, __one);
|
|
||||||
}
|
|
||||||
|
|
||||||
using _Base::count;
|
|
||||||
using _Base::size;
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
operator==(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT
|
operator==(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT
|
||||||
{ return _M_base() == __rhs; }
|
{ return _M_base() == __rhs; }
|
||||||
|
|
@ -315,11 +183,6 @@ namespace __profile
|
||||||
operator!=(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT
|
operator!=(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT
|
||||||
{ return _M_base() != __rhs; }
|
{ return _M_base() != __rhs; }
|
||||||
|
|
||||||
using _Base::test;
|
|
||||||
using _Base::all;
|
|
||||||
using _Base::any;
|
|
||||||
using _Base::none;
|
|
||||||
|
|
||||||
bitset<_Nb>
|
bitset<_Nb>
|
||||||
operator<<(size_t __pos) const _GLIBCXX_NOEXCEPT
|
operator<<(size_t __pos) const _GLIBCXX_NOEXCEPT
|
||||||
{ return bitset<_Nb>(_M_base() << __pos); }
|
{ return bitset<_Nb>(_M_base() << __pos); }
|
||||||
|
|
|
||||||
|
|
@ -43,26 +43,29 @@ namespace __profile
|
||||||
typedef _GLIBCXX_STD_C::deque<_Tp, _Allocator> _Base;
|
typedef _GLIBCXX_STD_C::deque<_Tp, _Allocator> _Base;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename _Base::reference reference;
|
typedef typename _Base::size_type size_type;
|
||||||
typedef typename _Base::const_reference const_reference;
|
typedef typename _Base::value_type value_type;
|
||||||
|
|
||||||
typedef typename _Base::iterator iterator;
|
|
||||||
typedef typename _Base::const_iterator const_iterator;
|
|
||||||
typedef typename _Base::reverse_iterator reverse_iterator;
|
|
||||||
typedef typename _Base::const_reverse_iterator const_reverse_iterator;
|
|
||||||
|
|
||||||
typedef typename _Base::size_type size_type;
|
|
||||||
typedef typename _Base::difference_type difference_type;
|
|
||||||
|
|
||||||
typedef _Tp value_type;
|
|
||||||
typedef _Allocator allocator_type;
|
|
||||||
typedef typename _Base::pointer pointer;
|
|
||||||
typedef typename _Base::const_pointer const_pointer;
|
|
||||||
|
|
||||||
// 23.2.1.1 construct/copy/destroy:
|
// 23.2.1.1 construct/copy/destroy:
|
||||||
|
|
||||||
|
#if __cplusplus < 201103L
|
||||||
deque()
|
deque()
|
||||||
: _Base() { }
|
: _Base() { }
|
||||||
|
deque(const deque& __x)
|
||||||
|
: _Base(__x) { }
|
||||||
|
|
||||||
|
~deque() { }
|
||||||
|
#else
|
||||||
|
deque() = default;
|
||||||
|
deque(const deque&) = default;
|
||||||
|
deque(deque&&) = default;
|
||||||
|
|
||||||
|
~deque() = default;
|
||||||
|
|
||||||
|
deque(initializer_list<value_type> __l,
|
||||||
|
const _Allocator& __a = _Allocator())
|
||||||
|
: _Base(__l, __a) { }
|
||||||
|
#endif
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
deque(const _Allocator& __a)
|
deque(const _Allocator& __a)
|
||||||
|
|
@ -89,346 +92,48 @@ namespace __profile
|
||||||
#else
|
#else
|
||||||
template<typename _InputIterator>
|
template<typename _InputIterator>
|
||||||
#endif
|
#endif
|
||||||
deque(_InputIterator __first, _InputIterator __last,
|
deque(_InputIterator __first, _InputIterator __last,
|
||||||
const _Allocator& __a = _Allocator())
|
const _Allocator& __a = _Allocator())
|
||||||
: _Base(__first, __last, __a)
|
: _Base(__first, __last, __a)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
deque(const deque& __x)
|
|
||||||
: _Base(__x) { }
|
|
||||||
|
|
||||||
deque(const _Base& __x)
|
deque(const _Base& __x)
|
||||||
: _Base(__x) { }
|
: _Base(__x) { }
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus < 201103L
|
||||||
deque(deque&& __x)
|
|
||||||
: _Base(std::move(__x))
|
|
||||||
{ }
|
|
||||||
|
|
||||||
deque(initializer_list<value_type> __l,
|
|
||||||
const allocator_type& __a = allocator_type())
|
|
||||||
: _Base(__l, __a) { }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
~deque() _GLIBCXX_NOEXCEPT { }
|
|
||||||
|
|
||||||
deque&
|
deque&
|
||||||
operator=(const deque& __x)
|
operator=(const deque& __x)
|
||||||
{
|
{
|
||||||
*static_cast<_Base*>(this) = __x;
|
_M_base() = __x;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
deque&
|
deque&
|
||||||
operator=(deque&& __x) noexcept
|
operator=(const deque&) = default;
|
||||||
{
|
|
||||||
// NB: DR 1204.
|
deque&
|
||||||
// NB: DR 675.
|
operator=(deque&&) = default;
|
||||||
this->clear();
|
|
||||||
this->swap(__x);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
deque&
|
deque&
|
||||||
operator=(initializer_list<value_type> __l)
|
operator=(initializer_list<value_type> __l)
|
||||||
{
|
{
|
||||||
*static_cast<_Base*>(this) = __l;
|
_M_base() = __l;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void
|
||||||
|
swap(deque& __x)
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
template<typename _InputIterator,
|
noexcept( noexcept(declval<_Base>().swap(__x)) )
|
||||||
typename = std::_RequireInputIter<_InputIterator>>
|
|
||||||
#else
|
|
||||||
template<typename _InputIterator>
|
|
||||||
#endif
|
#endif
|
||||||
void
|
{ _Base::swap(__x); }
|
||||||
assign(_InputIterator __first, _InputIterator __last)
|
|
||||||
{
|
|
||||||
_Base::assign(__first, __last);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
assign(size_type __n, const _Tp& __t)
|
|
||||||
{
|
|
||||||
_Base::assign(__n, __t);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
void
|
|
||||||
assign(initializer_list<value_type> __l)
|
|
||||||
{
|
|
||||||
_Base::assign(__l);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using _Base::get_allocator;
|
|
||||||
|
|
||||||
// iterators:
|
|
||||||
iterator
|
|
||||||
begin() _GLIBCXX_NOEXCEPT
|
|
||||||
{ return iterator(_Base::begin()); }
|
|
||||||
|
|
||||||
const_iterator
|
|
||||||
begin() const _GLIBCXX_NOEXCEPT
|
|
||||||
{ return const_iterator(_Base::begin()); }
|
|
||||||
|
|
||||||
iterator
|
|
||||||
end() _GLIBCXX_NOEXCEPT
|
|
||||||
{ return iterator(_Base::end()); }
|
|
||||||
|
|
||||||
const_iterator
|
|
||||||
end() const _GLIBCXX_NOEXCEPT
|
|
||||||
{ return const_iterator(_Base::end()); }
|
|
||||||
|
|
||||||
reverse_iterator
|
|
||||||
rbegin() _GLIBCXX_NOEXCEPT
|
|
||||||
{ return reverse_iterator(end()); }
|
|
||||||
|
|
||||||
const_reverse_iterator
|
|
||||||
rbegin() const _GLIBCXX_NOEXCEPT
|
|
||||||
{ return const_reverse_iterator(end()); }
|
|
||||||
|
|
||||||
reverse_iterator
|
|
||||||
rend() _GLIBCXX_NOEXCEPT
|
|
||||||
{ return reverse_iterator(begin()); }
|
|
||||||
|
|
||||||
const_reverse_iterator
|
|
||||||
rend() const _GLIBCXX_NOEXCEPT
|
|
||||||
{ return const_reverse_iterator(begin()); }
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
const_iterator
|
|
||||||
cbegin() const noexcept
|
|
||||||
{ return const_iterator(_Base::begin()); }
|
|
||||||
|
|
||||||
const_iterator
|
|
||||||
cend() const noexcept
|
|
||||||
{ return const_iterator(_Base::end()); }
|
|
||||||
|
|
||||||
const_reverse_iterator
|
|
||||||
crbegin() const noexcept
|
|
||||||
{ return const_reverse_iterator(end()); }
|
|
||||||
|
|
||||||
const_reverse_iterator
|
|
||||||
crend() const noexcept
|
|
||||||
{ return const_reverse_iterator(begin()); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 23.2.1.2 capacity:
|
|
||||||
using _Base::size;
|
|
||||||
using _Base::max_size;
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
void
|
|
||||||
resize(size_type __sz)
|
|
||||||
{
|
|
||||||
_Base::resize(__sz);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
resize(size_type __sz, const _Tp& __c)
|
|
||||||
{
|
|
||||||
_Base::resize(__sz, __c);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
void
|
|
||||||
resize(size_type __sz, _Tp __c = _Tp())
|
|
||||||
{
|
|
||||||
_Base::resize(__sz, __c);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
using _Base::shrink_to_fit;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using _Base::empty;
|
|
||||||
|
|
||||||
// element access:
|
|
||||||
reference
|
|
||||||
operator[](size_type __n) _GLIBCXX_NOEXCEPT
|
|
||||||
{
|
|
||||||
return _M_base()[__n];
|
|
||||||
}
|
|
||||||
|
|
||||||
const_reference
|
|
||||||
operator[](size_type __n) const _GLIBCXX_NOEXCEPT
|
|
||||||
{
|
|
||||||
return _M_base()[__n];
|
|
||||||
}
|
|
||||||
|
|
||||||
using _Base::at;
|
|
||||||
|
|
||||||
reference
|
|
||||||
front() _GLIBCXX_NOEXCEPT
|
|
||||||
{
|
|
||||||
return _Base::front();
|
|
||||||
}
|
|
||||||
|
|
||||||
const_reference
|
|
||||||
front() const _GLIBCXX_NOEXCEPT
|
|
||||||
{
|
|
||||||
return _Base::front();
|
|
||||||
}
|
|
||||||
|
|
||||||
reference
|
|
||||||
back() _GLIBCXX_NOEXCEPT
|
|
||||||
{
|
|
||||||
return _Base::back();
|
|
||||||
}
|
|
||||||
|
|
||||||
const_reference
|
|
||||||
back() const _GLIBCXX_NOEXCEPT
|
|
||||||
{
|
|
||||||
return _Base::back();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 23.2.1.3 modifiers:
|
|
||||||
void
|
|
||||||
push_front(const _Tp& __x)
|
|
||||||
{
|
|
||||||
_Base::push_front(__x);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
push_back(const _Tp& __x)
|
|
||||||
{
|
|
||||||
_Base::push_back(__x);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
void
|
|
||||||
push_front(_Tp&& __x)
|
|
||||||
{ emplace_front(std::move(__x)); }
|
|
||||||
|
|
||||||
void
|
|
||||||
push_back(_Tp&& __x)
|
|
||||||
{ emplace_back(std::move(__x)); }
|
|
||||||
|
|
||||||
template<typename... _Args>
|
|
||||||
void
|
|
||||||
emplace_front(_Args&&... __args)
|
|
||||||
{
|
|
||||||
_Base::emplace_front(std::forward<_Args>(__args)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename... _Args>
|
|
||||||
void
|
|
||||||
emplace_back(_Args&&... __args)
|
|
||||||
{
|
|
||||||
_Base::emplace_back(std::forward<_Args>(__args)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename... _Args>
|
|
||||||
iterator
|
|
||||||
emplace(const_iterator __position, _Args&&... __args)
|
|
||||||
{
|
|
||||||
typename _Base::iterator __res = _Base::emplace(__position,
|
|
||||||
std::forward<_Args>(__args)...);
|
|
||||||
return iterator(__res);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
iterator
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
insert(const_iterator __position, const _Tp& __x)
|
|
||||||
#else
|
|
||||||
insert(iterator __position, const _Tp& __x)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
typename _Base::iterator __res = _Base::insert(__position, __x);
|
|
||||||
return iterator(__res);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
iterator
|
|
||||||
insert(const_iterator __position, _Tp&& __x)
|
|
||||||
{ return emplace(__position, std::move(__x)); }
|
|
||||||
|
|
||||||
iterator
|
|
||||||
insert(const_iterator __p, initializer_list<value_type> __l)
|
|
||||||
{ return _Base::insert(__p, __l); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
iterator
|
|
||||||
insert(const_iterator __position, size_type __n, const _Tp& __x)
|
|
||||||
{ return _Base::insert(__position, __n, __x); }
|
|
||||||
#else
|
|
||||||
void
|
|
||||||
insert(iterator __position, size_type __n, const _Tp& __x)
|
|
||||||
{ _Base::insert(__position, __n, __x); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
template<typename _InputIterator,
|
|
||||||
typename = std::_RequireInputIter<_InputIterator>>
|
|
||||||
iterator
|
|
||||||
insert(const_iterator __position,
|
|
||||||
_InputIterator __first, _InputIterator __last)
|
|
||||||
{ return _Base::insert(__position, __first, __last); }
|
|
||||||
#else
|
|
||||||
template<typename _InputIterator>
|
|
||||||
void
|
|
||||||
insert(iterator __position,
|
|
||||||
_InputIterator __first, _InputIterator __last)
|
|
||||||
{ _Base::insert(__position, __first, __last); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
|
||||||
pop_front() _GLIBCXX_NOEXCEPT
|
|
||||||
{
|
|
||||||
_Base::pop_front();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
pop_back() _GLIBCXX_NOEXCEPT
|
|
||||||
{
|
|
||||||
_Base::pop_back();
|
|
||||||
}
|
|
||||||
|
|
||||||
iterator
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
erase(const_iterator __position)
|
|
||||||
#else
|
|
||||||
erase(iterator __position)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
return _Base::erase(__position);
|
|
||||||
}
|
|
||||||
|
|
||||||
iterator
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
erase(const_iterator __first, const_iterator __last)
|
|
||||||
#else
|
|
||||||
erase(iterator __first, iterator __last)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 151. can't currently clear() empty container
|
|
||||||
return _Base::erase(__first, __last);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
swap(deque& __x) _GLIBCXX_NOEXCEPT
|
|
||||||
{
|
|
||||||
_Base::swap(__x);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
clear() _GLIBCXX_NOEXCEPT
|
|
||||||
{
|
|
||||||
_Base::clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
_Base&
|
_Base&
|
||||||
_M_base() _GLIBCXX_NOEXCEPT { return *this; }
|
_M_base() _GLIBCXX_NOEXCEPT { return *this; }
|
||||||
|
|
||||||
const _Base&
|
const _Base&
|
||||||
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
|
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename _Tp, typename _Alloc>
|
template<typename _Tp, typename _Alloc>
|
||||||
|
|
|
||||||
|
|
@ -46,13 +46,9 @@ namespace __profile
|
||||||
{
|
{
|
||||||
typedef _GLIBCXX_STD_C::forward_list<_Tp, _Alloc> _Base;
|
typedef _GLIBCXX_STD_C::forward_list<_Tp, _Alloc> _Base;
|
||||||
|
|
||||||
typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template
|
|
||||||
rebind<_GLIBCXX_STD_C::_Fwd_list_node<_Tp>>::other _Node_alloc_type;
|
|
||||||
|
|
||||||
typedef __gnu_cxx::__alloc_traits<_Node_alloc_type> _Node_alloc_traits;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename _Base::size_type size_type;
|
typedef typename _Base::size_type size_type;
|
||||||
|
typedef typename _Base::const_iterator const_iterator;
|
||||||
|
|
||||||
// 23.2.3.1 construct/copy/destroy:
|
// 23.2.3.1 construct/copy/destroy:
|
||||||
explicit
|
explicit
|
||||||
|
|
@ -73,98 +69,135 @@ namespace __profile
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
forward_list(size_type __n, const _Tp& __value,
|
forward_list(size_type __n, const _Tp& __value,
|
||||||
const _Alloc& __al = _Alloc())
|
const _Alloc& __al = _Alloc())
|
||||||
: _Base(__n, __value, __al)
|
: _Base(__n, __value, __al)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
template<typename _InputIterator,
|
template<typename _InputIterator,
|
||||||
typename = std::_RequireInputIter<_InputIterator>>
|
typename = std::_RequireInputIter<_InputIterator>>
|
||||||
forward_list(_InputIterator __first, _InputIterator __last,
|
forward_list(_InputIterator __first, _InputIterator __last,
|
||||||
const _Alloc& __al = _Alloc())
|
const _Alloc& __al = _Alloc())
|
||||||
: _Base(__first, __last, __al)
|
: _Base(__first, __last, __al)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
forward_list(const forward_list& __list)
|
forward_list(const forward_list&) = default;
|
||||||
: _Base(__list)
|
forward_list(forward_list&&) = default;
|
||||||
{ }
|
|
||||||
|
|
||||||
forward_list(forward_list&& __list) noexcept
|
|
||||||
: _Base(std::move(__list)) { }
|
|
||||||
|
|
||||||
forward_list(std::initializer_list<_Tp> __il,
|
forward_list(std::initializer_list<_Tp> __il,
|
||||||
const _Alloc& __al = _Alloc())
|
const _Alloc& __al = _Alloc())
|
||||||
: _Base(__il, __al)
|
: _Base(__il, __al)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
~forward_list() noexcept
|
~forward_list() = default;
|
||||||
{ }
|
|
||||||
|
|
||||||
forward_list&
|
forward_list&
|
||||||
operator=(const forward_list& __list)
|
operator=(const forward_list&) = default;
|
||||||
{
|
|
||||||
static_cast<_Base&>(*this) = __list;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_list&
|
forward_list&
|
||||||
operator=(forward_list&& __list)
|
operator=(forward_list&&) = default;
|
||||||
noexcept(_Node_alloc_traits::_S_nothrow_move())
|
|
||||||
{
|
|
||||||
static_cast<_Base&>(*this) = std::move(__list);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_list&
|
forward_list&
|
||||||
operator=(std::initializer_list<_Tp> __il)
|
operator=(std::initializer_list<_Tp> __il)
|
||||||
{
|
{
|
||||||
static_cast<_Base&>(*this) = __il;
|
_M_base() = __il;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
swap(forward_list& __fl)
|
||||||
|
noexcept( noexcept(declval<_Base>().swap(__fl)) )
|
||||||
|
{ _Base::swap(__fl); }
|
||||||
|
|
||||||
|
void
|
||||||
|
splice_after(const_iterator __pos, forward_list&& __fl)
|
||||||
|
{ _Base::splice_after(__pos, std::move(__fl)); }
|
||||||
|
|
||||||
|
void
|
||||||
|
splice_after(const_iterator __pos, forward_list& __list)
|
||||||
|
{ _Base::splice_after(__pos, __list); }
|
||||||
|
|
||||||
|
void
|
||||||
|
splice_after(const_iterator __pos, forward_list&& __list,
|
||||||
|
const_iterator __i)
|
||||||
|
{ _Base::splice_after(__pos, std::move(__list), __i); }
|
||||||
|
|
||||||
|
void
|
||||||
|
splice_after(const_iterator __pos, forward_list& __list,
|
||||||
|
const_iterator __i)
|
||||||
|
{ _Base::splice_after(__pos, __list, __i); }
|
||||||
|
|
||||||
|
void
|
||||||
|
splice_after(const_iterator __pos, forward_list&& __list,
|
||||||
|
const_iterator __before, const_iterator __last)
|
||||||
|
{ _Base::splice_after(__pos, std::move(__list), __before, __last); }
|
||||||
|
|
||||||
|
void
|
||||||
|
splice_after(const_iterator __pos, forward_list& __list,
|
||||||
|
const_iterator __before, const_iterator __last)
|
||||||
|
{ _Base::splice_after(__pos, __list, __before, __last); }
|
||||||
|
|
||||||
|
void
|
||||||
|
merge(forward_list&& __list)
|
||||||
|
{ _Base::merge(std::move(__list)); }
|
||||||
|
|
||||||
|
void
|
||||||
|
merge(forward_list& __list)
|
||||||
|
{ _Base::merge(__list); }
|
||||||
|
|
||||||
|
template<typename _Comp>
|
||||||
|
void
|
||||||
|
merge(forward_list&& __list, _Comp __comp)
|
||||||
|
{ _Base::merge(std::move(__list), __comp); }
|
||||||
|
|
||||||
|
template<typename _Comp>
|
||||||
|
void
|
||||||
|
merge(forward_list& __list, _Comp __comp)
|
||||||
|
{ _Base::merge(__list, __comp); }
|
||||||
|
|
||||||
_Base&
|
_Base&
|
||||||
_M_base() noexcept { return *this; }
|
_M_base() noexcept { return *this; }
|
||||||
|
|
||||||
const _Base&
|
const _Base&
|
||||||
_M_base() const noexcept { return *this; }
|
_M_base() const noexcept { return *this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename _Tp, typename _Alloc>
|
template<typename _Tp, typename _Alloc>
|
||||||
inline bool
|
inline bool
|
||||||
operator==(const forward_list<_Tp, _Alloc>& __lx,
|
operator==(const forward_list<_Tp, _Alloc>& __lx,
|
||||||
const forward_list<_Tp, _Alloc>& __ly)
|
const forward_list<_Tp, _Alloc>& __ly)
|
||||||
{ return __lx._M_base() == __ly._M_base(); }
|
{ return __lx._M_base() == __ly._M_base(); }
|
||||||
|
|
||||||
template<typename _Tp, typename _Alloc>
|
template<typename _Tp, typename _Alloc>
|
||||||
inline bool
|
inline bool
|
||||||
operator<(const forward_list<_Tp, _Alloc>& __lx,
|
operator<(const forward_list<_Tp, _Alloc>& __lx,
|
||||||
const forward_list<_Tp, _Alloc>& __ly)
|
const forward_list<_Tp, _Alloc>& __ly)
|
||||||
{ return __lx._M_base() < __ly._M_base(); }
|
{ return __lx._M_base() < __ly._M_base(); }
|
||||||
|
|
||||||
template<typename _Tp, typename _Alloc>
|
template<typename _Tp, typename _Alloc>
|
||||||
inline bool
|
inline bool
|
||||||
operator!=(const forward_list<_Tp, _Alloc>& __lx,
|
operator!=(const forward_list<_Tp, _Alloc>& __lx,
|
||||||
const forward_list<_Tp, _Alloc>& __ly)
|
const forward_list<_Tp, _Alloc>& __ly)
|
||||||
{ return !(__lx == __ly); }
|
{ return !(__lx == __ly); }
|
||||||
|
|
||||||
/// Based on operator<
|
/// Based on operator<
|
||||||
template<typename _Tp, typename _Alloc>
|
template<typename _Tp, typename _Alloc>
|
||||||
inline bool
|
inline bool
|
||||||
operator>(const forward_list<_Tp, _Alloc>& __lx,
|
operator>(const forward_list<_Tp, _Alloc>& __lx,
|
||||||
const forward_list<_Tp, _Alloc>& __ly)
|
const forward_list<_Tp, _Alloc>& __ly)
|
||||||
{ return (__ly < __lx); }
|
{ return (__ly < __lx); }
|
||||||
|
|
||||||
/// Based on operator<
|
/// Based on operator<
|
||||||
template<typename _Tp, typename _Alloc>
|
template<typename _Tp, typename _Alloc>
|
||||||
inline bool
|
inline bool
|
||||||
operator>=(const forward_list<_Tp, _Alloc>& __lx,
|
operator>=(const forward_list<_Tp, _Alloc>& __lx,
|
||||||
const forward_list<_Tp, _Alloc>& __ly)
|
const forward_list<_Tp, _Alloc>& __ly)
|
||||||
{ return !(__lx < __ly); }
|
{ return !(__lx < __ly); }
|
||||||
|
|
||||||
/// Based on operator<
|
/// Based on operator<
|
||||||
template<typename _Tp, typename _Alloc>
|
template<typename _Tp, typename _Alloc>
|
||||||
inline bool
|
inline bool
|
||||||
operator<=(const forward_list<_Tp, _Alloc>& __lx,
|
operator<=(const forward_list<_Tp, _Alloc>& __lx,
|
||||||
const forward_list<_Tp, _Alloc>& __ly)
|
const forward_list<_Tp, _Alloc>& __ly)
|
||||||
{ return !(__ly < __lx); }
|
{ return !(__ly < __lx); }
|
||||||
|
|
||||||
/// See std::forward_list::swap().
|
/// See std::forward_list::swap().
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ namespace __gnu_profile
|
||||||
__log2(std::size_t __size)
|
__log2(std::size_t __size)
|
||||||
{
|
{
|
||||||
for (int __bit_count = sizeof(std::size_t) - 1; __bit_count >= 0;
|
for (int __bit_count = sizeof(std::size_t) - 1; __bit_count >= 0;
|
||||||
-- __bit_count)
|
-- __bit_count)
|
||||||
if ((2 << __bit_count) & __size)
|
if ((2 << __bit_count) & __size)
|
||||||
return __bit_count;
|
return __bit_count;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -48,7 +48,7 @@ namespace __gnu_profile
|
||||||
|
|
||||||
inline float
|
inline float
|
||||||
__map_insert_cost(std::size_t __size)
|
__map_insert_cost(std::size_t __size)
|
||||||
{ return (_GLIBCXX_PROFILE_DATA(__map_insert_cost_factor).__value
|
{ return (_GLIBCXX_PROFILE_DATA(__map_insert_cost_factor).__value
|
||||||
* static_cast<float>(__log2(__size))); }
|
* static_cast<float>(__log2(__size))); }
|
||||||
|
|
||||||
inline float
|
inline float
|
||||||
|
|
@ -61,7 +61,7 @@ namespace __gnu_profile
|
||||||
{ return (_GLIBCXX_PROFILE_DATA(__map_find_cost_factor).__value
|
{ return (_GLIBCXX_PROFILE_DATA(__map_find_cost_factor).__value
|
||||||
* static_cast<float>(__log2(__size))); }
|
* static_cast<float>(__log2(__size))); }
|
||||||
|
|
||||||
/** @brief A map-to-unordered_map instrumentation line in the
|
/** @brief A map-to-unordered_map instrumentation line in the
|
||||||
object table. */
|
object table. */
|
||||||
class __map2umap_info
|
class __map2umap_info
|
||||||
: public __object_info_base
|
: public __object_info_base
|
||||||
|
|
@ -70,9 +70,9 @@ namespace __gnu_profile
|
||||||
__map2umap_info()
|
__map2umap_info()
|
||||||
: _M_insert(0), _M_erase(0), _M_find(0), _M_iterate(0),
|
: _M_insert(0), _M_erase(0), _M_find(0), _M_iterate(0),
|
||||||
_M_umap_cost(0.0), _M_map_cost(0.0), _M_valid(true) { }
|
_M_umap_cost(0.0), _M_map_cost(0.0), _M_valid(true) { }
|
||||||
|
|
||||||
__map2umap_info(__stack_t __stack)
|
__map2umap_info(__stack_t __stack)
|
||||||
: __object_info_base(__stack), _M_insert(0), _M_erase(0), _M_find(0),
|
: __object_info_base(__stack), _M_insert(0), _M_erase(0), _M_find(0),
|
||||||
_M_iterate(0), _M_umap_cost(0.0), _M_map_cost(0.0), _M_valid(true) { }
|
_M_iterate(0), _M_umap_cost(0.0), _M_map_cost(0.0), _M_valid(true) { }
|
||||||
|
|
||||||
virtual ~__map2umap_info() { }
|
virtual ~__map2umap_info() { }
|
||||||
|
|
@ -108,32 +108,38 @@ namespace __gnu_profile
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
__advice() const
|
__advice() const
|
||||||
{ return "change std::map to std::unordered_map"; }
|
{ return "prefer an unordered container"; }
|
||||||
|
|
||||||
void
|
void
|
||||||
__record_insert(std::size_t __size, std::size_t __count)
|
__record_insert(std::size_t __size, std::size_t __count)
|
||||||
{
|
{
|
||||||
_M_insert += __count;
|
++_M_insert;
|
||||||
_M_map_cost += __count * __map_insert_cost(__size);
|
if (__count)
|
||||||
_M_umap_cost
|
{
|
||||||
+= (__count
|
_M_map_cost += __count * __map_insert_cost(__size);
|
||||||
* _GLIBCXX_PROFILE_DATA(__umap_insert_cost_factor).__value);
|
_M_umap_cost
|
||||||
|
+= (__count
|
||||||
|
* _GLIBCXX_PROFILE_DATA(__umap_insert_cost_factor).__value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
__record_erase(std::size_t __size, std::size_t __count)
|
__record_erase(std::size_t __size, std::size_t __count)
|
||||||
{
|
{
|
||||||
_M_erase += __count;
|
++_M_erase;
|
||||||
_M_map_cost += __count * __map_erase_cost(__size);
|
if (__count)
|
||||||
_M_umap_cost
|
{
|
||||||
+= (__count
|
_M_map_cost += __count * __map_erase_cost(__size);
|
||||||
* _GLIBCXX_PROFILE_DATA(__umap_erase_cost_factor).__value);
|
_M_umap_cost
|
||||||
|
+= (__count
|
||||||
|
* _GLIBCXX_PROFILE_DATA(__umap_erase_cost_factor).__value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
__record_find(std::size_t __size)
|
__record_find(std::size_t __size)
|
||||||
{
|
{
|
||||||
_M_find += 1;
|
++_M_find;
|
||||||
_M_map_cost += __map_find_cost(__size);
|
_M_map_cost += __map_find_cost(__size);
|
||||||
_M_umap_cost += _GLIBCXX_PROFILE_DATA(__umap_find_cost_factor).__value;
|
_M_umap_cost += _GLIBCXX_PROFILE_DATA(__umap_find_cost_factor).__value;
|
||||||
}
|
}
|
||||||
|
|
@ -165,9 +171,9 @@ namespace __gnu_profile
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/** @brief A map-to-unordered_map instrumentation line in the
|
/** @brief A map-to-unordered_map instrumentation line in the
|
||||||
stack table. */
|
stack table. */
|
||||||
class __map2umap_stack_info
|
class __map2umap_stack_info
|
||||||
: public __map2umap_info
|
: public __map2umap_info
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -177,12 +183,12 @@ namespace __gnu_profile
|
||||||
|
|
||||||
/** @brief Map-to-unordered_map instrumentation producer. */
|
/** @brief Map-to-unordered_map instrumentation producer. */
|
||||||
class __trace_map2umap
|
class __trace_map2umap
|
||||||
: public __trace_base<__map2umap_info, __map2umap_stack_info>
|
: public __trace_base<__map2umap_info, __map2umap_stack_info>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
__trace_map2umap()
|
__trace_map2umap()
|
||||||
: __trace_base<__map2umap_info, __map2umap_stack_info>()
|
: __trace_base<__map2umap_info, __map2umap_stack_info>()
|
||||||
{ __id = "map-to-unordered-map"; }
|
{ __id = "ordered-to-unordered"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
|
|
@ -193,7 +199,7 @@ namespace __gnu_profile
|
||||||
__trace_map_to_unordered_map_report(FILE* __f,
|
__trace_map_to_unordered_map_report(FILE* __f,
|
||||||
__warning_vector_t& __warnings)
|
__warning_vector_t& __warnings)
|
||||||
{
|
{
|
||||||
if (_GLIBCXX_PROFILE_DATA(_S_map2umap))
|
if (_GLIBCXX_PROFILE_DATA(_S_map2umap))
|
||||||
{
|
{
|
||||||
_GLIBCXX_PROFILE_DATA(_S_map2umap)->__collect_warnings(__warnings);
|
_GLIBCXX_PROFILE_DATA(_S_map2umap)->__collect_warnings(__warnings);
|
||||||
_GLIBCXX_PROFILE_DATA(_S_map2umap)->__write(__f);
|
_GLIBCXX_PROFILE_DATA(_S_map2umap)->__write(__f);
|
||||||
|
|
@ -220,7 +226,7 @@ namespace __gnu_profile
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
__trace_map_to_unordered_map_insert(const void* __obj,
|
__trace_map_to_unordered_map_insert(const void* __obj,
|
||||||
std::size_t __size, std::size_t __count)
|
std::size_t __size, std::size_t __count)
|
||||||
{
|
{
|
||||||
if (!__profcxx_init())
|
if (!__profcxx_init())
|
||||||
|
|
@ -234,13 +240,13 @@ namespace __gnu_profile
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
__trace_map_to_unordered_map_erase(const void* __obj,
|
__trace_map_to_unordered_map_erase(const void* __obj,
|
||||||
std::size_t __size, std::size_t __count)
|
std::size_t __size, std::size_t __count)
|
||||||
{
|
{
|
||||||
if (!__profcxx_init())
|
if (!__profcxx_init())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
__map2umap_info* __info
|
__map2umap_info* __info
|
||||||
= _GLIBCXX_PROFILE_DATA(_S_map2umap)->__get_object_info(__obj);
|
= _GLIBCXX_PROFILE_DATA(_S_map2umap)->__get_object_info(__obj);
|
||||||
|
|
||||||
if (__info)
|
if (__info)
|
||||||
|
|
@ -268,7 +274,7 @@ namespace __gnu_profile
|
||||||
|
|
||||||
__map2umap_info* __info
|
__map2umap_info* __info
|
||||||
= _GLIBCXX_PROFILE_DATA(_S_map2umap)->__get_object_info(__obj);
|
= _GLIBCXX_PROFILE_DATA(_S_map2umap)->__get_object_info(__obj);
|
||||||
|
|
||||||
if (__info)
|
if (__info)
|
||||||
__info->__record_iterate(__count);
|
__info->__record_iterate(__count);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,8 @@ namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
{
|
{
|
||||||
namespace __profile
|
namespace __profile
|
||||||
{
|
{
|
||||||
|
|
||||||
template<typename _Iterator, typename _Sequence>
|
template<typename _Iterator, typename _Sequence>
|
||||||
class __iterator_tracker
|
class __iterator_tracker
|
||||||
{
|
{
|
||||||
typedef __iterator_tracker _Self;
|
typedef __iterator_tracker _Self;
|
||||||
|
|
||||||
|
|
@ -49,12 +48,12 @@ namespace __profile
|
||||||
typedef std::iterator_traits<_Iterator> _Traits;
|
typedef std::iterator_traits<_Iterator> _Traits;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef _Iterator _Base_iterator;
|
typedef _Iterator _Base_iterator;
|
||||||
typedef typename _Traits::iterator_category iterator_category;
|
typedef typename _Traits::iterator_category iterator_category;
|
||||||
typedef typename _Traits::value_type value_type;
|
typedef typename _Traits::value_type value_type;
|
||||||
typedef typename _Traits::difference_type difference_type;
|
typedef typename _Traits::difference_type difference_type;
|
||||||
typedef typename _Traits::reference reference;
|
typedef typename _Traits::reference reference;
|
||||||
typedef typename _Traits::pointer pointer;
|
typedef typename _Traits::pointer pointer;
|
||||||
|
|
||||||
__iterator_tracker() _GLIBCXX_NOEXCEPT
|
__iterator_tracker() _GLIBCXX_NOEXCEPT
|
||||||
: _M_current(), _M_ds(0) { }
|
: _M_current(), _M_ds(0) { }
|
||||||
|
|
@ -67,7 +66,7 @@ namespace __profile
|
||||||
: _M_current(__x._M_current), _M_ds(__x._M_ds) { }
|
: _M_current(__x._M_current), _M_ds(__x._M_ds) { }
|
||||||
|
|
||||||
template<typename _MutableIterator>
|
template<typename _MutableIterator>
|
||||||
__iterator_tracker(const __iterator_tracker<_MutableIterator,
|
__iterator_tracker(const __iterator_tracker<_MutableIterator,
|
||||||
typename __gnu_cxx::__enable_if
|
typename __gnu_cxx::__enable_if
|
||||||
<(std::__are_same<_MutableIterator, typename
|
<(std::__are_same<_MutableIterator, typename
|
||||||
_Sequence::iterator::_Base_iterator>::__value),
|
_Sequence::iterator::_Base_iterator>::__value),
|
||||||
|
|
@ -76,7 +75,7 @@ namespace __profile
|
||||||
|
|
||||||
_Iterator
|
_Iterator
|
||||||
base() const _GLIBCXX_NOEXCEPT { return _M_current; }
|
base() const _GLIBCXX_NOEXCEPT { return _M_current; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Conversion to underlying non-debug iterator to allow
|
* @brief Conversion to underlying non-debug iterator to allow
|
||||||
* better interaction with non-profile containers.
|
* better interaction with non-profile containers.
|
||||||
|
|
@ -199,7 +198,7 @@ namespace __profile
|
||||||
template<typename _Iterator, typename _Sequence>
|
template<typename _Iterator, typename _Sequence>
|
||||||
inline bool
|
inline bool
|
||||||
operator!=(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
|
operator!=(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
|
||||||
const __iterator_tracker<_Iterator, _Sequence>& __rhs)
|
const __iterator_tracker<_Iterator, _Sequence>& __rhs)
|
||||||
_GLIBCXX_NOEXCEPT
|
_GLIBCXX_NOEXCEPT
|
||||||
{ return __lhs.base() != __rhs.base(); }
|
{ return __lhs.base() != __rhs.base(); }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,81 +30,109 @@
|
||||||
#define _GLIBCXX_PROFILE_LIST 1
|
#define _GLIBCXX_PROFILE_LIST 1
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <profile/base.h>
|
#include <profile/base.h>
|
||||||
#include <profile/iterator_tracker.h>
|
#include <profile/iterator_tracker.h>
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
{
|
{
|
||||||
namespace __profile
|
namespace __profile
|
||||||
{
|
{
|
||||||
/** @brief List wrapper with performance instrumentation. */
|
template<typename _List>
|
||||||
template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
class _List_profile
|
||||||
class list
|
|
||||||
: public _GLIBCXX_STD_C::list<_Tp, _Allocator>
|
|
||||||
{
|
{
|
||||||
typedef _GLIBCXX_STD_C::list<_Tp, _Allocator> _Base;
|
_List&
|
||||||
|
_M_conjure()
|
||||||
|
{ return *static_cast<_List*>(this); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename _Base::reference reference;
|
_List_profile() _GLIBCXX_NOEXCEPT
|
||||||
typedef typename _Base::const_reference const_reference;
|
{
|
||||||
|
__profcxx_list_construct(&_M_conjure()); // list2slist
|
||||||
|
__profcxx_list_construct2(&_M_conjure()); // list2vector
|
||||||
|
}
|
||||||
|
|
||||||
typedef __iterator_tracker<typename _Base::iterator, list>
|
#if __cplusplus >= 201103L
|
||||||
iterator;
|
_List_profile(const _List_profile&) noexcept
|
||||||
typedef __iterator_tracker<typename _Base::const_iterator, list>
|
: _List_profile() { }
|
||||||
const_iterator;
|
_List_profile(_List_profile&&) noexcept
|
||||||
|
: _List_profile() { }
|
||||||
|
|
||||||
typedef typename _Base::size_type size_type;
|
_List_profile&
|
||||||
typedef typename _Base::difference_type difference_type;
|
operator=(const _List_profile&) = default;
|
||||||
|
_List_profile&
|
||||||
|
operator=(_List_profile&&) = default;
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef _Tp value_type;
|
~_List_profile()
|
||||||
typedef _Allocator allocator_type;
|
{
|
||||||
typedef typename _Base::pointer pointer;
|
__profcxx_list_destruct(&_M_conjure());
|
||||||
typedef typename _Base::const_pointer const_pointer;
|
__profcxx_list_destruct2(&_M_conjure());
|
||||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
}
|
||||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
};
|
||||||
|
|
||||||
|
/** @brief List wrapper with performance instrumentation. */
|
||||||
|
template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
||||||
|
class list
|
||||||
|
: public _GLIBCXX_STD_C::list<_Tp, _Allocator>,
|
||||||
|
public _List_profile<list<_Tp, _Allocator> >
|
||||||
|
{
|
||||||
|
typedef _GLIBCXX_STD_C::list<_Tp, _Allocator> _Base;
|
||||||
|
|
||||||
|
public:
|
||||||
|
typedef typename _Base::reference reference;
|
||||||
|
typedef typename _Base::const_reference const_reference;
|
||||||
|
|
||||||
|
typedef __iterator_tracker<typename _Base::iterator, list>
|
||||||
|
iterator;
|
||||||
|
typedef __iterator_tracker<typename _Base::const_iterator, list>
|
||||||
|
const_iterator;
|
||||||
|
|
||||||
|
typedef typename _Base::size_type size_type;
|
||||||
|
typedef typename _Base::difference_type difference_type;
|
||||||
|
|
||||||
|
typedef _Tp value_type;
|
||||||
|
typedef _Allocator allocator_type;
|
||||||
|
typedef typename _Base::pointer pointer;
|
||||||
|
typedef typename _Base::const_pointer const_pointer;
|
||||||
|
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||||
|
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||||
|
|
||||||
// 23.2.2.1 construct/copy/destroy:
|
// 23.2.2.1 construct/copy/destroy:
|
||||||
|
|
||||||
list() _GLIBCXX_NOEXCEPT
|
#if __cplusplus < 201103L
|
||||||
: _Base()
|
list() { }
|
||||||
{
|
list(const list& __x)
|
||||||
__profcxx_list_construct(this); // list2slist
|
: _Base(__x) { }
|
||||||
__profcxx_list_construct2(this); // list2vector
|
|
||||||
}
|
~list() { }
|
||||||
|
#else
|
||||||
|
list() = default;
|
||||||
|
list(const list&) = default;
|
||||||
|
list(list&&) = default;
|
||||||
|
~list() = default;
|
||||||
|
|
||||||
|
list(initializer_list<value_type> __l,
|
||||||
|
const allocator_type& __a = allocator_type())
|
||||||
|
: _Base(__l, __a) { }
|
||||||
|
#endif
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
list(const _Allocator& __a) _GLIBCXX_NOEXCEPT
|
list(const _Allocator& __a) _GLIBCXX_NOEXCEPT
|
||||||
: _Base(__a)
|
: _Base(__a) { }
|
||||||
{
|
|
||||||
__profcxx_list_construct(this); // list2slist
|
|
||||||
__profcxx_list_construct2(this); // list2vector
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
explicit
|
explicit
|
||||||
list(size_type __n)
|
list(size_type __n)
|
||||||
: _Base(__n)
|
: _Base(__n) { }
|
||||||
{
|
|
||||||
__profcxx_list_construct(this);
|
|
||||||
__profcxx_list_construct2(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
list(size_type __n, const _Tp& __value,
|
list(size_type __n, const _Tp& __value,
|
||||||
const _Allocator& __a = _Allocator())
|
const _Allocator& __a = _Allocator())
|
||||||
: _Base(__n, __value, __a)
|
: _Base(__n, __value, __a) { }
|
||||||
{
|
|
||||||
__profcxx_list_construct(this);
|
|
||||||
__profcxx_list_construct2(this);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
explicit
|
explicit
|
||||||
list(size_type __n, const _Tp& __value = _Tp(),
|
list(size_type __n, const _Tp& __value = _Tp(),
|
||||||
const _Allocator& __a = _Allocator())
|
const _Allocator& __a = _Allocator())
|
||||||
: _Base(__n, __value, __a)
|
: _Base(__n, __value, __a) { }
|
||||||
{
|
|
||||||
__profcxx_list_construct(this);
|
|
||||||
__profcxx_list_construct2(this);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
|
|
@ -115,91 +143,33 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
||||||
#endif
|
#endif
|
||||||
list(_InputIterator __first, _InputIterator __last,
|
list(_InputIterator __first, _InputIterator __last,
|
||||||
const _Allocator& __a = _Allocator())
|
const _Allocator& __a = _Allocator())
|
||||||
: _Base(__first, __last, __a)
|
: _Base(__first, __last, __a) { }
|
||||||
{
|
|
||||||
__profcxx_list_construct(this);
|
|
||||||
__profcxx_list_construct2(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
list(const list& __x)
|
|
||||||
: _Base(__x)
|
|
||||||
{
|
|
||||||
__profcxx_list_construct(this);
|
|
||||||
__profcxx_list_construct2(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
list(const _Base& __x)
|
list(const _Base& __x)
|
||||||
: _Base(__x)
|
: _Base(__x) { }
|
||||||
{
|
|
||||||
__profcxx_list_construct(this);
|
|
||||||
__profcxx_list_construct2(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
list(list&& __x) noexcept
|
|
||||||
: _Base(std::move(__x))
|
|
||||||
{
|
|
||||||
__profcxx_list_construct(this);
|
|
||||||
__profcxx_list_construct2(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
list(initializer_list<value_type> __l,
|
|
||||||
const allocator_type& __a = allocator_type())
|
|
||||||
: _Base(__l, __a) { }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
~list() _GLIBCXX_NOEXCEPT
|
|
||||||
{
|
|
||||||
__profcxx_list_destruct(this);
|
|
||||||
__profcxx_list_destruct2(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
#if __cplusplus < 201103L
|
||||||
list&
|
list&
|
||||||
operator=(const list& __x)
|
operator=(const list& __x)
|
||||||
{
|
{
|
||||||
static_cast<_Base&>(*this) = __x;
|
_M_base() = __x;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
list&
|
list&
|
||||||
operator=(list&& __x)
|
operator=(const list&) = default;
|
||||||
{
|
|
||||||
// NB: DR 1204.
|
list&
|
||||||
// NB: DR 675.
|
operator=(list&&) = default;
|
||||||
this->clear();
|
|
||||||
this->swap(__x);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
list&
|
list&
|
||||||
operator=(initializer_list<value_type> __l)
|
operator=(initializer_list<value_type> __l)
|
||||||
{
|
{
|
||||||
static_cast<_Base&>(*this) = __l;
|
_M_base() = __l;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
assign(initializer_list<value_type> __l)
|
|
||||||
{ _Base::assign(__l); }
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
template<typename _InputIterator,
|
|
||||||
typename = std::_RequireInputIter<_InputIterator>>
|
|
||||||
#else
|
|
||||||
template<class _InputIterator>
|
|
||||||
#endif
|
|
||||||
void
|
|
||||||
assign(_InputIterator __first, _InputIterator __last)
|
|
||||||
{ _Base::assign(__first, __last); }
|
|
||||||
|
|
||||||
void
|
|
||||||
assign(size_type __n, const _Tp& __t)
|
|
||||||
{ _Base::assign(__n, __t); }
|
|
||||||
|
|
||||||
using _Base::get_allocator;
|
|
||||||
|
|
||||||
// iterators:
|
// iterators:
|
||||||
iterator
|
iterator
|
||||||
begin() _GLIBCXX_NOEXCEPT
|
begin() _GLIBCXX_NOEXCEPT
|
||||||
|
|
@ -212,29 +182,29 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
||||||
iterator
|
iterator
|
||||||
end() _GLIBCXX_NOEXCEPT
|
end() _GLIBCXX_NOEXCEPT
|
||||||
{
|
{
|
||||||
__profcxx_list_rewind(this);
|
__profcxx_list_rewind(this);
|
||||||
return iterator(_Base::end(), this);
|
return iterator(_Base::end(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator
|
const_iterator
|
||||||
end() const _GLIBCXX_NOEXCEPT
|
end() const _GLIBCXX_NOEXCEPT
|
||||||
{
|
{
|
||||||
__profcxx_list_rewind(this);
|
__profcxx_list_rewind(this);
|
||||||
return const_iterator(_Base::end(), this);
|
return const_iterator(_Base::end(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
reverse_iterator
|
reverse_iterator
|
||||||
rbegin() _GLIBCXX_NOEXCEPT
|
rbegin() _GLIBCXX_NOEXCEPT
|
||||||
{
|
{
|
||||||
__profcxx_list_rewind(this);
|
__profcxx_list_rewind(this);
|
||||||
return reverse_iterator(end());
|
return reverse_iterator(end());
|
||||||
}
|
}
|
||||||
|
|
||||||
const_reverse_iterator
|
const_reverse_iterator
|
||||||
rbegin() const _GLIBCXX_NOEXCEPT
|
rbegin() const _GLIBCXX_NOEXCEPT
|
||||||
{
|
{
|
||||||
__profcxx_list_rewind(this);
|
__profcxx_list_rewind(this);
|
||||||
return const_reverse_iterator(end());
|
return const_reverse_iterator(end());
|
||||||
}
|
}
|
||||||
|
|
||||||
reverse_iterator
|
reverse_iterator
|
||||||
|
|
@ -248,11 +218,11 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
const_iterator
|
const_iterator
|
||||||
cbegin() const noexcept
|
cbegin() const noexcept
|
||||||
{ return const_iterator(_Base::begin(), this); }
|
{ return const_iterator(_Base::cbegin(), this); }
|
||||||
|
|
||||||
const_iterator
|
const_iterator
|
||||||
cend() const noexcept
|
cend() const noexcept
|
||||||
{ return const_iterator(_Base::end(), this); }
|
{ return const_iterator(_Base::cend(), this); }
|
||||||
|
|
||||||
const_reverse_iterator
|
const_reverse_iterator
|
||||||
crbegin() const noexcept
|
crbegin() const noexcept
|
||||||
|
|
@ -264,44 +234,17 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 23.2.2.2 capacity:
|
// 23.2.2.2 capacity:
|
||||||
using _Base::empty;
|
|
||||||
using _Base::size;
|
|
||||||
using _Base::max_size;
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
void
|
|
||||||
resize(size_type __sz)
|
|
||||||
{ _Base::resize(__sz); }
|
|
||||||
|
|
||||||
void
|
|
||||||
resize(size_type __sz, const _Tp& __c)
|
|
||||||
{ _Base::resize(__sz, __c); }
|
|
||||||
#else
|
|
||||||
void
|
|
||||||
resize(size_type __sz, _Tp __c = _Tp())
|
|
||||||
{ _Base::resize(__sz, __c); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// element access:
|
|
||||||
reference
|
|
||||||
front() _GLIBCXX_NOEXCEPT
|
|
||||||
{ return _Base::front(); }
|
|
||||||
|
|
||||||
const_reference
|
|
||||||
front() const _GLIBCXX_NOEXCEPT
|
|
||||||
{ return _Base::front(); }
|
|
||||||
|
|
||||||
reference
|
reference
|
||||||
back() _GLIBCXX_NOEXCEPT
|
back() _GLIBCXX_NOEXCEPT
|
||||||
{
|
{
|
||||||
__profcxx_list_rewind(this);
|
__profcxx_list_rewind(this);
|
||||||
return _Base::back();
|
return _Base::back();
|
||||||
}
|
}
|
||||||
|
|
||||||
const_reference
|
const_reference
|
||||||
back() const _GLIBCXX_NOEXCEPT
|
back() const _GLIBCXX_NOEXCEPT
|
||||||
{
|
{
|
||||||
__profcxx_list_rewind(this);
|
__profcxx_list_rewind(this);
|
||||||
return _Base::back();
|
return _Base::back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -309,44 +252,32 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
||||||
void
|
void
|
||||||
push_front(const value_type& __x)
|
push_front(const value_type& __x)
|
||||||
{
|
{
|
||||||
__profcxx_list_invalid_operator(this);
|
__profcxx_list_invalid_operator(this);
|
||||||
__profcxx_list_operation(this);
|
__profcxx_list_operation(this);
|
||||||
_Base::push_front(__x);
|
_Base::push_front(__x);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
using _Base::emplace_front;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
void
|
||||||
pop_front() _GLIBCXX_NOEXCEPT
|
pop_front() _GLIBCXX_NOEXCEPT
|
||||||
{
|
{
|
||||||
__profcxx_list_operation(this);
|
__profcxx_list_operation(this);
|
||||||
_Base::pop_front();
|
_Base::pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
using _Base::push_back;
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
using _Base::emplace_back;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
void
|
||||||
pop_back() _GLIBCXX_NOEXCEPT
|
pop_back() _GLIBCXX_NOEXCEPT
|
||||||
{
|
{
|
||||||
iterator __victim = end();
|
|
||||||
--__victim;
|
|
||||||
_Base::pop_back();
|
_Base::pop_back();
|
||||||
__profcxx_list_rewind(this);
|
__profcxx_list_rewind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
template<typename... _Args>
|
template<typename... _Args>
|
||||||
iterator
|
iterator
|
||||||
emplace(const_iterator __position, _Args&&... __args)
|
emplace(const_iterator __position, _Args&&... __args)
|
||||||
{
|
{
|
||||||
return iterator(_Base::emplace(__position.base(),
|
return iterator(_Base::emplace(__position.base(),
|
||||||
std::forward<_Args>(__args)...),
|
std::forward<_Args>(__args)...),
|
||||||
this);
|
this);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -358,24 +289,24 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
||||||
insert(iterator __position, const _Tp& __x)
|
insert(iterator __position, const _Tp& __x)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
_M_profile_insert(this, __position, size());
|
_M_profile_insert(this, __position, this->size());
|
||||||
return iterator(_Base::insert(__position.base(), __x), this);
|
return iterator(_Base::insert(__position.base(), __x), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
iterator
|
iterator
|
||||||
insert(const_iterator __position, _Tp&& __x)
|
insert(const_iterator __position, _Tp&& __x)
|
||||||
{
|
{
|
||||||
_M_profile_insert(this, __position, size());
|
_M_profile_insert(this, __position, this->size());
|
||||||
return iterator(_Base::emplace(__position.base(), std::move(__x)),
|
return iterator(_Base::emplace(__position.base(), std::move(__x)),
|
||||||
this);
|
this);
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
insert(const_iterator __position, initializer_list<value_type> __l)
|
insert(const_iterator __position, initializer_list<value_type> __l)
|
||||||
{
|
{
|
||||||
_M_profile_insert(this, __position, size());
|
_M_profile_insert(this, __position, this->size());
|
||||||
return iterator(_Base::insert(__position.base(), __l), this);
|
return iterator(_Base::insert(__position.base(), __l), this);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -383,14 +314,14 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
||||||
iterator
|
iterator
|
||||||
insert(const_iterator __position, size_type __n, const _Tp& __x)
|
insert(const_iterator __position, size_type __n, const _Tp& __x)
|
||||||
{
|
{
|
||||||
_M_profile_insert(this, __position, size());
|
_M_profile_insert(this, __position, this->size());
|
||||||
return iterator(_Base::insert(__position.base(), __n, __x), this);
|
return iterator(_Base::insert(__position.base(), __n, __x), this);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void
|
void
|
||||||
insert(iterator __position, size_type __n, const _Tp& __x)
|
insert(iterator __position, size_type __n, const _Tp& __x)
|
||||||
{
|
{
|
||||||
_M_profile_insert(this, __position, size());
|
_M_profile_insert(this, __position, this->size());
|
||||||
_Base::insert(__position.base(), __n, __x);
|
_Base::insert(__position.base(), __n, __x);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -399,20 +330,20 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
||||||
template<typename _InputIterator,
|
template<typename _InputIterator,
|
||||||
typename = std::_RequireInputIter<_InputIterator>>
|
typename = std::_RequireInputIter<_InputIterator>>
|
||||||
iterator
|
iterator
|
||||||
insert(const_iterator __position, _InputIterator __first,
|
insert(const_iterator __position, _InputIterator __first,
|
||||||
_InputIterator __last)
|
_InputIterator __last)
|
||||||
{
|
{
|
||||||
_M_profile_insert(this, __position, size());
|
_M_profile_insert(this, __position, this->size());
|
||||||
return iterator(_Base::insert(__position.base(), __first, __last),
|
return iterator(_Base::insert(__position.base(), __first, __last),
|
||||||
this);
|
this);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
template<class _InputIterator>
|
template<class _InputIterator>
|
||||||
void
|
void
|
||||||
insert(iterator __position, _InputIterator __first,
|
insert(iterator __position, _InputIterator __first,
|
||||||
_InputIterator __last)
|
_InputIterator __last)
|
||||||
{
|
{
|
||||||
_M_profile_insert(this, __position, size());
|
_M_profile_insert(this, __position, this->size());
|
||||||
_Base::insert(__position.base(), __first, __last);
|
_Base::insert(__position.base(), __first, __last);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -439,12 +370,11 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
||||||
|
|
||||||
void
|
void
|
||||||
swap(list& __x)
|
swap(list& __x)
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
|
noexcept( noexcept(declval<_Base>().swap(__x)) )
|
||||||
|
#endif
|
||||||
{ _Base::swap(__x); }
|
{ _Base::swap(__x); }
|
||||||
|
|
||||||
void
|
|
||||||
clear() _GLIBCXX_NOEXCEPT
|
|
||||||
{ _Base::clear(); }
|
|
||||||
|
|
||||||
// 23.2.2.4 list operations:
|
// 23.2.2.4 list operations:
|
||||||
void
|
void
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
|
|
@ -488,9 +418,6 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
||||||
iterator __last)
|
iterator __last)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
// We used to perform the splice_alloc check: not anymore, redundant
|
|
||||||
// after implementing the relevant bits of N1599.
|
|
||||||
|
|
||||||
_Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()),
|
_Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()),
|
||||||
__first.base(), __last.base());
|
__first.base(), __last.base());
|
||||||
}
|
}
|
||||||
|
|
@ -515,12 +442,12 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class _Predicate>
|
template<class _Predicate>
|
||||||
void
|
void
|
||||||
remove_if(_Predicate __pred)
|
remove_if(_Predicate __pred)
|
||||||
{
|
{
|
||||||
for (iterator __x = begin(); __x != end(); )
|
for (iterator __x = begin(); __x != end(); )
|
||||||
{
|
{
|
||||||
__profcxx_list_operation(this);
|
__profcxx_list_operation(this);
|
||||||
if (__pred(*__x))
|
if (__pred(*__x))
|
||||||
__x = erase(__x);
|
__x = erase(__x);
|
||||||
else
|
else
|
||||||
|
|
@ -538,7 +465,7 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
||||||
iterator __next = __first;
|
iterator __next = __first;
|
||||||
while (++__next != __last)
|
while (++__next != __last)
|
||||||
{
|
{
|
||||||
__profcxx_list_operation(this);
|
__profcxx_list_operation(this);
|
||||||
if (*__first == *__next)
|
if (*__first == *__next)
|
||||||
erase(__next);
|
erase(__next);
|
||||||
else
|
else
|
||||||
|
|
@ -548,9 +475,9 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class _BinaryPredicate>
|
template<class _BinaryPredicate>
|
||||||
void
|
void
|
||||||
unique(_BinaryPredicate __binary_pred)
|
unique(_BinaryPredicate __binary_pred)
|
||||||
{
|
{
|
||||||
iterator __first = begin();
|
iterator __first = begin();
|
||||||
iterator __last = end();
|
iterator __last = end();
|
||||||
if (__first == __last)
|
if (__first == __last)
|
||||||
|
|
@ -558,7 +485,7 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
||||||
iterator __next = __first;
|
iterator __next = __first;
|
||||||
while (++__next != __last)
|
while (++__next != __last)
|
||||||
{
|
{
|
||||||
__profcxx_list_operation(this);
|
__profcxx_list_operation(this);
|
||||||
if (__binary_pred(*__first, *__next))
|
if (__binary_pred(*__first, *__next))
|
||||||
erase(__next);
|
erase(__next);
|
||||||
else
|
else
|
||||||
|
|
@ -573,12 +500,7 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
||||||
#else
|
#else
|
||||||
merge(list& __x)
|
merge(list& __x)
|
||||||
#endif
|
#endif
|
||||||
{
|
{ _Base::merge(_GLIBCXX_MOVE(__x._M_base())); }
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 300. list::merge() specification incomplete
|
|
||||||
if (this != &__x)
|
|
||||||
{ _Base::merge(_GLIBCXX_MOVE(__x._M_base())); }
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
void
|
void
|
||||||
|
|
@ -587,63 +509,49 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template<class _Compare>
|
template<class _Compare>
|
||||||
void
|
void
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
merge(list&& __x, _Compare __comp)
|
merge(list&& __x, _Compare __comp)
|
||||||
#else
|
#else
|
||||||
merge(list& __x, _Compare __comp)
|
merge(list& __x, _Compare __comp)
|
||||||
#endif
|
#endif
|
||||||
{
|
{ _Base::merge(_GLIBCXX_MOVE(__x._M_base()), __comp); }
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 300. list::merge() specification incomplete
|
|
||||||
if (this != &__x)
|
|
||||||
{ _Base::merge(_GLIBCXX_MOVE(__x._M_base()), __comp); }
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
template<typename _Compare>
|
template<typename _Compare>
|
||||||
void
|
void
|
||||||
merge(list& __x, _Compare __comp)
|
merge(list& __x, _Compare __comp)
|
||||||
{ this->merge(std::move(__x), __comp); }
|
{ this->merge(std::move(__x), __comp); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
|
||||||
sort() { _Base::sort(); }
|
|
||||||
|
|
||||||
template<typename _StrictWeakOrdering>
|
|
||||||
void
|
|
||||||
sort(_StrictWeakOrdering __pred) { _Base::sort(__pred); }
|
|
||||||
|
|
||||||
using _Base::reverse;
|
|
||||||
|
|
||||||
_Base&
|
_Base&
|
||||||
_M_base() _GLIBCXX_NOEXCEPT { return *this; }
|
_M_base() _GLIBCXX_NOEXCEPT { return *this; }
|
||||||
|
|
||||||
const _Base&
|
const _Base&
|
||||||
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
|
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
|
||||||
|
|
||||||
void _M_profile_find() const
|
void _M_profile_find() const
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void _M_profile_iterate(int __rewind = 0) const
|
void _M_profile_iterate(int __rewind = 0) const
|
||||||
{
|
{
|
||||||
__profcxx_list_operation(this);
|
__profcxx_list_operation(this);
|
||||||
__profcxx_list_iterate(this);
|
__profcxx_list_iterate(this);
|
||||||
if (__rewind)
|
if (__rewind)
|
||||||
__profcxx_list_rewind(this);
|
__profcxx_list_rewind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_type
|
size_type
|
||||||
_M_profile_insert(void* obj, const_iterator __pos, size_type __size)
|
_M_profile_insert(void* obj, const_iterator __pos, size_type __size)
|
||||||
{
|
{
|
||||||
size_type __shift = 0;
|
size_type __shift = 0;
|
||||||
typename _Base::const_iterator __it = __pos.base();
|
typename _Base::const_iterator __it = __pos.base();
|
||||||
for (; __it != _Base::end(); ++__it)
|
for (; __it != _Base::end(); ++__it)
|
||||||
__shift++;
|
__shift++;
|
||||||
__profcxx_list_rewind(this);
|
__profcxx_list_rewind(this);
|
||||||
__profcxx_list_operation(this);
|
__profcxx_list_operation(this);
|
||||||
__profcxx_list_insert(this, __shift, __size);
|
__profcxx_list_insert(this, __shift, __size);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@
|
||||||
#ifndef _GLIBCXX_PROFILE_MAP_H
|
#ifndef _GLIBCXX_PROFILE_MAP_H
|
||||||
#define _GLIBCXX_PROFILE_MAP_H 1
|
#define _GLIBCXX_PROFILE_MAP_H 1
|
||||||
|
|
||||||
#include <utility>
|
|
||||||
#include <profile/base.h>
|
#include <profile/base.h>
|
||||||
|
#include <profile/ordered_base.h>
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
{
|
{
|
||||||
|
|
@ -39,44 +39,47 @@ namespace __profile
|
||||||
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
|
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
|
||||||
typename _Allocator = std::allocator<std::pair<const _Key, _Tp> > >
|
typename _Allocator = std::allocator<std::pair<const _Key, _Tp> > >
|
||||||
class map
|
class map
|
||||||
: public _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Allocator>
|
: public _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Allocator>,
|
||||||
|
public _Ordered_profile<map<_Key, _Tp, _Compare, _Allocator> >
|
||||||
{
|
{
|
||||||
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;
|
||||||
typedef _Tp mapped_type;
|
typedef _Tp mapped_type;
|
||||||
typedef std::pair<const _Key, _Tp> value_type;
|
typedef typename _Base::value_type value_type;
|
||||||
typedef _Compare key_compare;
|
typedef _Compare key_compare;
|
||||||
typedef _Allocator allocator_type;
|
typedef typename _Base::reference reference;
|
||||||
typedef typename _Base::reference reference;
|
typedef typename _Base::const_reference const_reference;
|
||||||
typedef typename _Base::const_reference const_reference;
|
|
||||||
|
|
||||||
typedef typename _Base::iterator iterator;
|
typedef typename _Base::iterator iterator;
|
||||||
typedef typename _Base::const_iterator const_iterator;
|
typedef typename _Base::const_iterator const_iterator;
|
||||||
typedef typename _Base::size_type size_type;
|
typedef typename _Base::size_type size_type;
|
||||||
typedef typename _Base::difference_type difference_type;
|
typedef typename _Base::difference_type difference_type;
|
||||||
typedef typename _Base::pointer pointer;
|
typedef typename _Base::reverse_iterator reverse_iterator;
|
||||||
typedef typename _Base::const_pointer const_pointer;
|
typedef typename _Base::const_reverse_iterator const_reverse_iterator;
|
||||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
|
||||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
|
||||||
|
|
||||||
// 23.3.1.1 construct/copy/destroy:
|
// 23.3.1.1 construct/copy/destroy:
|
||||||
|
|
||||||
|
#if __cplusplus < 201103L
|
||||||
map()
|
map()
|
||||||
: _Base()
|
: _Base() { }
|
||||||
{ __profcxx_map_to_unordered_map_construct(this); }
|
map(const map& __x)
|
||||||
|
: _Base(__x) { }
|
||||||
|
~map()
|
||||||
|
{ }
|
||||||
|
#else
|
||||||
|
map() = default;
|
||||||
|
map(const map&) = default;
|
||||||
|
map(map&&) = default;
|
||||||
|
~map() = default;
|
||||||
|
#endif
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
map(const _Compare& __comp,
|
map(const _Compare& __comp,
|
||||||
const _Allocator& __a = _Allocator())
|
const _Allocator& __a = _Allocator())
|
||||||
: _Base(__comp, __a)
|
: _Base(__comp, __a) { }
|
||||||
{ __profcxx_map_to_unordered_map_construct(this); }
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
template<typename _InputIterator,
|
template<typename _InputIterator,
|
||||||
|
|
@ -84,61 +87,40 @@ namespace __profile
|
||||||
#else
|
#else
|
||||||
template<typename _InputIterator>
|
template<typename _InputIterator>
|
||||||
#endif
|
#endif
|
||||||
map(_InputIterator __first, _InputIterator __last,
|
map(_InputIterator __first, _InputIterator __last,
|
||||||
const _Compare& __comp = _Compare(),
|
const _Compare& __comp = _Compare(),
|
||||||
const _Allocator& __a = _Allocator())
|
const _Allocator& __a = _Allocator())
|
||||||
: _Base(__first, __last, __comp, __a)
|
: _Base(__first, __last, __comp, __a) { }
|
||||||
{ __profcxx_map_to_unordered_map_construct(this); }
|
|
||||||
|
|
||||||
map(const map& __x)
|
|
||||||
: _Base(__x)
|
|
||||||
{ __profcxx_map_to_unordered_map_construct(this); }
|
|
||||||
|
|
||||||
map(const _Base& __x)
|
map(const _Base& __x)
|
||||||
: _Base(__x)
|
: _Base(__x) { }
|
||||||
{ __profcxx_map_to_unordered_map_construct(this); }
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
map(map&& __x)
|
|
||||||
noexcept(is_nothrow_copy_constructible<_Compare>::value)
|
|
||||||
: _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& __a = _Allocator())
|
||||||
: _Base(__l, __c, __a)
|
: _Base(__l, __c, __a) { }
|
||||||
{ __profcxx_map_to_unordered_map_construct(this); }
|
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
map(const allocator_type& __a)
|
map(const _Allocator& __a)
|
||||||
: _Base(__a)
|
: _Base(__a) { }
|
||||||
{ __profcxx_map_to_unordered_map_construct(this); }
|
|
||||||
|
|
||||||
map(const map& __x, const allocator_type& __a)
|
map(const map& __x, const _Allocator& __a)
|
||||||
: _Base(__x, __a)
|
: _Base(__x, __a) { }
|
||||||
{ __profcxx_map_to_unordered_map_construct(this); }
|
|
||||||
|
|
||||||
map(map&& __x, const allocator_type& __a)
|
map(map&& __x, const _Allocator& __a)
|
||||||
noexcept(is_nothrow_copy_constructible<_Compare>::value
|
noexcept( noexcept(_Base(std::move(__x), __a)) )
|
||||||
&& _Alloc_traits::_S_always_equal())
|
: _Base(std::move(__x), __a) { }
|
||||||
: _Base(std::move(__x), __a)
|
|
||||||
{ __profcxx_map_to_unordered_map_construct(this); }
|
|
||||||
|
|
||||||
map(initializer_list<value_type> __l, const allocator_type& __a)
|
map(initializer_list<value_type> __l, const _Allocator& __a)
|
||||||
: _Base(__l, __a)
|
: _Base(__l, __a) { }
|
||||||
{ __profcxx_map_to_unordered_map_construct(this); }
|
|
||||||
|
|
||||||
template<typename _InputIterator>
|
template<typename _InputIterator>
|
||||||
map(_InputIterator __first, _InputIterator __last,
|
map(_InputIterator __first, _InputIterator __last,
|
||||||
const allocator_type& __a)
|
const _Allocator& __a)
|
||||||
: _Base(__first, __last, __a)
|
: _Base(__first, __last, __a) { }
|
||||||
{ __profcxx_map_to_unordered_map_construct(this); }
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
~map() _GLIBCXX_NOEXCEPT
|
|
||||||
{ __profcxx_map_to_unordered_map_destruct(this); }
|
|
||||||
|
|
||||||
#if __cplusplus < 201103L
|
#if __cplusplus < 201103L
|
||||||
map&
|
map&
|
||||||
operator=(const map& __x)
|
operator=(const map& __x)
|
||||||
|
|
@ -161,113 +143,79 @@ namespace __profile
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 133. map missing get_allocator()
|
|
||||||
using _Base::get_allocator;
|
|
||||||
|
|
||||||
// iterators:
|
|
||||||
iterator
|
|
||||||
begin() _GLIBCXX_NOEXCEPT
|
|
||||||
{ return _Base::begin(); }
|
|
||||||
|
|
||||||
const_iterator
|
|
||||||
begin() const _GLIBCXX_NOEXCEPT
|
|
||||||
{ return _Base::begin(); }
|
|
||||||
|
|
||||||
iterator
|
|
||||||
end() _GLIBCXX_NOEXCEPT
|
|
||||||
{ return _Base::end(); }
|
|
||||||
|
|
||||||
const_iterator
|
|
||||||
end() const _GLIBCXX_NOEXCEPT
|
|
||||||
{ return _Base::end(); }
|
|
||||||
|
|
||||||
reverse_iterator
|
reverse_iterator
|
||||||
rbegin() _GLIBCXX_NOEXCEPT
|
rbegin() _GLIBCXX_NOEXCEPT
|
||||||
{
|
{
|
||||||
__profcxx_map_to_unordered_map_invalidate(this);
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
return reverse_iterator(end());
|
return _Base::rbegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
const_reverse_iterator
|
const_reverse_iterator
|
||||||
rbegin() const _GLIBCXX_NOEXCEPT
|
rbegin() const _GLIBCXX_NOEXCEPT
|
||||||
{
|
{
|
||||||
__profcxx_map_to_unordered_map_invalidate(this);
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
return const_reverse_iterator(end());
|
return _Base::rbegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
reverse_iterator
|
reverse_iterator
|
||||||
rend() _GLIBCXX_NOEXCEPT
|
rend() _GLIBCXX_NOEXCEPT
|
||||||
{
|
{
|
||||||
__profcxx_map_to_unordered_map_invalidate(this);
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
return reverse_iterator(begin());
|
return _Base::rend();
|
||||||
}
|
}
|
||||||
|
|
||||||
const_reverse_iterator
|
const_reverse_iterator
|
||||||
rend() const _GLIBCXX_NOEXCEPT
|
rend() const _GLIBCXX_NOEXCEPT
|
||||||
{
|
{
|
||||||
__profcxx_map_to_unordered_map_invalidate(this);
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
return const_reverse_iterator(begin());
|
return _Base::rend();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
const_iterator
|
|
||||||
cbegin() const noexcept
|
|
||||||
{ return const_iterator(_Base::begin()); }
|
|
||||||
|
|
||||||
const_iterator
|
|
||||||
cend() const noexcept
|
|
||||||
{ return const_iterator(_Base::end()); }
|
|
||||||
|
|
||||||
const_reverse_iterator
|
const_reverse_iterator
|
||||||
crbegin() const noexcept
|
crbegin() const noexcept
|
||||||
{
|
{
|
||||||
__profcxx_map_to_unordered_map_invalidate(this);
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
return const_reverse_iterator(end());
|
return _Base::crbegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
const_reverse_iterator
|
const_reverse_iterator
|
||||||
crend() const noexcept
|
crend() const noexcept
|
||||||
{
|
{
|
||||||
__profcxx_map_to_unordered_map_invalidate(this);
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
return const_reverse_iterator(begin());
|
return _Base::crend();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// capacity:
|
|
||||||
using _Base::empty;
|
|
||||||
using _Base::size;
|
|
||||||
using _Base::max_size;
|
|
||||||
|
|
||||||
// 23.3.1.2 element access:
|
// 23.3.1.2 element access:
|
||||||
mapped_type&
|
mapped_type&
|
||||||
operator[](const key_type& __k)
|
operator[](const key_type& __k)
|
||||||
{
|
{
|
||||||
__profcxx_map_to_unordered_map_find(this, size());
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
return _Base::operator[](__k);
|
return _Base::operator[](__k);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
mapped_type&
|
mapped_type&
|
||||||
operator[](key_type&& __k)
|
operator[](key_type&& __k)
|
||||||
{
|
{
|
||||||
__profcxx_map_to_unordered_map_find(this, size());
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
return _Base::operator[](std::move(__k));
|
return _Base::operator[](std::move(__k));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mapped_type&
|
mapped_type&
|
||||||
at(const key_type& __k)
|
at(const key_type& __k)
|
||||||
{
|
{
|
||||||
__profcxx_map_to_unordered_map_find(this, size());
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
return _Base::at(__k);
|
return _Base::at(__k);
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapped_type&
|
const mapped_type&
|
||||||
at(const key_type& __k) const
|
at(const key_type& __k) const
|
||||||
{
|
{
|
||||||
__profcxx_map_to_unordered_map_find(this, size());
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
return _Base::at(__k);
|
return _Base::at(__k);
|
||||||
}
|
}
|
||||||
|
|
||||||
// modifiers:
|
// modifiers:
|
||||||
|
|
@ -276,21 +224,20 @@ namespace __profile
|
||||||
std::pair<iterator, bool>
|
std::pair<iterator, bool>
|
||||||
emplace(_Args&&... __args)
|
emplace(_Args&&... __args)
|
||||||
{
|
{
|
||||||
__profcxx_map_to_unordered_map_insert(this, size(), 1);
|
// The cost is the same whether or not the element is inserted so we
|
||||||
auto __res = _Base::emplace(std::forward<_Args>(__args)...);
|
// always report insertion of 1 element.
|
||||||
return std::pair<iterator, bool>(iterator(__res.first),
|
__profcxx_map_to_unordered_map_insert(this, this->size(), 1);
|
||||||
__res.second);
|
return _Base::emplace(std::forward<_Args>(__args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... _Args>
|
template<typename... _Args>
|
||||||
iterator
|
iterator
|
||||||
emplace_hint(const_iterator __pos, _Args&&... __args)
|
emplace_hint(const_iterator __pos, _Args&&... __args)
|
||||||
{
|
{
|
||||||
size_type size_before = size();
|
auto size_before = this->size();
|
||||||
auto __res = _Base::emplace_hint(__pos,
|
auto __res = _Base::emplace_hint(__pos, std::forward<_Args>(__args)...);
|
||||||
std::forward<_Args>(__args)...);
|
|
||||||
__profcxx_map_to_unordered_map_insert(this, size_before,
|
__profcxx_map_to_unordered_map_insert(this, size_before,
|
||||||
size() - size_before);
|
_M_hint_used(__pos, __res) ? 0 : 1);
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -298,67 +245,56 @@ namespace __profile
|
||||||
std::pair<iterator, bool>
|
std::pair<iterator, bool>
|
||||||
insert(const value_type& __x)
|
insert(const value_type& __x)
|
||||||
{
|
{
|
||||||
__profcxx_map_to_unordered_map_insert(this, size(), 1);
|
__profcxx_map_to_unordered_map_insert(this, this->size(), 1);
|
||||||
typedef typename _Base::iterator _Base_iterator;
|
return _Base::insert(__x);
|
||||||
std::pair<_Base_iterator, bool> __res = _Base::insert(__x);
|
|
||||||
return std::pair<iterator, bool>(iterator(__res.first),
|
|
||||||
__res.second);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
template<typename _Pair, typename = typename
|
template<typename _Pair, typename = typename
|
||||||
std::enable_if<std::is_constructible<value_type,
|
std::enable_if<std::is_constructible<value_type,
|
||||||
_Pair&&>::value>::type>
|
_Pair&&>::value>::type>
|
||||||
std::pair<iterator, bool>
|
std::pair<iterator, bool>
|
||||||
insert(_Pair&& __x)
|
insert(_Pair&& __x)
|
||||||
{
|
{
|
||||||
__profcxx_map_to_unordered_map_insert(this, size(), 1);
|
__profcxx_map_to_unordered_map_insert(this, this->size(), 1);
|
||||||
typedef typename _Base::iterator _Base_iterator;
|
return _Base::insert(std::forward<_Pair>(__x));
|
||||||
std::pair<_Base_iterator, bool> __res
|
|
||||||
= _Base::insert(std::forward<_Pair>(__x));
|
|
||||||
return std::pair<iterator, bool>(iterator(__res.first),
|
|
||||||
__res.second);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
void
|
void
|
||||||
insert(std::initializer_list<value_type> __list)
|
insert(std::initializer_list<value_type> __list)
|
||||||
{
|
{ insert(__list.begin(), __list.end()); }
|
||||||
size_type size_before = size();
|
|
||||||
_Base::insert(__list);
|
|
||||||
__profcxx_map_to_unordered_map_insert(this, size_before,
|
|
||||||
size() - size_before);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
insert(const_iterator __position, const value_type& __x)
|
insert(const_iterator __pos, const value_type& __x)
|
||||||
#else
|
#else
|
||||||
insert(iterator __position, const value_type& __x)
|
insert(iterator __pos, const value_type& __x)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
size_type size_before = size();
|
size_type size_before = this->size();
|
||||||
iterator __i = iterator(_Base::insert(__position, __x));
|
iterator __res = _Base::insert(__pos, __x);
|
||||||
__profcxx_map_to_unordered_map_insert(this, size_before,
|
|
||||||
size() - size_before);
|
__profcxx_map_to_unordered_map_insert(this, size_before,
|
||||||
return __i;
|
_M_hint_used(__pos, __res) ? 0 : 1);
|
||||||
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
template<typename _Pair, typename = typename
|
template<typename _Pair, typename = typename
|
||||||
std::enable_if<std::is_constructible<value_type,
|
std::enable_if<std::is_constructible<value_type,
|
||||||
_Pair&&>::value>::type>
|
_Pair&&>::value>::type>
|
||||||
iterator
|
iterator
|
||||||
insert(const_iterator __position, _Pair&& __x)
|
insert(const_iterator __pos, _Pair&& __x)
|
||||||
{
|
{
|
||||||
size_type size_before = size();
|
size_type size_before = this->size();
|
||||||
iterator __i
|
auto __res = _Base::insert(__pos, std::forward<_Pair>(__x));
|
||||||
= iterator(_Base::insert(__position, std::forward<_Pair>(__x)));
|
|
||||||
__profcxx_map_to_unordered_map_insert(this, size_before,
|
__profcxx_map_to_unordered_map_insert(this, size_before,
|
||||||
size() - size_before);
|
_M_hint_used(__pos, __res) ? 0 : 1);
|
||||||
return __i;
|
return __res;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -368,151 +304,163 @@ namespace __profile
|
||||||
#else
|
#else
|
||||||
template<typename _InputIterator>
|
template<typename _InputIterator>
|
||||||
#endif
|
#endif
|
||||||
void
|
void
|
||||||
insert(_InputIterator __first, _InputIterator __last)
|
insert(_InputIterator __first, _InputIterator __last)
|
||||||
{
|
{
|
||||||
size_type size_before = size();
|
for (; __first != __last; ++__first)
|
||||||
_Base::insert(__first, __last);
|
insert(*__first);
|
||||||
__profcxx_map_to_unordered_map_insert(this, size_before,
|
|
||||||
size() - size_before);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
iterator
|
iterator
|
||||||
erase(const_iterator __position)
|
erase(const_iterator __position)
|
||||||
{
|
{
|
||||||
iterator __i = _Base::erase(__position);
|
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
|
||||||
__profcxx_map_to_unordered_map_erase(this, size(), 1);
|
return _Base::erase(__position);
|
||||||
return __i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
erase(iterator __position)
|
erase(iterator __position)
|
||||||
{ return erase(const_iterator(__position)); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
|
||||||
|
return _Base::erase(__position);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
void
|
void
|
||||||
erase(iterator __position)
|
erase(iterator __position)
|
||||||
{
|
{
|
||||||
|
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
|
||||||
_Base::erase(__position);
|
_Base::erase(__position);
|
||||||
__profcxx_map_to_unordered_map_erase(this, size(), 1);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
size_type
|
size_type
|
||||||
erase(const key_type& __x)
|
erase(const key_type& __x)
|
||||||
{
|
{
|
||||||
iterator __victim = find(__x);
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
if (__victim == end())
|
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
|
||||||
return 0;
|
return _Base::erase(__x);
|
||||||
else
|
|
||||||
{
|
|
||||||
_Base::erase(__victim);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
iterator
|
iterator
|
||||||
erase(const_iterator __first, const_iterator __last)
|
erase(const_iterator __first, const_iterator __last)
|
||||||
{ return iterator(_Base::erase(__first, __last)); }
|
{
|
||||||
|
if (__first != __last)
|
||||||
|
{
|
||||||
|
iterator __ret;
|
||||||
|
for (; __first != __last;)
|
||||||
|
__ret = erase(__first++);
|
||||||
|
return __ret;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return _Base::erase(__first, __last);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
void
|
void
|
||||||
erase(iterator __first, iterator __last)
|
erase(iterator __first, iterator __last)
|
||||||
{ _Base::erase(__first, __last); }
|
{
|
||||||
|
for (; __first != __last;)
|
||||||
|
erase(__first++);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
swap(map& __x)
|
swap(map& __x)
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
noexcept(_Alloc_traits::_S_nothrow_swap())
|
noexcept( noexcept(declval<_Base>().swap(__x)) )
|
||||||
#endif
|
#endif
|
||||||
{ _Base::swap(__x); }
|
{ _Base::swap(__x); }
|
||||||
|
|
||||||
void
|
|
||||||
clear() _GLIBCXX_NOEXCEPT
|
|
||||||
{ this->erase(begin(), end()); }
|
|
||||||
|
|
||||||
// observers:
|
|
||||||
using _Base::key_comp;
|
|
||||||
using _Base::value_comp;
|
|
||||||
|
|
||||||
// 23.3.1.3 map operations:
|
// 23.3.1.3 map operations:
|
||||||
iterator
|
iterator
|
||||||
find(const key_type& __x)
|
find(const key_type& __x)
|
||||||
{
|
{
|
||||||
__profcxx_map_to_unordered_map_find(this, size());
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
return iterator(_Base::find(__x));
|
return _Base::find(__x);
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator
|
const_iterator
|
||||||
find(const key_type& __x) const
|
find(const key_type& __x) const
|
||||||
{
|
{
|
||||||
__profcxx_map_to_unordered_map_find(this, size());
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
return const_iterator(_Base::find(__x));
|
return _Base::find(__x);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_type
|
size_type
|
||||||
count(const key_type& __x) const
|
count(const key_type& __x) const
|
||||||
{
|
{
|
||||||
__profcxx_map_to_unordered_map_find(this, size());
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
return _Base::count(__x);
|
return _Base::count(__x);
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
lower_bound(const key_type& __x)
|
lower_bound(const key_type& __x)
|
||||||
{
|
{
|
||||||
__profcxx_map_to_unordered_map_invalidate(this);
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
return iterator(_Base::lower_bound(__x));
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::lower_bound(__x);
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator
|
const_iterator
|
||||||
lower_bound(const key_type& __x) const
|
lower_bound(const key_type& __x) const
|
||||||
{
|
{
|
||||||
__profcxx_map_to_unordered_map_invalidate(this);
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
return const_iterator(_Base::lower_bound(__x));
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::lower_bound(__x);
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
upper_bound(const key_type& __x)
|
upper_bound(const key_type& __x)
|
||||||
{
|
{
|
||||||
__profcxx_map_to_unordered_map_invalidate(this);
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
return iterator(_Base::upper_bound(__x));
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::upper_bound(__x);
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator
|
const_iterator
|
||||||
upper_bound(const key_type& __x) const
|
upper_bound(const key_type& __x) const
|
||||||
{
|
{
|
||||||
__profcxx_map_to_unordered_map_invalidate(this);
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
return const_iterator(_Base::upper_bound(__x));
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::upper_bound(__x);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<iterator,iterator>
|
std::pair<iterator,iterator>
|
||||||
equal_range(const key_type& __x)
|
equal_range(const key_type& __x)
|
||||||
{
|
{
|
||||||
typedef typename _Base::iterator _Base_iterator;
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
std::pair<_Base_iterator, _Base_iterator> __res =
|
return _Base::equal_range(__x);
|
||||||
_Base::equal_range(__x);
|
|
||||||
return std::make_pair(iterator(__res.first),
|
|
||||||
iterator(__res.second));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<const_iterator,const_iterator>
|
std::pair<const_iterator,const_iterator>
|
||||||
equal_range(const key_type& __x) const
|
equal_range(const key_type& __x) const
|
||||||
{
|
{
|
||||||
__profcxx_map_to_unordered_map_find(this, size());
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
typedef typename _Base::const_iterator _Base_const_iterator;
|
return _Base::equal_range(__x);
|
||||||
std::pair<_Base_const_iterator, _Base_const_iterator> __res =
|
|
||||||
_Base::equal_range(__x);
|
|
||||||
return std::make_pair(const_iterator(__res.first),
|
|
||||||
const_iterator(__res.second));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_Base&
|
_Base&
|
||||||
_M_base() _GLIBCXX_NOEXCEPT { return *this; }
|
_M_base() _GLIBCXX_NOEXCEPT { return *this; }
|
||||||
|
|
||||||
const _Base&
|
const _Base&
|
||||||
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
|
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
/** If hint is used we consider that the map and unordered_map
|
||||||
|
* operations have equivalent insertion cost so we do not update metrics
|
||||||
|
* about it.
|
||||||
|
* Note that to find out if hint has been used is libstdc++
|
||||||
|
* implementation dependant.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
_M_hint_used(const_iterator __hint, iterator __res)
|
||||||
|
{
|
||||||
|
return (__hint == __res ||
|
||||||
|
(__hint == this->end() && ++__res == this->end()) ||
|
||||||
|
(__hint != this->end() && (++__hint == __res ||
|
||||||
|
++__res == --__hint)));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename _Key, typename _Tp,
|
template<typename _Key, typename _Tp,
|
||||||
|
|
@ -520,10 +468,10 @@ namespace __profile
|
||||||
inline bool
|
inline bool
|
||||||
operator==(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
|
operator==(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
|
||||||
const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
|
const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
|
||||||
{
|
{
|
||||||
__profcxx_map_to_unordered_map_invalidate(&__lhs);
|
__profcxx_map_to_unordered_map_invalidate(&__lhs);
|
||||||
__profcxx_map_to_unordered_map_invalidate(&__rhs);
|
__profcxx_map_to_unordered_map_invalidate(&__rhs);
|
||||||
return __lhs._M_base() == __rhs._M_base();
|
return __lhs._M_base() == __rhs._M_base();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Key, typename _Tp,
|
template<typename _Key, typename _Tp,
|
||||||
|
|
@ -531,10 +479,10 @@ namespace __profile
|
||||||
inline bool
|
inline bool
|
||||||
operator!=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
|
operator!=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
|
||||||
const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
|
const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
|
||||||
{
|
{
|
||||||
__profcxx_map_to_unordered_map_invalidate(&__lhs);
|
__profcxx_map_to_unordered_map_invalidate(&__lhs);
|
||||||
__profcxx_map_to_unordered_map_invalidate(&__rhs);
|
__profcxx_map_to_unordered_map_invalidate(&__rhs);
|
||||||
return __lhs._M_base() != __rhs._M_base();
|
return __lhs._M_base() != __rhs._M_base();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Key, typename _Tp,
|
template<typename _Key, typename _Tp,
|
||||||
|
|
@ -545,7 +493,7 @@ namespace __profile
|
||||||
{
|
{
|
||||||
__profcxx_map_to_unordered_map_invalidate(&__lhs);
|
__profcxx_map_to_unordered_map_invalidate(&__lhs);
|
||||||
__profcxx_map_to_unordered_map_invalidate(&__rhs);
|
__profcxx_map_to_unordered_map_invalidate(&__rhs);
|
||||||
return __lhs._M_base() < __rhs._M_base();
|
return __lhs._M_base() < __rhs._M_base();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Key, typename _Tp,
|
template<typename _Key, typename _Tp,
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,8 @@
|
||||||
#ifndef _GLIBCXX_PROFILE_MULTIMAP_H
|
#ifndef _GLIBCXX_PROFILE_MULTIMAP_H
|
||||||
#define _GLIBCXX_PROFILE_MULTIMAP_H 1
|
#define _GLIBCXX_PROFILE_MULTIMAP_H 1
|
||||||
|
|
||||||
#include <utility>
|
#include <profile/base.h>
|
||||||
|
#include <profile/ordered_base.h>
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
{
|
{
|
||||||
|
|
@ -39,38 +40,44 @@ namespace __profile
|
||||||
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
|
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
|
||||||
typename _Allocator = std::allocator<std::pair<const _Key, _Tp> > >
|
typename _Allocator = std::allocator<std::pair<const _Key, _Tp> > >
|
||||||
class multimap
|
class multimap
|
||||||
: public _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Allocator>
|
: public _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Allocator>,
|
||||||
|
public _Ordered_profile<map<_Key, _Tp, _Compare, _Allocator> >
|
||||||
{
|
{
|
||||||
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;
|
||||||
typedef _Tp mapped_type;
|
typedef _Tp mapped_type;
|
||||||
typedef std::pair<const _Key, _Tp> value_type;
|
typedef std::pair<const _Key, _Tp> value_type;
|
||||||
typedef _Compare key_compare;
|
typedef _Compare key_compare;
|
||||||
typedef _Allocator allocator_type;
|
typedef typename _Base::reference reference;
|
||||||
typedef typename _Base::reference reference;
|
typedef typename _Base::const_reference const_reference;
|
||||||
typedef typename _Base::const_reference const_reference;
|
|
||||||
|
|
||||||
typedef typename _Base::iterator iterator;
|
typedef typename _Base::iterator iterator;
|
||||||
typedef typename _Base::const_iterator const_iterator;
|
typedef typename _Base::const_iterator const_iterator;
|
||||||
typedef typename _Base::reverse_iterator reverse_iterator;
|
typedef typename _Base::reverse_iterator reverse_iterator;
|
||||||
typedef typename _Base::const_reverse_iterator const_reverse_iterator;
|
typedef typename _Base::const_reverse_iterator const_reverse_iterator;
|
||||||
|
|
||||||
typedef typename _Base::size_type size_type;
|
typedef typename _Base::size_type size_type;
|
||||||
typedef typename _Base::difference_type difference_type;
|
typedef typename _Base::difference_type difference_type;
|
||||||
typedef typename _Base::pointer pointer;
|
typedef typename _Base::pointer pointer;
|
||||||
typedef typename _Base::const_pointer const_pointer;
|
typedef typename _Base::const_pointer const_pointer;
|
||||||
|
|
||||||
// 23.3.1.1 construct/copy/destroy:
|
// 23.3.1.1 construct/copy/destroy:
|
||||||
|
|
||||||
|
#if __cplusplus < 201103L
|
||||||
multimap()
|
multimap()
|
||||||
: _Base() { }
|
: _Base() { }
|
||||||
|
multimap(const multimap& __x)
|
||||||
|
: _Base(__x) { }
|
||||||
|
~multimap() { }
|
||||||
|
#else
|
||||||
|
multimap() = default;
|
||||||
|
multimap(const multimap&) = default;
|
||||||
|
multimap(multimap&&) = default;
|
||||||
|
~multimap() = default;
|
||||||
|
#endif
|
||||||
|
|
||||||
explicit multimap(const _Compare& __comp,
|
explicit multimap(const _Compare& __comp,
|
||||||
const _Allocator& __a = _Allocator())
|
const _Allocator& __a = _Allocator())
|
||||||
|
|
@ -82,49 +89,40 @@ namespace __profile
|
||||||
#else
|
#else
|
||||||
template<typename _InputIterator>
|
template<typename _InputIterator>
|
||||||
#endif
|
#endif
|
||||||
multimap(_InputIterator __first, _InputIterator __last,
|
multimap(_InputIterator __first, _InputIterator __last,
|
||||||
const _Compare& __comp = _Compare(),
|
const _Compare& __comp = _Compare(),
|
||||||
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)
|
|
||||||
: _Base(__x) { }
|
|
||||||
#else
|
|
||||||
multimap(const multimap&) = default;
|
|
||||||
multimap(multimap&&) = default;
|
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
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& __a = _Allocator())
|
||||||
: _Base(__l, __c, __a) { }
|
: _Base(__l, __c, __a) { }
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
multimap(const allocator_type& __a)
|
multimap(const _Allocator& __a)
|
||||||
: _Base(__a) { }
|
: _Base(__a) { }
|
||||||
|
|
||||||
multimap(const multimap& __x, const allocator_type& __a)
|
multimap(const multimap& __x, const _Allocator& __a)
|
||||||
: _Base(__x, __a) { }
|
: _Base(__x, __a) { }
|
||||||
|
|
||||||
multimap(multimap&& __x, const allocator_type& __a)
|
multimap(multimap&& __x, const _Allocator& __a)
|
||||||
noexcept(is_nothrow_copy_constructible<_Compare>::value
|
noexcept( noexcept(_Base(std::move(__x), __a)) )
|
||||||
&& _Alloc_traits::_S_always_equal())
|
|
||||||
: _Base(std::move(__x), __a) { }
|
: _Base(std::move(__x), __a) { }
|
||||||
|
|
||||||
multimap(initializer_list<value_type> __l, const allocator_type& __a)
|
multimap(initializer_list<value_type> __l, const _Allocator& __a)
|
||||||
: _Base(__l, __a) { }
|
: _Base(__l, __a) { }
|
||||||
|
|
||||||
template<typename _InputIterator>
|
template<typename _InputIterator>
|
||||||
multimap(_InputIterator __first, _InputIterator __last,
|
multimap(_InputIterator __first, _InputIterator __last,
|
||||||
const allocator_type& __a)
|
const _Allocator& __a)
|
||||||
: _Base(__first, __last, __a) { }
|
: _Base(__first, __last, __a) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
multimap(const _Base& __x)
|
multimap(const _Base& __x)
|
||||||
: _Base(__x) { }
|
: _Base(__x) { }
|
||||||
|
|
||||||
~multimap() _GLIBCXX_NOEXCEPT { }
|
|
||||||
|
|
||||||
#if __cplusplus < 201103L
|
#if __cplusplus < 201103L
|
||||||
multimap&
|
multimap&
|
||||||
operator=(const multimap& __x)
|
operator=(const multimap& __x)
|
||||||
|
|
@ -147,117 +145,125 @@ namespace __profile
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using _Base::get_allocator;
|
|
||||||
|
|
||||||
// iterators:
|
|
||||||
iterator
|
|
||||||
begin() _GLIBCXX_NOEXCEPT
|
|
||||||
{ return iterator(_Base::begin()); }
|
|
||||||
|
|
||||||
const_iterator
|
|
||||||
begin() const _GLIBCXX_NOEXCEPT
|
|
||||||
{ return const_iterator(_Base::begin()); }
|
|
||||||
|
|
||||||
iterator
|
|
||||||
end() _GLIBCXX_NOEXCEPT
|
|
||||||
{ return iterator(_Base::end()); }
|
|
||||||
|
|
||||||
const_iterator
|
|
||||||
end() const _GLIBCXX_NOEXCEPT
|
|
||||||
{ return const_iterator(_Base::end()); }
|
|
||||||
|
|
||||||
reverse_iterator
|
reverse_iterator
|
||||||
rbegin() _GLIBCXX_NOEXCEPT
|
rbegin() _GLIBCXX_NOEXCEPT
|
||||||
{ return reverse_iterator(end()); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::rbegin();
|
||||||
|
}
|
||||||
|
|
||||||
const_reverse_iterator
|
const_reverse_iterator
|
||||||
rbegin() const _GLIBCXX_NOEXCEPT
|
rbegin() const _GLIBCXX_NOEXCEPT
|
||||||
{ return const_reverse_iterator(end()); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::rbegin();
|
||||||
|
}
|
||||||
|
|
||||||
reverse_iterator
|
reverse_iterator
|
||||||
rend() _GLIBCXX_NOEXCEPT
|
rend() _GLIBCXX_NOEXCEPT
|
||||||
{ return reverse_iterator(begin()); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::rend();
|
||||||
|
}
|
||||||
|
|
||||||
const_reverse_iterator
|
const_reverse_iterator
|
||||||
rend() const _GLIBCXX_NOEXCEPT
|
rend() const _GLIBCXX_NOEXCEPT
|
||||||
{ return const_reverse_iterator(begin()); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::rend();
|
||||||
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
const_iterator
|
|
||||||
cbegin() const noexcept
|
|
||||||
{ return const_iterator(_Base::begin()); }
|
|
||||||
|
|
||||||
const_iterator
|
|
||||||
cend() const noexcept
|
|
||||||
{ return const_iterator(_Base::end()); }
|
|
||||||
|
|
||||||
const_reverse_iterator
|
const_reverse_iterator
|
||||||
crbegin() const noexcept
|
crbegin() const noexcept
|
||||||
{ return const_reverse_iterator(end()); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::crbegin();
|
||||||
|
}
|
||||||
|
|
||||||
const_reverse_iterator
|
const_reverse_iterator
|
||||||
crend() const noexcept
|
crend() const noexcept
|
||||||
{ return const_reverse_iterator(begin()); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::crend();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// capacity:
|
|
||||||
using _Base::empty;
|
|
||||||
using _Base::size;
|
|
||||||
using _Base::max_size;
|
|
||||||
|
|
||||||
// modifiers:
|
// modifiers:
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
template<typename... _Args>
|
template<typename... _Args>
|
||||||
iterator
|
iterator
|
||||||
emplace(_Args&&... __args)
|
emplace(_Args&&... __args)
|
||||||
{
|
{
|
||||||
return iterator(_Base::emplace(std::forward<_Args>(__args)...));
|
__profcxx_map_to_unordered_map_insert(this, this->size(), 1);
|
||||||
|
return _Base::emplace(std::forward<_Args>(__args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... _Args>
|
template<typename... _Args>
|
||||||
iterator
|
iterator
|
||||||
emplace_hint(const_iterator __pos, _Args&&... __args)
|
emplace_hint(const_iterator __pos, _Args&&... __args)
|
||||||
{
|
{
|
||||||
return iterator(_Base::emplace_hint(__pos,
|
auto size_before = this->size();
|
||||||
std::forward<_Args>(__args)...));
|
auto __res
|
||||||
|
= _Base::emplace_hint(__pos, std::forward<_Args>(__args)...);
|
||||||
|
__profcxx_map_to_unordered_map_insert(this, size_before,
|
||||||
|
_M_hint_used(__pos, __res) ? 0 : 1);
|
||||||
|
return __res;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
insert(const value_type& __x)
|
insert(const value_type& __x)
|
||||||
{ return iterator(_Base::insert(__x)); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_insert(this, this->size(), 1);
|
||||||
|
return _Base::insert(__x);
|
||||||
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
template<typename _Pair, typename = typename
|
template<typename _Pair, typename = typename
|
||||||
std::enable_if<std::is_constructible<value_type,
|
std::enable_if<std::is_constructible<value_type,
|
||||||
_Pair&&>::value>::type>
|
_Pair&&>::value>::type>
|
||||||
iterator
|
iterator
|
||||||
insert(_Pair&& __x)
|
insert(_Pair&& __x)
|
||||||
{ return iterator(_Base::insert(std::forward<_Pair>(__x))); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_insert(this, this->size(), 1);
|
||||||
|
return _Base::insert(std::forward<_Pair>(__x));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
void
|
void
|
||||||
insert(std::initializer_list<value_type> __list)
|
insert(std::initializer_list<value_type> __list)
|
||||||
{ _Base::insert(__list); }
|
{ insert(__list.begin(), __list.end()); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
insert(const_iterator __position, const value_type& __x)
|
insert(const_iterator __pos, const value_type& __x)
|
||||||
#else
|
#else
|
||||||
insert(iterator __position, const value_type& __x)
|
insert(iterator __pos, const value_type& __x)
|
||||||
#endif
|
#endif
|
||||||
{ return iterator(_Base::insert(__position, __x)); }
|
{
|
||||||
|
size_type size_before = this->size();
|
||||||
|
iterator __res = _Base::insert(__pos, __x);
|
||||||
|
__profcxx_map_to_unordered_map_insert(this, size_before,
|
||||||
|
_M_hint_used(__pos, __res) ? 0 : 1);
|
||||||
|
return __res;
|
||||||
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
template<typename _Pair, typename = typename
|
template<typename _Pair, typename = typename
|
||||||
std::enable_if<std::is_constructible<value_type,
|
std::enable_if<std::is_constructible<value_type,
|
||||||
_Pair&&>::value>::type>
|
_Pair&&>::value>::type>
|
||||||
iterator
|
iterator
|
||||||
insert(const_iterator __position, _Pair&& __x)
|
insert(const_iterator __pos, _Pair&& __x)
|
||||||
{ return iterator(_Base::insert(__position,
|
{
|
||||||
std::forward<_Pair>(__x))); }
|
size_type size_before = this->size();
|
||||||
|
auto __res = _Base::insert(__pos, std::forward<_Pair>(__x));
|
||||||
|
__profcxx_map_to_unordered_map_insert(this, size_before,
|
||||||
|
_M_hint_used(__pos, __res) ? 0 : 1);
|
||||||
|
return __res;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
|
|
@ -266,115 +272,163 @@ namespace __profile
|
||||||
#else
|
#else
|
||||||
template<typename _InputIterator>
|
template<typename _InputIterator>
|
||||||
#endif
|
#endif
|
||||||
void
|
void
|
||||||
insert(_InputIterator __first, _InputIterator __last)
|
insert(_InputIterator __first, _InputIterator __last)
|
||||||
{ _Base::insert(__first, __last); }
|
{
|
||||||
|
for (; __first != __last; ++__first)
|
||||||
|
insert(*__first);
|
||||||
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
iterator
|
iterator
|
||||||
erase(const_iterator __position)
|
erase(const_iterator __pos)
|
||||||
{ return iterator(_Base::erase(__position)); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
|
||||||
|
return _Base::erase(__pos);
|
||||||
|
}
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
erase(iterator __position)
|
erase(iterator __pos)
|
||||||
{ return iterator(_Base::erase(__position)); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
|
||||||
|
return _Base::erase(__pos);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
void
|
void
|
||||||
erase(iterator __position)
|
erase(iterator __pos)
|
||||||
{ _Base::erase(__position); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
|
||||||
|
_Base::erase(__pos);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
size_type
|
size_type
|
||||||
erase(const key_type& __x)
|
erase(const key_type& __x)
|
||||||
{
|
{
|
||||||
std::pair<iterator, iterator> __victims = this->equal_range(__x);
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
size_type __count = 0;
|
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
|
||||||
while (__victims.first != __victims.second)
|
return _Base::erase(__x);
|
||||||
{
|
|
||||||
iterator __victim = __victims.first++;
|
|
||||||
_Base::erase(__victim);
|
|
||||||
++__count;
|
|
||||||
}
|
|
||||||
return __count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
iterator
|
iterator
|
||||||
erase(const_iterator __first, const_iterator __last)
|
erase(const_iterator __first, const_iterator __last)
|
||||||
{ return iterator(_Base::erase(__first, __last)); }
|
{
|
||||||
|
if (__first != __last)
|
||||||
|
{
|
||||||
|
iterator __ret;
|
||||||
|
for (; __first != __last;)
|
||||||
|
__ret = erase(__first++);
|
||||||
|
return __ret;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return _Base::erase(__first, __last);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
void
|
void
|
||||||
erase(iterator __first, iterator __last)
|
erase(iterator __first, iterator __last)
|
||||||
{ _Base::erase(__first, __last); }
|
{
|
||||||
|
for (; __first != __last;)
|
||||||
|
erase(__first++);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
swap(multimap& __x)
|
swap(multimap& __x)
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
noexcept(_Alloc_traits::_S_nothrow_swap())
|
noexcept( noexcept(declval<_Base>().swap(__x)) )
|
||||||
#endif
|
#endif
|
||||||
{ _Base::swap(__x); }
|
{ _Base::swap(__x); }
|
||||||
|
|
||||||
void
|
|
||||||
clear() _GLIBCXX_NOEXCEPT
|
|
||||||
{ this->erase(begin(), end()); }
|
|
||||||
|
|
||||||
// observers:
|
|
||||||
using _Base::key_comp;
|
|
||||||
using _Base::value_comp;
|
|
||||||
|
|
||||||
// 23.3.1.3 multimap operations:
|
// 23.3.1.3 multimap operations:
|
||||||
iterator
|
iterator
|
||||||
find(const key_type& __x)
|
find(const key_type& __x)
|
||||||
{ return iterator(_Base::find(__x)); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
|
return _Base::find(__x);
|
||||||
|
}
|
||||||
|
|
||||||
const_iterator
|
const_iterator
|
||||||
find(const key_type& __x) const
|
find(const key_type& __x) const
|
||||||
{ return const_iterator(_Base::find(__x)); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
|
return _Base::find(__x);
|
||||||
|
}
|
||||||
|
|
||||||
using _Base::count;
|
size_type
|
||||||
|
count(const key_type& __x) const
|
||||||
|
{
|
||||||
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
|
return _Base::count(__x);
|
||||||
|
}
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
lower_bound(const key_type& __x)
|
lower_bound(const key_type& __x)
|
||||||
{ return iterator(_Base::lower_bound(__x)); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::lower_bound(__x);
|
||||||
|
}
|
||||||
|
|
||||||
const_iterator
|
const_iterator
|
||||||
lower_bound(const key_type& __x) const
|
lower_bound(const key_type& __x) const
|
||||||
{ return const_iterator(_Base::lower_bound(__x)); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::lower_bound(__x);
|
||||||
|
}
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
upper_bound(const key_type& __x)
|
upper_bound(const key_type& __x)
|
||||||
{ return iterator(_Base::upper_bound(__x)); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::upper_bound(__x);
|
||||||
|
}
|
||||||
|
|
||||||
const_iterator
|
const_iterator
|
||||||
upper_bound(const key_type& __x) const
|
upper_bound(const key_type& __x) const
|
||||||
{ return const_iterator(_Base::upper_bound(__x)); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::upper_bound(__x);
|
||||||
|
}
|
||||||
|
|
||||||
std::pair<iterator,iterator>
|
std::pair<iterator,iterator>
|
||||||
equal_range(const key_type& __x)
|
equal_range(const key_type& __x)
|
||||||
{
|
{
|
||||||
typedef typename _Base::iterator _Base_iterator;
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
std::pair<_Base_iterator, _Base_iterator> __res =
|
return _Base::equal_range(__x);
|
||||||
_Base::equal_range(__x);
|
|
||||||
return std::make_pair(iterator(__res.first),
|
|
||||||
iterator(__res.second));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<const_iterator,const_iterator>
|
std::pair<const_iterator,const_iterator>
|
||||||
equal_range(const key_type& __x) const
|
equal_range(const key_type& __x) const
|
||||||
{
|
{
|
||||||
typedef typename _Base::const_iterator _Base_const_iterator;
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
std::pair<_Base_const_iterator, _Base_const_iterator> __res =
|
return _Base::equal_range(__x);
|
||||||
_Base::equal_range(__x);
|
|
||||||
return std::make_pair(const_iterator(__res.first),
|
|
||||||
const_iterator(__res.second));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_Base&
|
_Base&
|
||||||
_M_base() _GLIBCXX_NOEXCEPT { return *this; }
|
_M_base() _GLIBCXX_NOEXCEPT { return *this; }
|
||||||
|
|
||||||
const _Base&
|
const _Base&
|
||||||
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
|
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
/** If hint is used we consider that the map and unordered_map
|
||||||
|
* operations have equivalent insertion cost so we do not update metrics
|
||||||
|
* about it.
|
||||||
|
* Note that to find out if hint has been used is libstdc++
|
||||||
|
* implementation dependant.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
_M_hint_used(const_iterator __hint, iterator __res)
|
||||||
|
{
|
||||||
|
return (__hint == __res ||
|
||||||
|
(__hint == this->end() && ++__res == this->end()) ||
|
||||||
|
(__hint != this->end() && (++__hint == __res ||
|
||||||
|
++__res == --__hint)));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename _Key, typename _Tp,
|
template<typename _Key, typename _Tp,
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,8 @@
|
||||||
#ifndef _GLIBCXX_PROFILE_MULTISET_H
|
#ifndef _GLIBCXX_PROFILE_MULTISET_H
|
||||||
#define _GLIBCXX_PROFILE_MULTISET_H 1
|
#define _GLIBCXX_PROFILE_MULTISET_H 1
|
||||||
|
|
||||||
#include <utility>
|
#include <profile/base.h>
|
||||||
|
#include <profile/ordered_base.h>
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
{
|
{
|
||||||
|
|
@ -39,38 +40,45 @@ namespace __profile
|
||||||
template<typename _Key, typename _Compare = std::less<_Key>,
|
template<typename _Key, typename _Compare = std::less<_Key>,
|
||||||
typename _Allocator = std::allocator<_Key> >
|
typename _Allocator = std::allocator<_Key> >
|
||||||
class multiset
|
class multiset
|
||||||
: public _GLIBCXX_STD_C::multiset<_Key, _Compare, _Allocator>
|
: public _GLIBCXX_STD_C::multiset<_Key, _Compare, _Allocator>,
|
||||||
|
public _Ordered_profile<multiset<_Key, _Compare, _Allocator> >
|
||||||
{
|
{
|
||||||
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;
|
||||||
typedef _Key value_type;
|
typedef _Key value_type;
|
||||||
typedef _Compare key_compare;
|
typedef _Compare key_compare;
|
||||||
typedef _Compare value_compare;
|
typedef _Compare value_compare;
|
||||||
typedef _Allocator allocator_type;
|
typedef _Allocator allocator_type;
|
||||||
typedef typename _Base::reference reference;
|
typedef typename _Base::reference reference;
|
||||||
typedef typename _Base::const_reference const_reference;
|
typedef typename _Base::const_reference const_reference;
|
||||||
|
|
||||||
typedef typename _Base::iterator iterator;
|
typedef typename _Base::iterator iterator;
|
||||||
typedef typename _Base::const_iterator const_iterator;
|
typedef typename _Base::const_iterator const_iterator;
|
||||||
typedef typename _Base::reverse_iterator reverse_iterator;
|
typedef typename _Base::reverse_iterator reverse_iterator;
|
||||||
typedef typename _Base::const_reverse_iterator const_reverse_iterator;
|
typedef typename _Base::const_reverse_iterator const_reverse_iterator;
|
||||||
|
|
||||||
typedef typename _Base::size_type size_type;
|
typedef typename _Base::size_type size_type;
|
||||||
typedef typename _Base::difference_type difference_type;
|
typedef typename _Base::difference_type difference_type;
|
||||||
typedef typename _Base::pointer pointer;
|
typedef typename _Base::pointer pointer;
|
||||||
typedef typename _Base::const_pointer const_pointer;
|
typedef typename _Base::const_pointer const_pointer;
|
||||||
|
|
||||||
// 23.3.3.1 construct/copy/destroy:
|
// 23.3.3.1 construct/copy/destroy:
|
||||||
|
|
||||||
|
#if __cplusplus < 201103L
|
||||||
multiset()
|
multiset()
|
||||||
: _Base() { }
|
: _Base() { }
|
||||||
|
multiset(const multiset& __x)
|
||||||
|
: _Base(__x) { }
|
||||||
|
~multiset() { }
|
||||||
|
#else
|
||||||
|
multiset() = default;
|
||||||
|
multiset(const multiset&) = default;
|
||||||
|
multiset(multiset&&) = default;
|
||||||
|
~multiset() = default;
|
||||||
|
#endif
|
||||||
|
|
||||||
explicit multiset(const _Compare& __comp,
|
explicit multiset(const _Compare& __comp,
|
||||||
const _Allocator& __a = _Allocator())
|
const _Allocator& __a = _Allocator())
|
||||||
|
|
@ -82,18 +90,12 @@ namespace __profile
|
||||||
#else
|
#else
|
||||||
template<typename _InputIterator>
|
template<typename _InputIterator>
|
||||||
#endif
|
#endif
|
||||||
multiset(_InputIterator __first, _InputIterator __last,
|
multiset(_InputIterator __first, _InputIterator __last,
|
||||||
const _Compare& __comp = _Compare(),
|
const _Compare& __comp = _Compare(),
|
||||||
const _Allocator& __a = _Allocator())
|
const _Allocator& __a = _Allocator())
|
||||||
: _Base(__first, __last, __comp, __a) { }
|
: _Base(__first, __last, __comp, __a) { }
|
||||||
|
|
||||||
#if __cplusplus < 201103L
|
#if __cplusplus >= 201103L
|
||||||
multiset(const multiset& __x)
|
|
||||||
: _Base(__x) { }
|
|
||||||
#else
|
|
||||||
multiset(const multiset&) = default;
|
|
||||||
multiset(multiset&&) = default;
|
|
||||||
|
|
||||||
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())
|
||||||
|
|
@ -101,30 +103,27 @@ namespace __profile
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
multiset(const allocator_type& __a)
|
multiset(const allocator_type& __a)
|
||||||
: _Base(__a) { }
|
: _Base(__a) { }
|
||||||
|
|
||||||
multiset(const multiset& __x, const allocator_type& __a)
|
multiset(const multiset& __x, const allocator_type& __a)
|
||||||
: _Base(__x, __a) { }
|
: _Base(__x, __a) { }
|
||||||
|
|
||||||
multiset(multiset&& __x, const allocator_type& __a)
|
multiset(multiset&& __x, const allocator_type& __a)
|
||||||
noexcept(is_nothrow_copy_constructible<_Compare>::value
|
noexcept( noexcept(_Base(std::move(__x), __a)) )
|
||||||
&& _Alloc_traits::_S_always_equal())
|
|
||||||
: _Base(std::move(__x), __a) { }
|
: _Base(std::move(__x), __a) { }
|
||||||
|
|
||||||
multiset(initializer_list<value_type> __l, const allocator_type& __a)
|
multiset(initializer_list<value_type> __l, const allocator_type& __a)
|
||||||
: _Base(__l, __a) { }
|
: _Base(__l, __a) { }
|
||||||
|
|
||||||
template<typename _InputIterator>
|
template<typename _InputIterator>
|
||||||
multiset(_InputIterator __first, _InputIterator __last,
|
multiset(_InputIterator __first, _InputIterator __last,
|
||||||
const allocator_type& __a)
|
const allocator_type& __a)
|
||||||
: _Base(__first, __last, __a) { }
|
: _Base(__first, __last, __a) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
multiset(const _Base& __x)
|
multiset(const _Base& __x)
|
||||||
: _Base(__x) { }
|
: _Base(__x) { }
|
||||||
|
|
||||||
~multiset() _GLIBCXX_NOEXCEPT { }
|
|
||||||
|
|
||||||
#if __cplusplus < 201103L
|
#if __cplusplus < 201103L
|
||||||
multiset&
|
multiset&
|
||||||
operator=(const multiset& __x)
|
operator=(const multiset& __x)
|
||||||
|
|
@ -147,98 +146,112 @@ namespace __profile
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using _Base::get_allocator;
|
|
||||||
|
|
||||||
// iterators:
|
// iterators:
|
||||||
iterator
|
|
||||||
begin() _GLIBCXX_NOEXCEPT
|
|
||||||
{ return iterator(_Base::begin()); }
|
|
||||||
|
|
||||||
const_iterator
|
|
||||||
begin() const _GLIBCXX_NOEXCEPT
|
|
||||||
{ return const_iterator(_Base::begin()); }
|
|
||||||
|
|
||||||
iterator
|
|
||||||
end() _GLIBCXX_NOEXCEPT
|
|
||||||
{ return iterator(_Base::end()); }
|
|
||||||
|
|
||||||
const_iterator
|
|
||||||
end() const _GLIBCXX_NOEXCEPT
|
|
||||||
{ return const_iterator(_Base::end()); }
|
|
||||||
|
|
||||||
reverse_iterator
|
reverse_iterator
|
||||||
rbegin() _GLIBCXX_NOEXCEPT
|
rbegin() _GLIBCXX_NOEXCEPT
|
||||||
{ return reverse_iterator(end()); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::rbegin();
|
||||||
|
}
|
||||||
|
|
||||||
const_reverse_iterator
|
const_reverse_iterator
|
||||||
rbegin() const _GLIBCXX_NOEXCEPT
|
rbegin() const _GLIBCXX_NOEXCEPT
|
||||||
{ return const_reverse_iterator(end()); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::rbegin();
|
||||||
|
}
|
||||||
|
|
||||||
reverse_iterator
|
reverse_iterator
|
||||||
rend() _GLIBCXX_NOEXCEPT
|
rend() _GLIBCXX_NOEXCEPT
|
||||||
{ return reverse_iterator(begin()); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::rend();
|
||||||
|
}
|
||||||
|
|
||||||
const_reverse_iterator
|
const_reverse_iterator
|
||||||
rend() const _GLIBCXX_NOEXCEPT
|
rend() const _GLIBCXX_NOEXCEPT
|
||||||
{ return const_reverse_iterator(begin()); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::rend();
|
||||||
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
const_iterator
|
|
||||||
cbegin() const noexcept
|
|
||||||
{ return const_iterator(_Base::begin()); }
|
|
||||||
|
|
||||||
const_iterator
|
|
||||||
cend() const noexcept
|
|
||||||
{ return const_iterator(_Base::end()); }
|
|
||||||
|
|
||||||
const_reverse_iterator
|
const_reverse_iterator
|
||||||
crbegin() const noexcept
|
crbegin() const noexcept
|
||||||
{ return const_reverse_iterator(end()); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::crbegin();
|
||||||
|
}
|
||||||
|
|
||||||
const_reverse_iterator
|
const_reverse_iterator
|
||||||
crend() const noexcept
|
crend() const noexcept
|
||||||
{ return const_reverse_iterator(begin()); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::crend();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// capacity:
|
|
||||||
using _Base::empty;
|
|
||||||
using _Base::size;
|
|
||||||
using _Base::max_size;
|
|
||||||
|
|
||||||
// modifiers:
|
// modifiers:
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
template<typename... _Args>
|
template<typename... _Args>
|
||||||
iterator
|
iterator
|
||||||
emplace(_Args&&... __args)
|
emplace(_Args&&... __args)
|
||||||
{ return iterator(_Base::emplace(std::forward<_Args>(__args)...)); }
|
{
|
||||||
|
// The cost is the same whether or not the element is inserted so we
|
||||||
|
// always report insertion of 1 element.
|
||||||
|
__profcxx_map_to_unordered_map_insert(this, this->size(), 1);
|
||||||
|
return _Base::emplace(std::forward<_Args>(__args)...);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename... _Args>
|
template<typename... _Args>
|
||||||
iterator
|
iterator
|
||||||
emplace_hint(const_iterator __pos, _Args&&... __args)
|
emplace_hint(const_iterator __pos, _Args&&... __args)
|
||||||
{
|
{
|
||||||
return iterator(_Base::emplace_hint(__pos,
|
auto size_before = this->size();
|
||||||
std::forward<_Args>(__args)...));
|
auto __res = _Base::emplace_hint(__pos, std::forward<_Args>(__args)...);
|
||||||
|
__profcxx_map_to_unordered_map_insert(this, size_before,
|
||||||
|
_M_hint_used(__pos, __res) ? 0 : 1);
|
||||||
|
return __res;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
insert(const value_type& __x)
|
insert(const value_type& __x)
|
||||||
{ return iterator(_Base::insert(__x)); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_insert(this, this->size(), 1);
|
||||||
|
return _Base::insert(__x);
|
||||||
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
iterator
|
iterator
|
||||||
insert(value_type&& __x)
|
insert(value_type&& __x)
|
||||||
{ return iterator(_Base::insert(std::move(__x))); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_insert(this, this->size(), 1);
|
||||||
|
return _Base::insert(std::move(__x));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
insert(const_iterator __position, const value_type& __x)
|
insert(const_iterator __pos, const value_type& __x)
|
||||||
{ return iterator(_Base::insert(__position, __x)); }
|
{
|
||||||
|
size_type size_before = this->size();
|
||||||
|
iterator __res = _Base::insert(__pos, __x);
|
||||||
|
|
||||||
|
__profcxx_map_to_unordered_map_insert(this, size_before,
|
||||||
|
_M_hint_used(__pos, __res) ? 0 : 1);
|
||||||
|
return __res;
|
||||||
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
iterator
|
iterator
|
||||||
insert(const_iterator __position, value_type&& __x)
|
insert(const_iterator __pos, value_type&& __x)
|
||||||
{ return iterator(_Base::insert(__position, std::move(__x))); }
|
{
|
||||||
|
auto size_before = this->size();
|
||||||
|
auto __res = _Base::insert(__pos, std::move(__x));
|
||||||
|
__profcxx_map_to_unordered_map_insert(this, size_before,
|
||||||
|
_M_hint_used(__pos, __res) ? 0 : 1);
|
||||||
|
return __res;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
|
|
@ -247,106 +260,137 @@ namespace __profile
|
||||||
#else
|
#else
|
||||||
template<typename _InputIterator>
|
template<typename _InputIterator>
|
||||||
#endif
|
#endif
|
||||||
void
|
void
|
||||||
insert(_InputIterator __first, _InputIterator __last)
|
insert(_InputIterator __first, _InputIterator __last)
|
||||||
{ _Base::insert(__first, __last); }
|
{
|
||||||
|
for (; __first != __last; ++__first)
|
||||||
|
insert(*__first);
|
||||||
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
void
|
void
|
||||||
insert(initializer_list<value_type> __l)
|
insert(initializer_list<value_type> __l)
|
||||||
{ _Base::insert(__l); }
|
{ insert(__l.begin(), __l.end()); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
iterator
|
iterator
|
||||||
erase(const_iterator __position)
|
erase(const_iterator __pos)
|
||||||
{ return iterator(_Base::erase(__position)); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
|
||||||
|
return _Base::erase(__pos);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
void
|
void
|
||||||
erase(iterator __position)
|
erase(iterator __pos)
|
||||||
{ _Base::erase(__position); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
|
||||||
|
_Base::erase(__pos);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
size_type
|
size_type
|
||||||
erase(const key_type& __x)
|
erase(const key_type& __x)
|
||||||
{
|
{
|
||||||
std::pair<iterator, iterator> __victims = this->equal_range(__x);
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
size_type __count = 0;
|
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
|
||||||
while (__victims.first != __victims.second)
|
return _Base::erase(__x);
|
||||||
{
|
|
||||||
iterator __victim = __victims.first++;
|
|
||||||
_Base::erase(__victim);
|
|
||||||
++__count;
|
|
||||||
}
|
|
||||||
return __count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
iterator
|
iterator
|
||||||
erase(const_iterator __first, const_iterator __last)
|
erase(const_iterator __first, const_iterator __last)
|
||||||
{ return iterator(_Base::erase(__first, __last)); }
|
{
|
||||||
|
if (__first != __last)
|
||||||
|
{
|
||||||
|
iterator __ret;
|
||||||
|
for (; __first != __last;)
|
||||||
|
__ret = erase(__first++);
|
||||||
|
return __ret;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return _Base::erase(__first, __last);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
void
|
void
|
||||||
erase(iterator __first, iterator __last)
|
erase(iterator __first, iterator __last)
|
||||||
{ _Base::erase(__first, __last); }
|
{
|
||||||
|
for (; __first != __last;)
|
||||||
|
erase(__first++);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
swap(multiset& __x)
|
swap(multiset& __x)
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
noexcept(_Alloc_traits::_S_nothrow_swap())
|
noexcept( noexcept(declval<_Base>().swap(__x)) )
|
||||||
#endif
|
#endif
|
||||||
{ _Base::swap(__x); }
|
{ _Base::swap(__x); }
|
||||||
|
|
||||||
void
|
|
||||||
clear() _GLIBCXX_NOEXCEPT
|
|
||||||
{ this->erase(begin(), end()); }
|
|
||||||
|
|
||||||
// observers:
|
|
||||||
using _Base::key_comp;
|
|
||||||
using _Base::value_comp;
|
|
||||||
|
|
||||||
// multiset operations:
|
// multiset operations:
|
||||||
iterator
|
iterator
|
||||||
find(const key_type& __x)
|
find(const key_type& __x)
|
||||||
{ return iterator(_Base::find(__x)); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
|
return _Base::find(__x);
|
||||||
|
}
|
||||||
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||||
// 214. set::find() missing const overload
|
// 214. set::find() missing const overload
|
||||||
const_iterator
|
const_iterator
|
||||||
find(const key_type& __x) const
|
find(const key_type& __x) const
|
||||||
{ return const_iterator(_Base::find(__x)); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
|
return _Base::find(__x);
|
||||||
|
}
|
||||||
|
|
||||||
using _Base::count;
|
size_type
|
||||||
|
count(const key_type& __x) const
|
||||||
|
{
|
||||||
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
|
return _Base::count(__x);
|
||||||
|
}
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
lower_bound(const key_type& __x)
|
lower_bound(const key_type& __x)
|
||||||
{ return iterator(_Base::lower_bound(__x)); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
|
return _Base::lower_bound(__x);
|
||||||
|
}
|
||||||
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||||
// 214. set::find() missing const overload
|
// 214. set::find() missing const overload
|
||||||
const_iterator
|
const_iterator
|
||||||
lower_bound(const key_type& __x) const
|
lower_bound(const key_type& __x) const
|
||||||
{ return const_iterator(_Base::lower_bound(__x)); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::lower_bound(__x);
|
||||||
|
}
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
upper_bound(const key_type& __x)
|
upper_bound(const key_type& __x)
|
||||||
{ return iterator(_Base::upper_bound(__x)); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::upper_bound(__x);
|
||||||
|
}
|
||||||
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||||
// 214. set::find() missing const overload
|
// 214. set::find() missing const overload
|
||||||
const_iterator
|
const_iterator
|
||||||
upper_bound(const key_type& __x) const
|
upper_bound(const key_type& __x) const
|
||||||
{ return const_iterator(_Base::upper_bound(__x)); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::upper_bound(__x);
|
||||||
|
}
|
||||||
|
|
||||||
std::pair<iterator,iterator>
|
std::pair<iterator,iterator>
|
||||||
equal_range(const key_type& __x)
|
equal_range(const key_type& __x)
|
||||||
{
|
{
|
||||||
typedef typename _Base::iterator _Base_iterator;
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
std::pair<_Base_iterator, _Base_iterator> __res =
|
return _Base::equal_range(__x);
|
||||||
_Base::equal_range(__x);
|
|
||||||
return std::make_pair(iterator(__res.first),
|
|
||||||
iterator(__res.second));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||||
|
|
@ -354,19 +398,31 @@ namespace __profile
|
||||||
std::pair<const_iterator,const_iterator>
|
std::pair<const_iterator,const_iterator>
|
||||||
equal_range(const key_type& __x) const
|
equal_range(const key_type& __x) const
|
||||||
{
|
{
|
||||||
typedef typename _Base::const_iterator _Base_iterator;
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
std::pair<_Base_iterator, _Base_iterator> __res =
|
return _Base::equal_range(__x);
|
||||||
_Base::equal_range(__x);
|
|
||||||
return std::make_pair(const_iterator(__res.first),
|
|
||||||
const_iterator(__res.second));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_Base&
|
_Base&
|
||||||
_M_base() _GLIBCXX_NOEXCEPT { return *this; }
|
_M_base() _GLIBCXX_NOEXCEPT { return *this; }
|
||||||
|
|
||||||
const _Base&
|
const _Base&
|
||||||
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
|
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
/** If hint is used we consider that the map and unordered_map
|
||||||
|
* operations have equivalent insertion cost so we do not update metrics
|
||||||
|
* about it.
|
||||||
|
* Note that to find out if hint has been used is libstdc++
|
||||||
|
* implementation dependant.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
_M_hint_used(const_iterator __hint, iterator __res)
|
||||||
|
{
|
||||||
|
return (__hint == __res ||
|
||||||
|
(__hint == this->end() && ++__res == this->end()) ||
|
||||||
|
(__hint != this->end() && (++__hint == __res ||
|
||||||
|
++__res == --__hint)));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename _Key, typename _Compare, typename _Allocator>
|
template<typename _Key, typename _Compare, typename _Allocator>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
// Profiling unordered containers implementation details -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2014 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License along
|
||||||
|
// with this library; see the file COPYING3. If not see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file profile/ordered_base.h
|
||||||
|
* This file is a GNU profile extension to the Standard C++ Library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_PROFILE_ORDERED
|
||||||
|
#define _GLIBCXX_PROFILE_ORDERED 1
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
namespace __profile
|
||||||
|
{
|
||||||
|
template<typename _Cont>
|
||||||
|
class _Ordered_profile
|
||||||
|
{
|
||||||
|
_Cont&
|
||||||
|
_M_conjure()
|
||||||
|
{ return *static_cast<_Cont*>(this); }
|
||||||
|
|
||||||
|
public:
|
||||||
|
_Ordered_profile() _GLIBCXX_NOEXCEPT
|
||||||
|
{ __profcxx_map_to_unordered_map_construct(&_M_conjure()); }
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
|
_Ordered_profile(const _Ordered_profile&) noexcept
|
||||||
|
: _Ordered_profile() { }
|
||||||
|
_Ordered_profile(_Ordered_profile&&) noexcept
|
||||||
|
: _Ordered_profile() { }
|
||||||
|
|
||||||
|
_Ordered_profile&
|
||||||
|
operator=(const _Ordered_profile&) = default;
|
||||||
|
_Ordered_profile&
|
||||||
|
operator=(_Ordered_profile&&) = default;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
~_Ordered_profile()
|
||||||
|
{ __profcxx_map_to_unordered_map_destruct(&_M_conjure()); }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace __profile
|
||||||
|
} // namespace std
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -29,9 +29,10 @@
|
||||||
#ifndef _GLIBCXX_PROFILE_SET_H
|
#ifndef _GLIBCXX_PROFILE_SET_H
|
||||||
#define _GLIBCXX_PROFILE_SET_H 1
|
#define _GLIBCXX_PROFILE_SET_H 1
|
||||||
|
|
||||||
#include <utility>
|
#include <profile/base.h>
|
||||||
|
#include <profile/ordered_base.h>
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
{
|
{
|
||||||
namespace __profile
|
namespace __profile
|
||||||
{
|
{
|
||||||
|
|
@ -39,7 +40,8 @@ namespace __profile
|
||||||
template<typename _Key, typename _Compare = std::less<_Key>,
|
template<typename _Key, typename _Compare = std::less<_Key>,
|
||||||
typename _Allocator = std::allocator<_Key> >
|
typename _Allocator = std::allocator<_Key> >
|
||||||
class set
|
class set
|
||||||
: public _GLIBCXX_STD_C::set<_Key,_Compare,_Allocator>
|
: public _GLIBCXX_STD_C::set<_Key,_Compare,_Allocator>,
|
||||||
|
public _Ordered_profile<set<_Key, _Compare, _Allocator> >
|
||||||
{
|
{
|
||||||
typedef _GLIBCXX_STD_C::set<_Key, _Compare, _Allocator> _Base;
|
typedef _GLIBCXX_STD_C::set<_Key, _Compare, _Allocator> _Base;
|
||||||
|
|
||||||
|
|
@ -49,28 +51,36 @@ namespace __profile
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// types:
|
// types:
|
||||||
typedef _Key key_type;
|
typedef _Key key_type;
|
||||||
typedef _Key value_type;
|
typedef _Key value_type;
|
||||||
typedef _Compare key_compare;
|
typedef _Compare key_compare;
|
||||||
typedef _Compare value_compare;
|
typedef _Compare value_compare;
|
||||||
typedef _Allocator allocator_type;
|
typedef typename _Base::reference reference;
|
||||||
typedef typename _Base::reference reference;
|
typedef typename _Base::const_reference const_reference;
|
||||||
typedef typename _Base::const_reference const_reference;
|
|
||||||
|
|
||||||
typedef typename _Base::iterator iterator;
|
typedef typename _Base::iterator iterator;
|
||||||
typedef typename _Base::const_iterator const_iterator;
|
typedef typename _Base::const_iterator const_iterator;
|
||||||
typedef typename _Base::reverse_iterator reverse_iterator;
|
typedef typename _Base::reverse_iterator reverse_iterator;
|
||||||
typedef typename _Base::const_reverse_iterator const_reverse_iterator;
|
typedef typename _Base::const_reverse_iterator const_reverse_iterator;
|
||||||
|
|
||||||
typedef typename _Base::size_type size_type;
|
typedef typename _Base::size_type size_type;
|
||||||
typedef typename _Base::difference_type difference_type;
|
typedef typename _Base::difference_type difference_type;
|
||||||
typedef typename _Base::pointer pointer;
|
typedef typename _Base::pointer pointer;
|
||||||
typedef typename _Base::const_pointer const_pointer;
|
typedef typename _Base::const_pointer const_pointer;
|
||||||
|
|
||||||
// 23.3.3.1 construct/copy/destroy:
|
// 23.3.3.1 construct/copy/destroy:
|
||||||
|
#if __cplusplus < 201103L
|
||||||
set()
|
set()
|
||||||
: _Base() { }
|
: _Base() { }
|
||||||
|
set(const set& __x)
|
||||||
|
: _Base(__x) { }
|
||||||
|
~set() { }
|
||||||
|
#else
|
||||||
|
set() = default;
|
||||||
|
set(const set&) = default;
|
||||||
|
set(set&&) = default;
|
||||||
|
~set() = default;
|
||||||
|
#endif
|
||||||
|
|
||||||
explicit set(const _Compare& __comp,
|
explicit set(const _Compare& __comp,
|
||||||
const _Allocator& __a = _Allocator())
|
const _Allocator& __a = _Allocator())
|
||||||
|
|
@ -82,49 +92,40 @@ namespace __profile
|
||||||
#else
|
#else
|
||||||
template<typename _InputIterator>
|
template<typename _InputIterator>
|
||||||
#endif
|
#endif
|
||||||
set(_InputIterator __first, _InputIterator __last,
|
set(_InputIterator __first, _InputIterator __last,
|
||||||
const _Compare& __comp = _Compare(),
|
const _Compare& __comp = _Compare(),
|
||||||
const _Allocator& __a = _Allocator())
|
const _Allocator& __a = _Allocator())
|
||||||
: _Base(__first, __last, __comp, __a) { }
|
: _Base(__first, __last, __comp, __a) { }
|
||||||
|
|
||||||
#if __cplusplus < 201103L
|
#if __cplusplus >= 201103L
|
||||||
set(const set& __x)
|
|
||||||
: _Base(__x) { }
|
|
||||||
#else
|
|
||||||
set(const set&) = default;
|
|
||||||
set(set&&) = default;
|
|
||||||
|
|
||||||
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& __a = _Allocator())
|
||||||
: _Base(__l, __comp, __a) { }
|
: _Base(__l, __comp, __a) { }
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
set(const allocator_type& __a)
|
set(const _Allocator& __a)
|
||||||
: _Base(__a) { }
|
: _Base(__a) { }
|
||||||
|
|
||||||
set(const set& __x, const allocator_type& __a)
|
set(const set& __x, const _Allocator& __a)
|
||||||
: _Base(__x, __a) { }
|
: _Base(__x, __a) { }
|
||||||
|
|
||||||
set(set&& __x, const allocator_type& __a)
|
set(set&& __x, const _Allocator& __a)
|
||||||
noexcept(is_nothrow_copy_constructible<_Compare>::value
|
noexcept( noexcept(_Base(std::move(__x), __a)) )
|
||||||
&& _Alloc_traits::_S_always_equal())
|
|
||||||
: _Base(std::move(__x), __a) { }
|
: _Base(std::move(__x), __a) { }
|
||||||
|
|
||||||
set(initializer_list<value_type> __l, const allocator_type& __a)
|
set(initializer_list<value_type> __l, const _Allocator& __a)
|
||||||
: _Base(__l, __a) { }
|
: _Base(__l, __a) { }
|
||||||
|
|
||||||
template<typename _InputIterator>
|
template<typename _InputIterator>
|
||||||
set(_InputIterator __first, _InputIterator __last,
|
set(_InputIterator __first, _InputIterator __last,
|
||||||
const allocator_type& __a)
|
const _Allocator& __a)
|
||||||
: _Base(__first, __last, __a) { }
|
: _Base(__first, __last, __a) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
set(const _Base& __x)
|
set(const _Base& __x)
|
||||||
: _Base(__x) { }
|
: _Base(__x) { }
|
||||||
|
|
||||||
~set() _GLIBCXX_NOEXCEPT { }
|
|
||||||
|
|
||||||
#if __cplusplus < 201103L
|
#if __cplusplus < 201103L
|
||||||
set&
|
set&
|
||||||
operator=(const set& __x)
|
operator=(const set& __x)
|
||||||
|
|
@ -147,108 +148,98 @@ namespace __profile
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using _Base::get_allocator;
|
|
||||||
|
|
||||||
// iterators:
|
|
||||||
iterator
|
|
||||||
begin() _GLIBCXX_NOEXCEPT
|
|
||||||
{ return iterator(_Base::begin()); }
|
|
||||||
|
|
||||||
const_iterator
|
|
||||||
begin() const _GLIBCXX_NOEXCEPT
|
|
||||||
{ return const_iterator(_Base::begin()); }
|
|
||||||
|
|
||||||
iterator
|
|
||||||
end() _GLIBCXX_NOEXCEPT
|
|
||||||
{ return iterator(_Base::end()); }
|
|
||||||
|
|
||||||
const_iterator
|
|
||||||
end() const _GLIBCXX_NOEXCEPT
|
|
||||||
{ return const_iterator(_Base::end()); }
|
|
||||||
|
|
||||||
reverse_iterator
|
reverse_iterator
|
||||||
rbegin() _GLIBCXX_NOEXCEPT
|
rbegin() _GLIBCXX_NOEXCEPT
|
||||||
{ return reverse_iterator(end()); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::rbegin();
|
||||||
|
}
|
||||||
|
|
||||||
const_reverse_iterator
|
const_reverse_iterator
|
||||||
rbegin() const _GLIBCXX_NOEXCEPT
|
rbegin() const _GLIBCXX_NOEXCEPT
|
||||||
{ return const_reverse_iterator(end()); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::rbegin();
|
||||||
|
}
|
||||||
|
|
||||||
reverse_iterator
|
reverse_iterator
|
||||||
rend() _GLIBCXX_NOEXCEPT
|
rend() _GLIBCXX_NOEXCEPT
|
||||||
{ return reverse_iterator(begin()); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::rend();
|
||||||
|
}
|
||||||
|
|
||||||
const_reverse_iterator
|
const_reverse_iterator
|
||||||
rend() const _GLIBCXX_NOEXCEPT
|
rend() const _GLIBCXX_NOEXCEPT
|
||||||
{ return const_reverse_iterator(begin()); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::rend();
|
||||||
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
const_iterator
|
|
||||||
cbegin() const noexcept
|
|
||||||
{ return const_iterator(_Base::begin()); }
|
|
||||||
|
|
||||||
const_iterator
|
|
||||||
cend() const noexcept
|
|
||||||
{ return const_iterator(_Base::end()); }
|
|
||||||
|
|
||||||
const_reverse_iterator
|
const_reverse_iterator
|
||||||
crbegin() const noexcept
|
crbegin() const noexcept
|
||||||
{ return const_reverse_iterator(end()); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::crbegin();
|
||||||
|
}
|
||||||
|
|
||||||
const_reverse_iterator
|
const_reverse_iterator
|
||||||
crend() const noexcept
|
crend() const noexcept
|
||||||
{ return const_reverse_iterator(begin()); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::crend();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// capacity:
|
|
||||||
using _Base::empty;
|
|
||||||
using _Base::size;
|
|
||||||
using _Base::max_size;
|
|
||||||
|
|
||||||
// modifiers:
|
// modifiers:
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
template<typename... _Args>
|
template<typename... _Args>
|
||||||
std::pair<iterator, bool>
|
std::pair<iterator, bool>
|
||||||
emplace(_Args&&... __args)
|
emplace(_Args&&... __args)
|
||||||
{
|
{
|
||||||
auto __res = _Base::emplace(std::forward<_Args>(__args)...);
|
__profcxx_map_to_unordered_map_insert(this, this->size(), 1);
|
||||||
return std::pair<iterator, bool>(iterator(__res.first),
|
return _Base::emplace(std::forward<_Args>(__args)...);
|
||||||
__res.second);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... _Args>
|
template<typename... _Args>
|
||||||
iterator
|
iterator
|
||||||
emplace_hint(const_iterator __pos, _Args&&... __args)
|
emplace_hint(const_iterator __pos, _Args&&... __args)
|
||||||
{
|
{
|
||||||
return iterator(_Base::emplace_hint(__pos,
|
auto size_before = this->size();
|
||||||
std::forward<_Args>(__args)...));
|
auto __res
|
||||||
|
= _Base::emplace_hint(__pos, std::forward<_Args>(__args)...);
|
||||||
|
__profcxx_map_to_unordered_map_insert(this, size_before,
|
||||||
|
_M_hint_used(__pos, __res) ? 0 : 1);
|
||||||
|
return __res;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::pair<iterator, bool>
|
std::pair<iterator, bool>
|
||||||
insert(const value_type& __x)
|
insert(const value_type& __x)
|
||||||
{
|
{
|
||||||
typedef typename _Base::iterator _Base_iterator;
|
__profcxx_map_to_unordered_map_insert(this, this->size(), 1);
|
||||||
std::pair<_Base_iterator, bool> __res = _Base::insert(__x);
|
return _Base::insert(__x);
|
||||||
return std::pair<iterator, bool>(iterator(__res.first),
|
|
||||||
__res.second);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
std::pair<iterator, bool>
|
std::pair<iterator, bool>
|
||||||
insert(value_type&& __x)
|
insert(value_type&& __x)
|
||||||
{
|
{
|
||||||
typedef typename _Base::iterator _Base_iterator;
|
__profcxx_map_to_unordered_map_insert(this, this->size(), 1);
|
||||||
std::pair<_Base_iterator, bool> __res
|
return _Base::insert(std::move(__x));
|
||||||
= _Base::insert(std::move(__x));
|
|
||||||
return std::pair<iterator, bool>(iterator(__res.first),
|
|
||||||
__res.second);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
insert(const_iterator __position, const value_type& __x)
|
insert(const_iterator __pos, const value_type& __x)
|
||||||
{ return iterator(_Base::insert(__position, __x)); }
|
{
|
||||||
|
size_type size_before = this->size();
|
||||||
|
iterator __res = _Base::insert(__pos, __x);
|
||||||
|
__profcxx_map_to_unordered_map_insert(this, size_before,
|
||||||
|
_M_hint_used(__pos, __res) ? 0 : 1);
|
||||||
|
return __res;
|
||||||
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
iterator
|
iterator
|
||||||
|
|
@ -262,125 +253,162 @@ namespace __profile
|
||||||
#else
|
#else
|
||||||
template<typename _InputIterator>
|
template<typename _InputIterator>
|
||||||
#endif
|
#endif
|
||||||
void
|
void
|
||||||
insert(_InputIterator __first, _InputIterator __last)
|
insert(_InputIterator __first, _InputIterator __last)
|
||||||
{ _Base::insert(__first, __last); }
|
{
|
||||||
|
for (; __first != __last; ++__first)
|
||||||
|
insert(*__first);
|
||||||
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
void
|
void
|
||||||
insert(initializer_list<value_type> __l)
|
insert(initializer_list<value_type> __l)
|
||||||
{ _Base::insert(__l); }
|
{ insert(__l.begin(), __l.end()); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
iterator
|
iterator
|
||||||
erase(const_iterator __position)
|
erase(const_iterator __pos)
|
||||||
{ return iterator(_Base::erase(__position)); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
|
||||||
|
return _Base::erase(__pos);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
void
|
void
|
||||||
erase(iterator __position)
|
erase(iterator __pos)
|
||||||
{ _Base::erase(__position); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
|
||||||
|
_Base::erase(__pos);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
size_type
|
size_type
|
||||||
erase(const key_type& __x)
|
erase(const key_type& __x)
|
||||||
{
|
{
|
||||||
iterator __victim = find(__x);
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
if (__victim == end())
|
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
|
||||||
return 0;
|
return _Base::erase(__x);
|
||||||
else
|
|
||||||
{
|
|
||||||
_Base::erase(__victim);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
iterator
|
iterator
|
||||||
erase(const_iterator __first, const_iterator __last)
|
erase(const_iterator __first, const_iterator __last)
|
||||||
{ return iterator(_Base::erase(__first, __last)); }
|
{
|
||||||
|
if (__first != __last)
|
||||||
|
{
|
||||||
|
iterator __ret;
|
||||||
|
for (; __first != __last;)
|
||||||
|
__ret = erase(__first++);
|
||||||
|
return __ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _Base::erase(__first, __last);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
void
|
void
|
||||||
erase(iterator __first, iterator __last)
|
erase(iterator __first, iterator __last)
|
||||||
{ _Base::erase(__first, __last); }
|
{
|
||||||
|
for (; __first != __last;)
|
||||||
|
erase(__first++);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
swap(set& __x)
|
swap(set& __x)
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
noexcept(_Alloc_traits::_S_nothrow_swap())
|
noexcept( noexcept(declval<_Base>().swap(__x)) )
|
||||||
#endif
|
#endif
|
||||||
{ _Base::swap(__x); }
|
{ _Base::swap(__x); }
|
||||||
|
|
||||||
void
|
|
||||||
clear() _GLIBCXX_NOEXCEPT
|
|
||||||
{ this->erase(begin(), end()); }
|
|
||||||
|
|
||||||
// observers:
|
|
||||||
using _Base::key_comp;
|
|
||||||
using _Base::value_comp;
|
|
||||||
|
|
||||||
// set operations:
|
// set operations:
|
||||||
iterator
|
iterator
|
||||||
find(const key_type& __x)
|
find(const key_type& __x)
|
||||||
{ return iterator(_Base::find(__x)); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
|
return _Base::find(__x);
|
||||||
|
}
|
||||||
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 214. set::find() missing const overload
|
|
||||||
const_iterator
|
const_iterator
|
||||||
find(const key_type& __x) const
|
find(const key_type& __x) const
|
||||||
{ return const_iterator(_Base::find(__x)); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
|
return _Base::find(__x);
|
||||||
|
}
|
||||||
|
|
||||||
using _Base::count;
|
size_type
|
||||||
|
count(const key_type& __x) const
|
||||||
|
{
|
||||||
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
|
return _Base::count(__x);
|
||||||
|
}
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
lower_bound(const key_type& __x)
|
lower_bound(const key_type& __x)
|
||||||
{ return iterator(_Base::lower_bound(__x)); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::lower_bound(__x);
|
||||||
|
}
|
||||||
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 214. set::find() missing const overload
|
|
||||||
const_iterator
|
const_iterator
|
||||||
lower_bound(const key_type& __x) const
|
lower_bound(const key_type& __x) const
|
||||||
{ return const_iterator(_Base::lower_bound(__x)); }
|
{
|
||||||
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::lower_bound(__x);
|
||||||
|
}
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
upper_bound(const key_type& __x)
|
upper_bound(const key_type& __x)
|
||||||
{ return iterator(_Base::upper_bound(__x)); }
|
|
||||||
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 214. set::find() missing const overload
|
|
||||||
const_iterator
|
|
||||||
upper_bound(const key_type& __x) const
|
|
||||||
{ return const_iterator(_Base::upper_bound(__x)); }
|
|
||||||
|
|
||||||
std::pair<iterator,iterator>
|
|
||||||
equal_range(const key_type& __x)
|
|
||||||
{
|
{
|
||||||
typedef typename _Base::iterator _Base_iterator;
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
std::pair<_Base_iterator, _Base_iterator> __res =
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
_Base::equal_range(__x);
|
return _Base::upper_bound(__x);
|
||||||
return std::make_pair(iterator(__res.first),
|
|
||||||
iterator(__res.second));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
const_iterator
|
||||||
// 214. set::find() missing const overload
|
upper_bound(const key_type& __x) const
|
||||||
std::pair<const_iterator,const_iterator>
|
{
|
||||||
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
|
__profcxx_map_to_unordered_map_invalidate(this);
|
||||||
|
return _Base::upper_bound(__x);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::pair<iterator, iterator>
|
||||||
|
equal_range(const key_type& __x)
|
||||||
|
{
|
||||||
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
|
return _Base::equal_range(__x);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::pair<const_iterator, const_iterator>
|
||||||
equal_range(const key_type& __x) const
|
equal_range(const key_type& __x) const
|
||||||
{
|
{
|
||||||
typedef typename _Base::const_iterator _Base_iterator;
|
__profcxx_map_to_unordered_map_find(this, this->size());
|
||||||
std::pair<_Base_iterator, _Base_iterator> __res =
|
return _Base::equal_range(__x);
|
||||||
_Base::equal_range(__x);
|
|
||||||
return std::make_pair(const_iterator(__res.first),
|
|
||||||
const_iterator(__res.second));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_Base&
|
_Base&
|
||||||
_M_base() _GLIBCXX_NOEXCEPT { return *this; }
|
_M_base() _GLIBCXX_NOEXCEPT { return *this; }
|
||||||
|
|
||||||
const _Base&
|
const _Base&
|
||||||
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
|
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
/** If hint is used we consider that the map and unordered_map
|
||||||
|
* operations have equivalent insertion cost so we do not update metrics
|
||||||
|
* about it.
|
||||||
|
* Note that to find out if hint has been used is libstdc++
|
||||||
|
* implementation dependant.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
_M_hint_used(const_iterator __hint, iterator __res)
|
||||||
|
{
|
||||||
|
return (__hint == __res ||
|
||||||
|
(__hint == this->end() && ++__res == this->end()) ||
|
||||||
|
(__hint != this->end() && (++__hint == __res ||
|
||||||
|
++__res == --__hint)));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename _Key, typename _Compare, typename _Allocator>
|
template<typename _Key, typename _Compare, typename _Allocator>
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ namespace __profile
|
||||||
_Unordered_profile()
|
_Unordered_profile()
|
||||||
{
|
{
|
||||||
auto& __uc = _M_conjure();
|
auto& __uc = _M_conjure();
|
||||||
__profcxx_hashtable_construct(&__uc, __uc.bucket_count());
|
__profcxx_hashtable_construct(&__uc, __uc.bucket_count());
|
||||||
__profcxx_hashtable_construct2(&__uc);
|
__profcxx_hashtable_construct2(&__uc);
|
||||||
}
|
}
|
||||||
_Unordered_profile(const _Unordered_profile&)
|
_Unordered_profile(const _Unordered_profile&)
|
||||||
|
|
@ -168,8 +168,8 @@ namespace __profile
|
||||||
~_Unordered_profile() noexcept
|
~_Unordered_profile() noexcept
|
||||||
{
|
{
|
||||||
auto& __uc = _M_conjure();
|
auto& __uc = _M_conjure();
|
||||||
__profcxx_hashtable_destruct(&__uc, __uc.bucket_count(), __uc.size());
|
__profcxx_hashtable_destruct(&__uc, __uc.bucket_count(), __uc.size());
|
||||||
_M_profile_destruct();
|
_M_profile_destruct();
|
||||||
}
|
}
|
||||||
|
|
||||||
_Unordered_profile&
|
_Unordered_profile&
|
||||||
|
|
@ -210,6 +210,7 @@ namespace __profile
|
||||||
auto __lend = __uc.end(__bkt);
|
auto __lend = __uc.end(__bkt);
|
||||||
for (++__it, ++__lit; __lit != __lend; ++__it, ++__lit)
|
for (++__it, ++__lit; __lit != __lend; ++__it, ++__lit)
|
||||||
++__chain;
|
++__chain;
|
||||||
|
|
||||||
if (__chain)
|
if (__chain)
|
||||||
{
|
{
|
||||||
++__chain;
|
++__chain;
|
||||||
|
|
@ -245,6 +246,7 @@ namespace __profile
|
||||||
__pit = __it;
|
__pit = __it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__chain)
|
if (__chain)
|
||||||
{
|
{
|
||||||
++__chain;
|
++__chain;
|
||||||
|
|
|
||||||
|
|
@ -56,73 +56,66 @@ namespace __profile
|
||||||
typedef typename _GLIBCXX_STD_BASE _Base;
|
typedef typename _GLIBCXX_STD_BASE _Base;
|
||||||
|
|
||||||
_Base&
|
_Base&
|
||||||
_M_base() noexcept { return *this; }
|
_M_base() noexcept { return *this; }
|
||||||
|
|
||||||
const _Base&
|
const _Base&
|
||||||
_M_base() const noexcept { return *this; }
|
_M_base() const noexcept { return *this; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename _Base::size_type size_type;
|
typedef typename _Base::size_type size_type;
|
||||||
typedef typename _Base::hasher hasher;
|
typedef typename _Base::hasher hasher;
|
||||||
typedef typename _Base::key_equal key_equal;
|
typedef typename _Base::key_equal key_equal;
|
||||||
typedef typename _Base::allocator_type allocator_type;
|
typedef typename _Base::allocator_type allocator_type;
|
||||||
typedef typename _Base::key_type key_type;
|
typedef typename _Base::key_type key_type;
|
||||||
typedef typename _Base::value_type value_type;
|
typedef typename _Base::value_type value_type;
|
||||||
typedef typename _Base::difference_type difference_type;
|
typedef typename _Base::difference_type difference_type;
|
||||||
typedef typename _Base::reference reference;
|
typedef typename _Base::reference reference;
|
||||||
typedef typename _Base::const_reference const_reference;
|
typedef typename _Base::const_reference const_reference;
|
||||||
typedef typename _Base::mapped_type mapped_type;
|
typedef typename _Base::mapped_type mapped_type;
|
||||||
|
|
||||||
typedef typename _Base::iterator iterator;
|
typedef typename _Base::iterator iterator;
|
||||||
typedef typename _Base::const_iterator const_iterator;
|
typedef typename _Base::const_iterator const_iterator;
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
unordered_map(size_type __n = 10,
|
unordered_map(size_type __n = 10,
|
||||||
const hasher& __hf = hasher(),
|
const hasher& __hf = hasher(),
|
||||||
const key_equal& __eql = key_equal(),
|
const key_equal& __eql = key_equal(),
|
||||||
const allocator_type& __a = allocator_type())
|
const allocator_type& __a = allocator_type())
|
||||||
: _Base(__n, __hf, __eql, __a)
|
: _Base(__n, __hf, __eql, __a) { }
|
||||||
{ }
|
|
||||||
|
|
||||||
template<typename _InputIterator>
|
template<typename _InputIterator>
|
||||||
unordered_map(_InputIterator __f, _InputIterator __l,
|
unordered_map(_InputIterator __f, _InputIterator __l,
|
||||||
size_type __n = 0,
|
size_type __n = 0,
|
||||||
const hasher& __hf = hasher(),
|
const hasher& __hf = hasher(),
|
||||||
const key_equal& __eql = key_equal(),
|
const key_equal& __eql = key_equal(),
|
||||||
const allocator_type& __a = allocator_type())
|
const allocator_type& __a = allocator_type())
|
||||||
: _Base(__f, __l, __n, __hf, __eql, __a)
|
: _Base(__f, __l, __n, __hf, __eql, __a) { }
|
||||||
{ }
|
|
||||||
|
|
||||||
unordered_map(const unordered_map&) = default;
|
unordered_map(const unordered_map&) = default;
|
||||||
|
|
||||||
unordered_map(const _Base& __x)
|
unordered_map(const _Base& __x)
|
||||||
: _Base(__x)
|
: _Base(__x) { }
|
||||||
{ }
|
|
||||||
|
|
||||||
unordered_map(unordered_map&&) = default;
|
unordered_map(unordered_map&&) = default;
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
unordered_map(const allocator_type& __a)
|
unordered_map(const allocator_type& __a)
|
||||||
: _Base(__a)
|
: _Base(__a) { }
|
||||||
{ }
|
|
||||||
|
|
||||||
unordered_map(const unordered_map& __umap,
|
unordered_map(const unordered_map& __umap,
|
||||||
const allocator_type& __a)
|
const allocator_type& __a)
|
||||||
: _Base(__umap, __a)
|
: _Base(__umap, __a) { }
|
||||||
{ }
|
|
||||||
|
|
||||||
unordered_map(unordered_map&& __umap,
|
unordered_map(unordered_map&& __umap,
|
||||||
const allocator_type& __a)
|
const allocator_type& __a)
|
||||||
: _Base(std::move(__umap._M_base()), __a)
|
: _Base(std::move(__umap._M_base()), __a) { }
|
||||||
{ }
|
|
||||||
|
|
||||||
unordered_map(initializer_list<value_type> __l,
|
unordered_map(initializer_list<value_type> __l,
|
||||||
size_type __n = 0,
|
size_type __n = 0,
|
||||||
const hasher& __hf = hasher(),
|
const hasher& __hf = hasher(),
|
||||||
const key_equal& __eql = key_equal(),
|
const key_equal& __eql = key_equal(),
|
||||||
const allocator_type& __a = allocator_type())
|
const allocator_type& __a = allocator_type())
|
||||||
: _Base(__l, __n, __hf, __eql, __a)
|
: _Base(__l, __n, __hf, __eql, __a) { }
|
||||||
{ }
|
|
||||||
|
|
||||||
unordered_map&
|
unordered_map&
|
||||||
operator=(const unordered_map&) = default;
|
operator=(const unordered_map&) = default;
|
||||||
|
|
@ -140,9 +133,9 @@ namespace __profile
|
||||||
void
|
void
|
||||||
clear() noexcept
|
clear() noexcept
|
||||||
{
|
{
|
||||||
__profcxx_hashtable_destruct(this, _Base::bucket_count(),
|
__profcxx_hashtable_destruct(this, _Base::bucket_count(),
|
||||||
_Base::size());
|
_Base::size());
|
||||||
this->_M_profile_destruct();
|
this->_M_profile_destruct();
|
||||||
_Base::clear();
|
_Base::clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -170,81 +163,81 @@ namespace __profile
|
||||||
|
|
||||||
void
|
void
|
||||||
insert(std::initializer_list<value_type> __l)
|
insert(std::initializer_list<value_type> __l)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
_Base::insert(__l);
|
_Base::insert(__l);
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<iterator, bool>
|
std::pair<iterator, bool>
|
||||||
insert(const value_type& __obj)
|
insert(const value_type& __obj)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
std::pair<iterator, bool> __res = _Base::insert(__obj);
|
std::pair<iterator, bool> __res = _Base::insert(__obj);
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
insert(const_iterator __iter, const value_type& __v)
|
insert(const_iterator __iter, const value_type& __v)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
iterator __res = _Base::insert(__iter, __v);
|
iterator __res = _Base::insert(__iter, __v);
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Pair, typename = typename
|
template<typename _Pair, typename = typename
|
||||||
std::enable_if<std::is_constructible<value_type,
|
std::enable_if<std::is_constructible<value_type,
|
||||||
_Pair&&>::value>::type>
|
_Pair&&>::value>::type>
|
||||||
std::pair<iterator, bool>
|
std::pair<iterator, bool>
|
||||||
insert(_Pair&& __obj)
|
insert(_Pair&& __obj)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
std::pair<iterator, bool> __res
|
std::pair<iterator, bool> __res
|
||||||
= _Base::insert(std::forward<_Pair>(__obj));
|
= _Base::insert(std::forward<_Pair>(__obj));
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Pair, typename = typename
|
template<typename _Pair, typename = typename
|
||||||
std::enable_if<std::is_constructible<value_type,
|
std::enable_if<std::is_constructible<value_type,
|
||||||
_Pair&&>::value>::type>
|
_Pair&&>::value>::type>
|
||||||
iterator
|
iterator
|
||||||
insert(const_iterator __iter, _Pair&& __v)
|
insert(const_iterator __iter, _Pair&& __v)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
iterator __res = _Base::insert(__iter, std::forward<_Pair>(__v));
|
iterator __res = _Base::insert(__iter, std::forward<_Pair>(__v));
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _InputIter>
|
template<typename _InputIter>
|
||||||
void
|
void
|
||||||
insert(_InputIter __first, _InputIter __last)
|
insert(_InputIter __first, _InputIter __last)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
_Base::insert(__first, __last);
|
_Base::insert(__first, __last);
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// operator[]
|
// operator[]
|
||||||
mapped_type&
|
mapped_type&
|
||||||
operator[](const _Key& __k)
|
operator[](const _Key& __k)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
mapped_type& __res = _M_base()[__k];
|
mapped_type& __res = _M_base()[__k];
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
mapped_type&
|
mapped_type&
|
||||||
operator[](_Key&& __k)
|
operator[](_Key&& __k)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
mapped_type& __res = _M_base()[std::move(__k)];
|
mapped_type& __res = _M_base()[std::move(__k)];
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -256,7 +249,7 @@ namespace __profile
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
_Base::rehash(__n);
|
_Base::rehash(__n);
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -305,76 +298,69 @@ namespace __profile
|
||||||
public _Unordered_profile<unordered_multimap<_Key, _Tp,
|
public _Unordered_profile<unordered_multimap<_Key, _Tp,
|
||||||
_Hash, _Pred, _Alloc>,
|
_Hash, _Pred, _Alloc>,
|
||||||
false>
|
false>
|
||||||
{
|
{
|
||||||
typedef typename _GLIBCXX_STD_BASE _Base;
|
typedef typename _GLIBCXX_STD_BASE _Base;
|
||||||
|
|
||||||
_Base&
|
_Base&
|
||||||
_M_base() noexcept { return *this; }
|
_M_base() noexcept { return *this; }
|
||||||
|
|
||||||
const _Base&
|
const _Base&
|
||||||
_M_base() const noexcept { return *this; }
|
_M_base() const noexcept { return *this; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename _Base::size_type size_type;
|
typedef typename _Base::size_type size_type;
|
||||||
typedef typename _Base::hasher hasher;
|
typedef typename _Base::hasher hasher;
|
||||||
typedef typename _Base::key_equal key_equal;
|
typedef typename _Base::key_equal key_equal;
|
||||||
typedef typename _Base::allocator_type allocator_type;
|
typedef typename _Base::allocator_type allocator_type;
|
||||||
typedef typename _Base::key_type key_type;
|
typedef typename _Base::key_type key_type;
|
||||||
typedef typename _Base::value_type value_type;
|
typedef typename _Base::value_type value_type;
|
||||||
typedef typename _Base::difference_type difference_type;
|
typedef typename _Base::difference_type difference_type;
|
||||||
typedef typename _Base::reference reference;
|
typedef typename _Base::reference reference;
|
||||||
typedef typename _Base::const_reference const_reference;
|
typedef typename _Base::const_reference const_reference;
|
||||||
|
|
||||||
typedef typename _Base::iterator iterator;
|
typedef typename _Base::iterator iterator;
|
||||||
typedef typename _Base::const_iterator const_iterator;
|
typedef typename _Base::const_iterator const_iterator;
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
unordered_multimap(size_type __n = 10,
|
unordered_multimap(size_type __n = 10,
|
||||||
const hasher& __hf = hasher(),
|
const hasher& __hf = hasher(),
|
||||||
const key_equal& __eql = key_equal(),
|
const key_equal& __eql = key_equal(),
|
||||||
const allocator_type& __a = allocator_type())
|
const allocator_type& __a = allocator_type())
|
||||||
: _Base(__n, __hf, __eql, __a)
|
: _Base(__n, __hf, __eql, __a) { }
|
||||||
{ }
|
|
||||||
|
|
||||||
template<typename _InputIterator>
|
template<typename _InputIterator>
|
||||||
unordered_multimap(_InputIterator __f, _InputIterator __l,
|
unordered_multimap(_InputIterator __f, _InputIterator __l,
|
||||||
size_type __n = 0,
|
size_type __n = 0,
|
||||||
const hasher& __hf = hasher(),
|
const hasher& __hf = hasher(),
|
||||||
const key_equal& __eql = key_equal(),
|
const key_equal& __eql = key_equal(),
|
||||||
const allocator_type& __a = allocator_type())
|
const allocator_type& __a = allocator_type())
|
||||||
: _Base(__f, __l, __n, __hf, __eql, __a)
|
: _Base(__f, __l, __n, __hf, __eql, __a) { }
|
||||||
{ }
|
|
||||||
|
|
||||||
unordered_multimap(const unordered_multimap&) = default;
|
unordered_multimap(const unordered_multimap&) = default;
|
||||||
|
|
||||||
unordered_multimap(const _Base& __x)
|
unordered_multimap(const _Base& __x)
|
||||||
: _Base(__x)
|
: _Base(__x) { }
|
||||||
{ }
|
|
||||||
|
|
||||||
unordered_multimap(unordered_multimap&&) = default;
|
unordered_multimap(unordered_multimap&&) = default;
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
unordered_multimap(const allocator_type& __a)
|
unordered_multimap(const allocator_type& __a)
|
||||||
: _Base(__a)
|
: _Base(__a) { }
|
||||||
{ }
|
|
||||||
|
|
||||||
unordered_multimap(const unordered_multimap& __ummap,
|
unordered_multimap(const unordered_multimap& __ummap,
|
||||||
const allocator_type& __a)
|
const allocator_type& __a)
|
||||||
: _Base(__ummap._M_base(), __a)
|
: _Base(__ummap._M_base(), __a) { }
|
||||||
{ }
|
|
||||||
|
|
||||||
unordered_multimap(unordered_multimap&& __ummap,
|
unordered_multimap(unordered_multimap&& __ummap,
|
||||||
const allocator_type& __a)
|
const allocator_type& __a)
|
||||||
: _Base(std::move(__ummap._M_base()), __a)
|
: _Base(std::move(__ummap._M_base()), __a) { }
|
||||||
{ }
|
|
||||||
|
|
||||||
unordered_multimap(initializer_list<value_type> __l,
|
unordered_multimap(initializer_list<value_type> __l,
|
||||||
size_type __n = 0,
|
size_type __n = 0,
|
||||||
const hasher& __hf = hasher(),
|
const hasher& __hf = hasher(),
|
||||||
const key_equal& __eql = key_equal(),
|
const key_equal& __eql = key_equal(),
|
||||||
const allocator_type& __a = allocator_type())
|
const allocator_type& __a = allocator_type())
|
||||||
: _Base(__l, __n, __hf, __eql, __a)
|
: _Base(__l, __n, __hf, __eql, __a) { }
|
||||||
{ }
|
|
||||||
|
|
||||||
unordered_multimap&
|
unordered_multimap&
|
||||||
operator=(const unordered_multimap&) = default;
|
operator=(const unordered_multimap&) = default;
|
||||||
|
|
@ -392,7 +378,7 @@ namespace __profile
|
||||||
void
|
void
|
||||||
clear() noexcept
|
clear() noexcept
|
||||||
{
|
{
|
||||||
__profcxx_hashtable_destruct(this, _Base::bucket_count(),
|
__profcxx_hashtable_destruct(this, _Base::bucket_count(),
|
||||||
_Base::size());
|
_Base::size());
|
||||||
this->_M_profile_destruct();
|
this->_M_profile_destruct();
|
||||||
_Base::clear();
|
_Base::clear();
|
||||||
|
|
@ -422,61 +408,61 @@ namespace __profile
|
||||||
|
|
||||||
void
|
void
|
||||||
insert(std::initializer_list<value_type> __l)
|
insert(std::initializer_list<value_type> __l)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
_Base::insert(__l);
|
_Base::insert(__l);
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
insert(const value_type& __obj)
|
insert(const value_type& __obj)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
iterator __res = _Base::insert(__obj);
|
iterator __res = _Base::insert(__obj);
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
insert(const_iterator __iter, const value_type& __v)
|
insert(const_iterator __iter, const value_type& __v)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
iterator __res = _Base::insert(__iter, __v);
|
iterator __res = _Base::insert(__iter, __v);
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Pair, typename = typename
|
template<typename _Pair, typename = typename
|
||||||
std::enable_if<std::is_constructible<value_type,
|
std::enable_if<std::is_constructible<value_type,
|
||||||
_Pair&&>::value>::type>
|
_Pair&&>::value>::type>
|
||||||
iterator
|
iterator
|
||||||
insert(_Pair&& __obj)
|
insert(_Pair&& __obj)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
iterator __res = _Base::insert(std::forward<_Pair>(__obj));
|
iterator __res = _Base::insert(std::forward<_Pair>(__obj));
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Pair, typename = typename
|
template<typename _Pair, typename = typename
|
||||||
std::enable_if<std::is_constructible<value_type,
|
std::enable_if<std::is_constructible<value_type,
|
||||||
_Pair&&>::value>::type>
|
_Pair&&>::value>::type>
|
||||||
iterator
|
iterator
|
||||||
insert(const_iterator __iter, _Pair&& __v)
|
insert(const_iterator __iter, _Pair&& __v)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
iterator __res = _Base::insert(__iter, std::forward<_Pair>(__v));
|
iterator __res = _Base::insert(__iter, std::forward<_Pair>(__v));
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _InputIter>
|
template<typename _InputIter>
|
||||||
void
|
void
|
||||||
insert(_InputIter __first, _InputIter __last)
|
insert(_InputIter __first, _InputIter __last)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
_Base::insert(__first, __last);
|
_Base::insert(__first, __last);
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -487,9 +473,9 @@ namespace __profile
|
||||||
void
|
void
|
||||||
rehash(size_type __n)
|
rehash(size_type __n)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
_Base::rehash(__n);
|
_Base::rehash(__n);
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -497,8 +483,8 @@ namespace __profile
|
||||||
_M_profile_resize(size_type __old_size)
|
_M_profile_resize(size_type __old_size)
|
||||||
{
|
{
|
||||||
size_type __new_size = _Base::bucket_count();
|
size_type __new_size = _Base::bucket_count();
|
||||||
if (__old_size != __new_size)
|
if (__old_size != __new_size)
|
||||||
__profcxx_hashtable_resize(this, __old_size, __new_size);
|
__profcxx_hashtable_resize(this, __old_size, __new_size);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
namespace __profile
|
namespace __profile
|
||||||
{
|
{
|
||||||
/** @brief Unordered_set wrapper with performance instrumentation. */
|
/** @brief Unordered_set wrapper with performance instrumentation. */
|
||||||
template<typename _Key,
|
template<typename _Key,
|
||||||
typename _Hash = std::hash<_Key>,
|
typename _Hash = std::hash<_Key>,
|
||||||
typename _Pred = std::equal_to<_Key>,
|
typename _Pred = std::equal_to<_Key>,
|
||||||
typename _Alloc = std::allocator<_Key> >
|
typename _Alloc = std::allocator<_Key> >
|
||||||
|
|
@ -62,18 +62,18 @@ namespace __profile
|
||||||
_M_base() const noexcept { return *this; }
|
_M_base() const noexcept { return *this; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename _Base::size_type size_type;
|
typedef typename _Base::size_type size_type;
|
||||||
typedef typename _Base::hasher hasher;
|
typedef typename _Base::hasher hasher;
|
||||||
typedef typename _Base::key_equal key_equal;
|
typedef typename _Base::key_equal key_equal;
|
||||||
typedef typename _Base::allocator_type allocator_type;
|
typedef typename _Base::allocator_type allocator_type;
|
||||||
typedef typename _Base::key_type key_type;
|
typedef typename _Base::key_type key_type;
|
||||||
typedef typename _Base::value_type value_type;
|
typedef typename _Base::value_type value_type;
|
||||||
typedef typename _Base::difference_type difference_type;
|
typedef typename _Base::difference_type difference_type;
|
||||||
typedef typename _Base::reference reference;
|
typedef typename _Base::reference reference;
|
||||||
typedef typename _Base::const_reference const_reference;
|
typedef typename _Base::const_reference const_reference;
|
||||||
|
|
||||||
typedef typename _Base::iterator iterator;
|
typedef typename _Base::iterator iterator;
|
||||||
typedef typename _Base::const_iterator const_iterator;
|
typedef typename _Base::const_iterator const_iterator;
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
unordered_set(size_type __n = 10,
|
unordered_set(size_type __n = 10,
|
||||||
|
|
@ -84,7 +84,7 @@ namespace __profile
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
template<typename _InputIterator>
|
template<typename _InputIterator>
|
||||||
unordered_set(_InputIterator __f, _InputIterator __l,
|
unordered_set(_InputIterator __f, _InputIterator __l,
|
||||||
size_type __n = 0,
|
size_type __n = 0,
|
||||||
const hasher& __hf = hasher(),
|
const hasher& __hf = hasher(),
|
||||||
const key_equal& __eql = key_equal(),
|
const key_equal& __eql = key_equal(),
|
||||||
|
|
@ -144,10 +144,10 @@ namespace __profile
|
||||||
void
|
void
|
||||||
clear() noexcept
|
clear() noexcept
|
||||||
{
|
{
|
||||||
__profcxx_hashtable_destruct(this, _Base::bucket_count(),
|
__profcxx_hashtable_destruct(this, _Base::bucket_count(),
|
||||||
_Base::size());
|
_Base::size());
|
||||||
this->_M_profile_destruct();
|
this->_M_profile_destruct();
|
||||||
_Base::clear();
|
_Base::clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... _Args>
|
template<typename... _Args>
|
||||||
|
|
@ -174,63 +174,63 @@ namespace __profile
|
||||||
|
|
||||||
void
|
void
|
||||||
insert(std::initializer_list<value_type> __l)
|
insert(std::initializer_list<value_type> __l)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
_Base::insert(__l);
|
_Base::insert(__l);
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<iterator, bool>
|
std::pair<iterator, bool>
|
||||||
insert(const value_type& __obj)
|
insert(const value_type& __obj)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
std::pair<iterator, bool> __res = _Base::insert(__obj);
|
std::pair<iterator, bool> __res = _Base::insert(__obj);
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
insert(const_iterator __iter, const value_type& __v)
|
insert(const_iterator __iter, const value_type& __v)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
iterator __res = _Base::insert(__iter, __v);
|
iterator __res = _Base::insert(__iter, __v);
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<iterator, bool>
|
std::pair<iterator, bool>
|
||||||
insert(value_type&& __obj)
|
insert(value_type&& __obj)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
std::pair<iterator, bool> __res = _Base::insert(std::move(__obj));
|
std::pair<iterator, bool> __res = _Base::insert(std::move(__obj));
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
insert(const_iterator __iter, value_type&& __v)
|
insert(const_iterator __iter, value_type&& __v)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
iterator __res = _Base::insert(__iter, std::move(__v));
|
iterator __res = _Base::insert(__iter, std::move(__v));
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _InputIter>
|
template<typename _InputIter>
|
||||||
void
|
void
|
||||||
insert(_InputIter __first, _InputIter __last)
|
insert(_InputIter __first, _InputIter __last)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
_Base::insert(__first, __last);
|
_Base::insert(__first, __last);
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rehash(size_type __n)
|
rehash(size_type __n)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
_Base::rehash(__n);
|
_Base::rehash(__n);
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -287,10 +287,10 @@ namespace __profile
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename _Base::size_type size_type;
|
typedef typename _Base::size_type size_type;
|
||||||
typedef typename _Base::hasher hasher;
|
typedef typename _Base::hasher hasher;
|
||||||
typedef typename _Base::key_equal key_equal;
|
typedef typename _Base::key_equal key_equal;
|
||||||
typedef typename _Base::allocator_type allocator_type;
|
typedef typename _Base::allocator_type allocator_type;
|
||||||
typedef typename _Base::key_type key_type;
|
typedef typename _Base::key_type key_type;
|
||||||
typedef typename _Base::value_type value_type;
|
typedef typename _Base::value_type value_type;
|
||||||
typedef typename _Base::difference_type difference_type;
|
typedef typename _Base::difference_type difference_type;
|
||||||
typedef typename _Base::reference reference;
|
typedef typename _Base::reference reference;
|
||||||
|
|
@ -308,7 +308,7 @@ namespace __profile
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
template<typename _InputIterator>
|
template<typename _InputIterator>
|
||||||
unordered_multiset(_InputIterator __f, _InputIterator __l,
|
unordered_multiset(_InputIterator __f, _InputIterator __l,
|
||||||
size_type __n = 0,
|
size_type __n = 0,
|
||||||
const hasher& __hf = hasher(),
|
const hasher& __hf = hasher(),
|
||||||
const key_equal& __eql = key_equal(),
|
const key_equal& __eql = key_equal(),
|
||||||
|
|
@ -368,10 +368,10 @@ namespace __profile
|
||||||
void
|
void
|
||||||
clear() noexcept
|
clear() noexcept
|
||||||
{
|
{
|
||||||
__profcxx_hashtable_destruct(this, _Base::bucket_count(),
|
__profcxx_hashtable_destruct(this, _Base::bucket_count(),
|
||||||
_Base::size());
|
_Base::size());
|
||||||
this->_M_profile_destruct();
|
this->_M_profile_destruct();
|
||||||
_Base::clear();
|
_Base::clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... _Args>
|
template<typename... _Args>
|
||||||
|
|
@ -397,63 +397,63 @@ namespace __profile
|
||||||
|
|
||||||
void
|
void
|
||||||
insert(std::initializer_list<value_type> __l)
|
insert(std::initializer_list<value_type> __l)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
_Base::insert(__l);
|
_Base::insert(__l);
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
insert(const value_type& __obj)
|
insert(const value_type& __obj)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
iterator __res = _Base::insert(__obj);
|
iterator __res = _Base::insert(__obj);
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
insert(const_iterator __iter, const value_type& __v)
|
insert(const_iterator __iter, const value_type& __v)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
iterator __res = _Base::insert(__iter, __v);
|
iterator __res = _Base::insert(__iter, __v);
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
insert(value_type&& __obj)
|
insert(value_type&& __obj)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
iterator __res = _Base::insert(std::move(__obj));
|
iterator __res = _Base::insert(std::move(__obj));
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
insert(const_iterator __iter, value_type&& __v)
|
insert(const_iterator __iter, value_type&& __v)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
iterator __res = _Base::insert(__iter, std::move(__v));
|
iterator __res = _Base::insert(__iter, std::move(__v));
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _InputIter>
|
template<typename _InputIter>
|
||||||
void
|
void
|
||||||
insert(_InputIter __first, _InputIter __last)
|
insert(_InputIter __first, _InputIter __last)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
_Base::insert(__first, __last);
|
_Base::insert(__first, __last);
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rehash(size_type __n)
|
rehash(size_type __n)
|
||||||
{
|
{
|
||||||
size_type __old_size = _Base::bucket_count();
|
size_type __old_size = _Base::bucket_count();
|
||||||
_Base::rehash(__n);
|
_Base::rehash(__n);
|
||||||
_M_profile_resize(__old_size);
|
_M_profile_resize(__old_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -461,8 +461,8 @@ namespace __profile
|
||||||
_M_profile_resize(size_type __old_size)
|
_M_profile_resize(size_type __old_size)
|
||||||
{
|
{
|
||||||
size_type __new_size = _Base::bucket_count();
|
size_type __new_size = _Base::bucket_count();
|
||||||
if (__old_size != __new_size)
|
if (__old_size != __new_size)
|
||||||
__profcxx_hashtable_resize(this, __old_size, __new_size);
|
__profcxx_hashtable_resize(this, __old_size, __new_size);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,87 +37,134 @@ namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
{
|
{
|
||||||
namespace __profile
|
namespace __profile
|
||||||
{
|
{
|
||||||
|
template<typename _Vector>
|
||||||
|
class _Vector_profile_pre
|
||||||
|
{
|
||||||
|
_Vector&
|
||||||
|
_M_conjure()
|
||||||
|
{ return *static_cast<_Vector*>(this); }
|
||||||
|
|
||||||
|
public:
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
|
_Vector_profile_pre() = default;
|
||||||
|
_Vector_profile_pre(const _Vector_profile_pre&) = default;
|
||||||
|
_Vector_profile_pre(_Vector_profile_pre&&) = default;
|
||||||
|
|
||||||
|
_Vector_profile_pre&
|
||||||
|
operator=(const _Vector_profile_pre&) = default;
|
||||||
|
|
||||||
|
_Vector_profile_pre&
|
||||||
|
operator=(_Vector_profile_pre&&) noexcept
|
||||||
|
{ _M_profile_destruct(); }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void
|
||||||
|
_M_profile_destruct()
|
||||||
|
{
|
||||||
|
__profcxx_vector_destruct2(&_M_conjure());
|
||||||
|
__profcxx_vector_destruct(&_M_conjure(),
|
||||||
|
_M_conjure().capacity(), _M_conjure().size());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename _Vector>
|
||||||
|
class _Vector_profile_post
|
||||||
|
{
|
||||||
|
_Vector&
|
||||||
|
_M_conjure()
|
||||||
|
{ return *static_cast<_Vector*>(this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
_Vector_profile_post() _GLIBCXX_NOEXCEPT
|
||||||
|
{
|
||||||
|
__profcxx_vector_construct(&_M_conjure(), _M_conjure().capacity());
|
||||||
|
__profcxx_vector_construct2(&_M_conjure());
|
||||||
|
}
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
|
_Vector_profile_post(const _Vector_profile_post&) noexcept
|
||||||
|
: _Vector_profile_post() { }
|
||||||
|
_Vector_profile_post(_Vector_profile_post&&) noexcept
|
||||||
|
: _Vector_profile_post() { }
|
||||||
|
|
||||||
|
_Vector_profile_post&
|
||||||
|
operator=(const _Vector_profile_post&) = default;
|
||||||
|
_Vector_profile_post&
|
||||||
|
operator=(_Vector_profile_post&&) = default;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
~_Vector_profile_post()
|
||||||
|
{ _M_conjure()._M_profile_destruct(); }
|
||||||
|
};
|
||||||
|
|
||||||
template<typename _Tp,
|
template<typename _Tp,
|
||||||
typename _Allocator = std::allocator<_Tp> >
|
typename _Allocator = std::allocator<_Tp> >
|
||||||
class vector
|
class vector
|
||||||
: public _GLIBCXX_STD_C::vector<_Tp, _Allocator>
|
: public _Vector_profile_pre<vector<_Tp, _Allocator> >,
|
||||||
|
public _GLIBCXX_STD_C::vector<_Tp, _Allocator>,
|
||||||
|
public _Vector_profile_post<vector<_Tp, _Allocator> >
|
||||||
{
|
{
|
||||||
typedef _GLIBCXX_STD_C::vector<_Tp, _Allocator> _Base;
|
typedef _GLIBCXX_STD_C::vector<_Tp, _Allocator> _Base;
|
||||||
|
|
||||||
typedef typename _Base::iterator _Base_iterator;
|
typedef typename _Base::iterator _Base_iterator;
|
||||||
typedef typename _Base::const_iterator _Base_const_iterator;
|
typedef typename _Base::const_iterator _Base_const_iterator;
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
typedef __gnu_cxx::__alloc_traits<_Allocator> _Alloc_traits;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename _Base::reference reference;
|
typedef typename _Base::reference reference;
|
||||||
typedef typename _Base::const_reference const_reference;
|
typedef typename _Base::const_reference const_reference;
|
||||||
|
|
||||||
typedef __iterator_tracker<_Base_iterator, vector>
|
typedef __iterator_tracker<_Base_iterator, vector>
|
||||||
iterator;
|
iterator;
|
||||||
typedef __iterator_tracker<_Base_const_iterator, vector>
|
typedef __iterator_tracker<_Base_const_iterator, vector>
|
||||||
const_iterator;
|
const_iterator;
|
||||||
|
|
||||||
typedef typename _Base::size_type size_type;
|
typedef typename _Base::size_type size_type;
|
||||||
typedef typename _Base::difference_type difference_type;
|
typedef typename _Base::difference_type difference_type;
|
||||||
|
|
||||||
|
typedef _Tp value_type;
|
||||||
|
typedef _Allocator allocator_type;
|
||||||
|
typedef typename _Base::pointer pointer;
|
||||||
|
typedef typename _Base::const_pointer const_pointer;
|
||||||
|
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||||
|
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||||
|
|
||||||
typedef _Tp value_type;
|
|
||||||
typedef _Allocator allocator_type;
|
|
||||||
typedef typename _Base::pointer pointer;
|
|
||||||
typedef typename _Base::const_pointer const_pointer;
|
|
||||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
|
||||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
|
||||||
|
|
||||||
_Base&
|
_Base&
|
||||||
_M_base() _GLIBCXX_NOEXCEPT { return *this; }
|
_M_base() _GLIBCXX_NOEXCEPT { return *this; }
|
||||||
|
|
||||||
const _Base&
|
const _Base&
|
||||||
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
|
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
|
||||||
|
|
||||||
// 23.2.4.1 construct/copy/destroy:
|
// 23.2.4.1 construct/copy/destroy:
|
||||||
|
|
||||||
vector() _GLIBCXX_NOEXCEPT
|
#if __cplusplus < 201103L
|
||||||
: _Base()
|
vector()
|
||||||
{
|
{ }
|
||||||
__profcxx_vector_construct(this, this->capacity());
|
|
||||||
__profcxx_vector_construct2(this);
|
vector(const vector& __x)
|
||||||
}
|
: _Base(__x) { }
|
||||||
|
#else
|
||||||
|
vector() = default;
|
||||||
|
vector(const vector&) = default;
|
||||||
|
vector(vector&&) = default;
|
||||||
|
#endif
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
vector(const _Allocator& __a) _GLIBCXX_NOEXCEPT
|
vector(const _Allocator& __a) _GLIBCXX_NOEXCEPT
|
||||||
: _Base(__a)
|
: _Base(__a) { }
|
||||||
{
|
|
||||||
__profcxx_vector_construct(this, this->capacity());
|
|
||||||
__profcxx_vector_construct2(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
explicit
|
explicit
|
||||||
vector(size_type __n, const _Allocator& __a = _Allocator())
|
vector(size_type __n, const _Allocator& __a = _Allocator())
|
||||||
: _Base(__n, __a)
|
: _Base(__n, __a) { }
|
||||||
{
|
|
||||||
__profcxx_vector_construct(this, this->capacity());
|
|
||||||
__profcxx_vector_construct2(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
vector(size_type __n, const _Tp& __value,
|
vector(size_type __n, const _Tp& __value,
|
||||||
const _Allocator& __a = _Allocator())
|
const _Allocator& __a = _Allocator())
|
||||||
: _Base(__n, __value, __a)
|
: _Base(__n, __value, __a) { }
|
||||||
{
|
|
||||||
__profcxx_vector_construct(this, this->capacity());
|
|
||||||
__profcxx_vector_construct2(this);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
explicit
|
explicit
|
||||||
vector(size_type __n, const _Tp& __value = _Tp(),
|
vector(size_type __n, const _Tp& __value = _Tp(),
|
||||||
const _Allocator& __a = _Allocator())
|
const _Allocator& __a = _Allocator())
|
||||||
: _Base(__n, __value, __a)
|
: _Base(__n, __value, __a) { }
|
||||||
{
|
|
||||||
__profcxx_vector_construct(this, this->capacity());
|
|
||||||
__profcxx_vector_construct2(this);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
|
|
@ -126,91 +173,48 @@ namespace __profile
|
||||||
#else
|
#else
|
||||||
template<typename _InputIterator>
|
template<typename _InputIterator>
|
||||||
#endif
|
#endif
|
||||||
vector(_InputIterator __first, _InputIterator __last,
|
vector(_InputIterator __first, _InputIterator __last,
|
||||||
const _Allocator& __a = _Allocator())
|
const _Allocator& __a = _Allocator())
|
||||||
: _Base(__first, __last, __a)
|
: _Base(__first, __last, __a) { }
|
||||||
{
|
|
||||||
__profcxx_vector_construct(this, this->capacity());
|
|
||||||
__profcxx_vector_construct2(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
vector(const vector& __x)
|
/// Construction from a normal-mode vector
|
||||||
: _Base(__x)
|
|
||||||
{
|
|
||||||
__profcxx_vector_construct(this, this->capacity());
|
|
||||||
__profcxx_vector_construct2(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Construction from a release-mode vector
|
|
||||||
vector(const _Base& __x)
|
vector(const _Base& __x)
|
||||||
: _Base(__x)
|
: _Base(__x) { }
|
||||||
{
|
|
||||||
__profcxx_vector_construct(this, this->capacity());
|
|
||||||
__profcxx_vector_construct2(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
vector(vector&& __x) noexcept
|
|
||||||
: _Base(std::move(__x))
|
|
||||||
{
|
|
||||||
__profcxx_vector_construct(this, this->capacity());
|
|
||||||
__profcxx_vector_construct2(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
vector(const _Base& __x, const _Allocator& __a)
|
vector(const _Base& __x, const _Allocator& __a)
|
||||||
: _Base(__x, __a)
|
: _Base(__x, __a) { }
|
||||||
{
|
|
||||||
__profcxx_vector_construct(this, this->capacity());
|
|
||||||
__profcxx_vector_construct2(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
vector(vector&& __x, const _Allocator& __a)
|
vector(vector&& __x, const _Allocator& __a)
|
||||||
: _Base(std::move(__x), __a)
|
: _Base(std::move(__x), __a) { }
|
||||||
{
|
|
||||||
__profcxx_vector_construct(this, this->capacity());
|
|
||||||
__profcxx_vector_construct2(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
vector(initializer_list<value_type> __l,
|
vector(initializer_list<value_type> __l,
|
||||||
const allocator_type& __a = allocator_type())
|
const allocator_type& __a = allocator_type())
|
||||||
: _Base(__l, __a) { }
|
: _Base(__l, __a) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
~vector() _GLIBCXX_NOEXCEPT
|
#if __cplusplus < 201103L
|
||||||
{
|
|
||||||
__profcxx_vector_destruct(this, this->capacity(), this->size());
|
|
||||||
__profcxx_vector_destruct2(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
vector&
|
vector&
|
||||||
operator=(const vector& __x)
|
operator=(const vector& __x)
|
||||||
{
|
{
|
||||||
static_cast<_Base&>(*this) = __x;
|
_M_base() = __x;
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
vector&
|
|
||||||
operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
|
|
||||||
{
|
|
||||||
__profcxx_vector_destruct(this, this->capacity(), this->size());
|
|
||||||
__profcxx_vector_destruct2(this);
|
|
||||||
static_cast<_Base&>(*this) = std::move(__x);
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
vector&
|
||||||
|
operator=(const vector&) = default;
|
||||||
|
|
||||||
|
vector&
|
||||||
|
operator=(vector&&) = default;
|
||||||
|
|
||||||
vector&
|
vector&
|
||||||
operator=(initializer_list<value_type> __l)
|
operator=(initializer_list<value_type> __l)
|
||||||
{
|
{
|
||||||
static_cast<_Base&>(*this) = __l;
|
_M_base() = __l;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using _Base::assign;
|
|
||||||
using _Base::get_allocator;
|
|
||||||
|
|
||||||
|
|
||||||
// iterators:
|
// iterators:
|
||||||
iterator
|
iterator
|
||||||
begin() _GLIBCXX_NOEXCEPT
|
begin() _GLIBCXX_NOEXCEPT
|
||||||
|
|
@ -263,183 +267,135 @@ namespace __profile
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 23.2.4.2 capacity:
|
// 23.2.4.2 capacity:
|
||||||
using _Base::size;
|
|
||||||
using _Base::max_size;
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
void
|
void
|
||||||
resize(size_type __sz)
|
resize(size_type __sz)
|
||||||
{
|
{
|
||||||
__profcxx_vector_invalid_operator(this);
|
__profcxx_vector_invalid_operator(this);
|
||||||
_M_profile_resize(this, this->capacity(), __sz);
|
_M_profile_resize(this->capacity(), __sz);
|
||||||
_Base::resize(__sz);
|
_Base::resize(__sz);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
resize(size_type __sz, const _Tp& __c)
|
resize(size_type __sz, const _Tp& __c)
|
||||||
{
|
{
|
||||||
__profcxx_vector_invalid_operator(this);
|
__profcxx_vector_invalid_operator(this);
|
||||||
_M_profile_resize(this, this->capacity(), __sz);
|
_M_profile_resize(this->capacity(), __sz);
|
||||||
_Base::resize(__sz, __c);
|
_Base::resize(__sz, __c);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void
|
void
|
||||||
resize(size_type __sz, _Tp __c = _Tp())
|
resize(size_type __sz, _Tp __c = _Tp())
|
||||||
{
|
{
|
||||||
__profcxx_vector_invalid_operator(this);
|
__profcxx_vector_invalid_operator(this);
|
||||||
_M_profile_resize(this, this->capacity(), __sz);
|
_M_profile_resize(this->capacity(), __sz);
|
||||||
_Base::resize(__sz, __c);
|
_Base::resize(__sz, __c);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
using _Base::shrink_to_fit;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using _Base::empty;
|
|
||||||
|
|
||||||
// element access:
|
// element access:
|
||||||
reference
|
reference
|
||||||
operator[](size_type __n) _GLIBCXX_NOEXCEPT
|
operator[](size_type __n) _GLIBCXX_NOEXCEPT
|
||||||
{
|
{
|
||||||
__profcxx_vector_invalid_operator(this);
|
__profcxx_vector_invalid_operator(this);
|
||||||
return _M_base()[__n];
|
return _M_base()[__n];
|
||||||
}
|
}
|
||||||
const_reference
|
const_reference
|
||||||
operator[](size_type __n) const _GLIBCXX_NOEXCEPT
|
operator[](size_type __n) const _GLIBCXX_NOEXCEPT
|
||||||
{
|
{
|
||||||
__profcxx_vector_invalid_operator(this);
|
__profcxx_vector_invalid_operator(this);
|
||||||
return _M_base()[__n];
|
return _M_base()[__n];
|
||||||
}
|
}
|
||||||
|
|
||||||
using _Base::at;
|
|
||||||
|
|
||||||
reference
|
|
||||||
front() _GLIBCXX_NOEXCEPT
|
|
||||||
{
|
|
||||||
return _Base::front();
|
|
||||||
}
|
|
||||||
|
|
||||||
const_reference
|
|
||||||
front() const _GLIBCXX_NOEXCEPT
|
|
||||||
{
|
|
||||||
return _Base::front();
|
|
||||||
}
|
|
||||||
|
|
||||||
reference
|
|
||||||
back() _GLIBCXX_NOEXCEPT
|
|
||||||
{
|
|
||||||
return _Base::back();
|
|
||||||
}
|
|
||||||
|
|
||||||
const_reference
|
|
||||||
back() const _GLIBCXX_NOEXCEPT
|
|
||||||
{
|
|
||||||
return _Base::back();
|
|
||||||
}
|
|
||||||
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// DR 464. Suggestion for new member functions in standard containers.
|
|
||||||
using _Base::data;
|
|
||||||
|
|
||||||
// 23.2.4.3 modifiers:
|
// 23.2.4.3 modifiers:
|
||||||
void
|
void
|
||||||
push_back(const _Tp& __x)
|
push_back(const _Tp& __x)
|
||||||
{
|
{
|
||||||
size_type __old_size = this->capacity();
|
size_type __old_size = this->capacity();
|
||||||
_Base::push_back(__x);
|
_Base::push_back(__x);
|
||||||
_M_profile_resize(this, __old_size, this->capacity());
|
_M_profile_resize(__old_size, this->capacity());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
void
|
void
|
||||||
push_back(_Tp&& __x)
|
push_back(_Tp&& __x)
|
||||||
{
|
{
|
||||||
size_type __old_size = this->capacity();
|
size_type __old_size = this->capacity();
|
||||||
_Base::push_back(std::move(__x));
|
_Base::push_back(std::move(__x));
|
||||||
_M_profile_resize(this, __old_size, this->capacity());
|
_M_profile_resize(__old_size, this->capacity());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
insert(const_iterator __position, const _Tp& __x)
|
insert(const_iterator __pos, const _Tp& __x)
|
||||||
#else
|
#else
|
||||||
insert(iterator __position, const _Tp& __x)
|
insert(iterator __pos, const _Tp& __x)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
__profcxx_vector_insert(this, __position.base() - _Base::begin(),
|
__profcxx_vector_insert(this, __pos.base() - _Base::begin(),
|
||||||
this->size());
|
this->size());
|
||||||
size_type __old_size = this->capacity();
|
size_type __old_size = this->capacity();
|
||||||
_Base_iterator __res = _Base::insert(__position.base(), __x);
|
_Base_iterator __res = _Base::insert(__pos.base(), __x);
|
||||||
_M_profile_resize(this, __old_size, this->capacity());
|
_M_profile_resize(__old_size, this->capacity());
|
||||||
return iterator(__res, this);
|
return iterator(__res, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
iterator
|
iterator
|
||||||
insert(const_iterator __position, _Tp&& __x)
|
insert(const_iterator __pos, _Tp&& __x)
|
||||||
{
|
{
|
||||||
__profcxx_vector_insert(this, __position.base() - _Base::cbegin(),
|
__profcxx_vector_insert(this, __pos.base() - _Base::cbegin(),
|
||||||
this->size());
|
this->size());
|
||||||
size_type __old_size = this->capacity();
|
size_type __old_size = this->capacity();
|
||||||
_Base_iterator __res = _Base::insert(__position.base(), __x);
|
_Base_iterator __res = _Base::insert(__pos.base(), __x);
|
||||||
_M_profile_resize(this, __old_size, this->capacity());
|
_M_profile_resize(__old_size, this->capacity());
|
||||||
return iterator(__res, this);
|
return iterator(__res, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... _Args>
|
template<typename... _Args>
|
||||||
iterator
|
iterator
|
||||||
emplace(const_iterator __position, _Args&&... __args)
|
emplace(const_iterator __pos, _Args&&... __args)
|
||||||
{
|
{
|
||||||
_Base_iterator __res = _Base::emplace(__position.base(),
|
_Base_iterator __res = _Base::emplace(__pos.base(),
|
||||||
std::forward<_Args>(__args)...);
|
std::forward<_Args>(__args)...);
|
||||||
return iterator(__res, this);
|
return iterator(__res, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
insert(const_iterator __position, initializer_list<value_type> __l)
|
insert(const_iterator __pos, initializer_list<value_type> __l)
|
||||||
{ return this->insert(__position, __l.begin(), __l.end()); }
|
{ return this->insert(__pos, __l.begin(), __l.end()); }
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
void
|
|
||||||
swap(vector&& __x)
|
|
||||||
{
|
|
||||||
_Base::swap(__x);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
swap(vector& __x)
|
swap(vector& __x)
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
noexcept(_Alloc_traits::_S_nothrow_swap())
|
noexcept( noexcept(declval<_Base>().swap(__x)) )
|
||||||
#endif
|
#endif
|
||||||
{
|
{ _Base::swap(__x); }
|
||||||
_Base::swap(__x);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
iterator
|
iterator
|
||||||
insert(const_iterator __position, size_type __n, const _Tp& __x)
|
insert(const_iterator __pos, size_type __n, const _Tp& __x)
|
||||||
{
|
{
|
||||||
__profcxx_vector_insert(this, __position.base() - _Base::cbegin(),
|
__profcxx_vector_insert(this, __pos.base() - _Base::cbegin(),
|
||||||
this->size());
|
this->size());
|
||||||
size_type __old_size = this->capacity();
|
size_type __old_size = this->capacity();
|
||||||
_Base_iterator __res = _Base::insert(__position, __n, __x);
|
_Base_iterator __res = _Base::insert(__pos, __n, __x);
|
||||||
_M_profile_resize(this, __old_size, this->capacity());
|
_M_profile_resize(__old_size, this->capacity());
|
||||||
return iterator(__res, this);
|
return iterator(__res, this);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void
|
void
|
||||||
insert(iterator __position, size_type __n, const _Tp& __x)
|
insert(iterator __pos, size_type __n, const _Tp& __x)
|
||||||
{
|
{
|
||||||
__profcxx_vector_insert(this, __position.base() - _Base::begin(),
|
__profcxx_vector_insert(this, __pos.base() - _Base::begin(),
|
||||||
this->size());
|
this->size());
|
||||||
size_type __old_size = this->capacity();
|
size_type __old_size = this->capacity();
|
||||||
_Base::insert(__position, __n, __x);
|
_Base::insert(__pos, __n, __x);
|
||||||
_M_profile_resize(this, __old_size, this->capacity());
|
_M_profile_resize(__old_size, this->capacity());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -447,40 +403,37 @@ namespace __profile
|
||||||
template<typename _InputIterator,
|
template<typename _InputIterator,
|
||||||
typename = std::_RequireInputIter<_InputIterator>>
|
typename = std::_RequireInputIter<_InputIterator>>
|
||||||
iterator
|
iterator
|
||||||
insert(const_iterator __position,
|
insert(const_iterator __pos,
|
||||||
_InputIterator __first, _InputIterator __last)
|
_InputIterator __first, _InputIterator __last)
|
||||||
{
|
{
|
||||||
__profcxx_vector_insert(this, __position.base() - _Base::cbegin(),
|
__profcxx_vector_insert(this, __pos.base() - _Base::cbegin(),
|
||||||
this->size());
|
this->size());
|
||||||
size_type __old_size = this->capacity();
|
size_type __old_size = this->capacity();
|
||||||
_Base_iterator __res = _Base::insert(__position, __first, __last);
|
_Base_iterator __res = _Base::insert(__pos, __first, __last);
|
||||||
_M_profile_resize(this, __old_size, this->capacity());
|
_M_profile_resize(__old_size, this->capacity());
|
||||||
return iterator(__res, this);
|
return iterator(__res, this);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
template<typename _InputIterator>
|
template<typename _InputIterator>
|
||||||
void
|
void
|
||||||
insert(iterator __position,
|
insert(iterator __pos,
|
||||||
_InputIterator __first, _InputIterator __last)
|
_InputIterator __first, _InputIterator __last)
|
||||||
{
|
{
|
||||||
__profcxx_vector_insert(this, __position.base() - _Base::begin(),
|
__profcxx_vector_insert(this, __pos.base() - _Base::begin(),
|
||||||
this->size());
|
this->size());
|
||||||
size_type __old_size = this->capacity();
|
size_type __old_size = this->capacity();
|
||||||
_Base::insert(__position, __first, __last);
|
_Base::insert(__pos, __first, __last);
|
||||||
_M_profile_resize(this, __old_size, this->capacity());
|
_M_profile_resize(__old_size, this->capacity());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
erase(const_iterator __position)
|
erase(const_iterator __pos)
|
||||||
#else
|
#else
|
||||||
erase(iterator __position)
|
erase(iterator __pos)
|
||||||
#endif
|
#endif
|
||||||
{
|
{ return iterator(_Base::erase(__pos.base()), this); }
|
||||||
_Base_iterator __res = _Base::erase(__position.base());
|
|
||||||
return iterator(__res, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
|
|
@ -488,76 +441,66 @@ namespace __profile
|
||||||
#else
|
#else
|
||||||
erase(iterator __first, iterator __last)
|
erase(iterator __first, iterator __last)
|
||||||
#endif
|
#endif
|
||||||
{
|
{ return iterator(_Base::erase(__first.base(), __last.base()), this); }
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 151. can't currently clear() empty container
|
|
||||||
_Base_iterator __res = _Base::erase(__first.base(), __last.base());
|
|
||||||
return iterator(__res, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
clear() _GLIBCXX_NOEXCEPT
|
clear() _GLIBCXX_NOEXCEPT
|
||||||
{
|
{
|
||||||
__profcxx_vector_destruct(this, this->capacity(), this->size());
|
this->_M_profile_destruct();
|
||||||
__profcxx_vector_destruct2(this);
|
_Base::clear();
|
||||||
_Base::clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void _M_profile_find() const
|
inline void _M_profile_find() const
|
||||||
{
|
{ __profcxx_vector_find(this, this->size()); }
|
||||||
__profcxx_vector_find(this, size());
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void _M_profile_iterate(int __rewind = 0) const
|
inline void _M_profile_iterate(int __rewind = 0) const
|
||||||
{
|
{ __profcxx_vector_iterate(this); }
|
||||||
__profcxx_vector_iterate(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _M_profile_resize(void* obj, size_type __old_size,
|
void _M_profile_resize(size_type __old_size, size_type __new_size)
|
||||||
size_type __new_size)
|
|
||||||
{
|
{
|
||||||
if (__old_size < __new_size) {
|
if (__old_size < __new_size)
|
||||||
__profcxx_vector_resize(this, this->size(), __new_size);
|
{
|
||||||
__profcxx_vector_resize2(this, this->size(), __new_size);
|
__profcxx_vector_resize(this, this->size(), __new_size);
|
||||||
}
|
__profcxx_vector_resize2(this, this->size(), __new_size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename _Tp, typename _Alloc>
|
template<typename _Tp, typename _Alloc>
|
||||||
inline bool
|
inline bool
|
||||||
operator==(const vector<_Tp, _Alloc>& __lhs,
|
operator==(const vector<_Tp, _Alloc>& __lhs,
|
||||||
const vector<_Tp, _Alloc>& __rhs)
|
const vector<_Tp, _Alloc>& __rhs)
|
||||||
{ return __lhs._M_base() == __rhs._M_base(); }
|
{ return __lhs._M_base() == __rhs._M_base(); }
|
||||||
|
|
||||||
template<typename _Tp, typename _Alloc>
|
template<typename _Tp, typename _Alloc>
|
||||||
inline bool
|
inline bool
|
||||||
operator!=(const vector<_Tp, _Alloc>& __lhs,
|
operator!=(const vector<_Tp, _Alloc>& __lhs,
|
||||||
const vector<_Tp, _Alloc>& __rhs)
|
const vector<_Tp, _Alloc>& __rhs)
|
||||||
{ return __lhs._M_base() != __rhs._M_base(); }
|
{ return __lhs._M_base() != __rhs._M_base(); }
|
||||||
|
|
||||||
template<typename _Tp, typename _Alloc>
|
template<typename _Tp, typename _Alloc>
|
||||||
inline bool
|
inline bool
|
||||||
operator<(const vector<_Tp, _Alloc>& __lhs,
|
operator<(const vector<_Tp, _Alloc>& __lhs,
|
||||||
const vector<_Tp, _Alloc>& __rhs)
|
const vector<_Tp, _Alloc>& __rhs)
|
||||||
{ return __lhs._M_base() < __rhs._M_base(); }
|
{ return __lhs._M_base() < __rhs._M_base(); }
|
||||||
|
|
||||||
template<typename _Tp, typename _Alloc>
|
template<typename _Tp, typename _Alloc>
|
||||||
inline bool
|
inline bool
|
||||||
operator<=(const vector<_Tp, _Alloc>& __lhs,
|
operator<=(const vector<_Tp, _Alloc>& __lhs,
|
||||||
const vector<_Tp, _Alloc>& __rhs)
|
const vector<_Tp, _Alloc>& __rhs)
|
||||||
{ return __lhs._M_base() <= __rhs._M_base(); }
|
{ return __lhs._M_base() <= __rhs._M_base(); }
|
||||||
|
|
||||||
template<typename _Tp, typename _Alloc>
|
template<typename _Tp, typename _Alloc>
|
||||||
inline bool
|
inline bool
|
||||||
operator>=(const vector<_Tp, _Alloc>& __lhs,
|
operator>=(const vector<_Tp, _Alloc>& __lhs,
|
||||||
const vector<_Tp, _Alloc>& __rhs)
|
const vector<_Tp, _Alloc>& __rhs)
|
||||||
{ return __lhs._M_base() >= __rhs._M_base(); }
|
{ return __lhs._M_base() >= __rhs._M_base(); }
|
||||||
|
|
||||||
template<typename _Tp, typename _Alloc>
|
template<typename _Tp, typename _Alloc>
|
||||||
inline bool
|
inline bool
|
||||||
operator>(const vector<_Tp, _Alloc>& __lhs,
|
operator>(const vector<_Tp, _Alloc>& __lhs,
|
||||||
const vector<_Tp, _Alloc>& __rhs)
|
const vector<_Tp, _Alloc>& __rhs)
|
||||||
{ return __lhs._M_base() > __rhs._M_base(); }
|
{ return __lhs._M_base() > __rhs._M_base(); }
|
||||||
|
|
||||||
template<typename _Tp, typename _Alloc>
|
template<typename _Tp, typename _Alloc>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue