If #defined _RWSTD_NO_PART_SPEC_OVERLOAD the functions
std::swap (std::container&, std::container&) is not defined (where
container is vector, list, string, deque, ...).
They may be defined the same way, as in the MSVC 7.0 STL:
class container
{
public:
friend void swap (container& __lhs, container& __rhs)
{
__lhs.swap (__rhs);
}
};
I have been added this functions with additional test
(etc/config/src/INLINE_FRIENDS.cpp).
ChangeLog:
* INLINE_FRIENDS.cpp: New file checking the inline friend functions
* deque: Added #ifndef _RWSTD_NO_PART_SPEC_OVERLOAD/#endif around the
function std::swap<T, A> (std::deque<T, A>&, std::deque<T, A>&);
[_RWSTD_NO_PART_SPEC_OVERLOAD && !_RWSTD_NO_INLINE_FRIENDS]:
Added function std::swap (std::deque&, std::deque&)
* list [_RWSTD_NO_PART_SPEC_OVERLOAD && !_RWSTD_NO_INLINE_FRIENDS]:
Added function std::swap (std::list&, std::list&)
* map [_RWSTD_NO_PART_SPEC_OVERLOAD && !_RWSTD_NO_INLINE_FRIENDS]:
Added functions std::swap (std::map&, std::map&) and
std::swap (std::multimap&, std::multimap&)
* set [_RWSTD_NO_PART_SPEC_OVERLOAD && !_RWSTD_NO_INLINE_FRIENDS]:
Added functions std::swap (std::set&, std::set&) and
std::swap (std::multiset&, std::multiset&)
* string [_RWSTD_NO_PART_SPEC_OVERLOAD && !_RWSTD_NO_INLINE_FRIENDS]:
Added function std::swap (std::string&, std::string&)
* vector [_RWSTD_NO_PART_SPEC_OVERLOAD && !_RWSTD_NO_INLINE_FRIENDS]:
Added functions std::swap (std::vector&, std::vector&) and
std::swap (std::vector<bool>&, std::vector<bool>&)
Farid.
Index: etc/config/src/INLINE_FRIENDS.cpp
===================================================================
--- etc/config/src/INLINE_FRIENDS.cpp (revision 0)
+++ etc/config/src/INLINE_FRIENDS.cpp (revision 0)
@@ -0,0 +1,24 @@
+// checking for inline friends
+
+struct A
+{
+ friend void foo (A) { }
+};
+
+
+template <class T>
+struct B
+{
+ friend void foo (B) { }
+};
+
+
+// check that friends are usable
+void foo (A a, B<int> b, B<A> ba)
+{
+ foo (a);
+
+ foo (b);
+
+ foo (ba);
+}
Index: include/deque
===================================================================
--- include/deque (revision 450357)
+++ include/deque (working copy)
@@ -651,6 +651,16 @@
_RWSTD_ASSERT (_C_is_valid (1 /* valid and empty */));
}
+#if defined (_RWSTD_NO_PART_SPEC_OVERLOAD) && \
+ !defined (_RWSTD_NO_INLINE_FRIENDS)
+
+ friend void swap (deque& __lhs, deque& __rhs)
+ {
+ __lhs.swap (__rhs);
+ }
+#endif
+
+
private:
//////////////////////////////////////////////////////////////////
@@ -983,6 +993,8 @@
}
+#ifndef _RWSTD_NO_PART_SPEC_OVERLOAD
+
template <class _TypeT, class _Allocator>
inline void
swap (deque<_TypeT, _Allocator> &__lhs, deque<_TypeT, _Allocator> &__rhs)
@@ -990,6 +1002,7 @@
__lhs.swap (__rhs);
}
+#endif // _RWSTD_NO_PART_SPEC_OVERLOAD
} // namespace end
Index: include/list
===================================================================
--- include/list (revision 450357)
+++ include/list (working copy)
@@ -664,6 +664,15 @@
erase (begin (), end ());
}
+#if defined (_RWSTD_NO_PART_SPEC_OVERLOAD) && \
+ !defined (_RWSTD_NO_INLINE_FRIENDS)
+
+ friend void swap (list& __lhs, list& __rhs)
+ {
+ __lhs.swap (__rhs);
+ }
+#endif
+
protected:
void _C_transfer (iterator, iterator, iterator, list&);
Index: include/map
===================================================================
--- include/map (revision 450357)
+++ include/map (working copy)
@@ -300,6 +300,16 @@
equal_range (const key_type& __x) const {
return _C_rep.equal_range (__x);
}
+
+#if defined (_RWSTD_NO_PART_SPEC_OVERLOAD) && \
+ !defined (_RWSTD_NO_INLINE_FRIENDS)
+
+ friend void swap (map& __lhs, map& __rhs)
+ {
+ __lhs.swap (__rhs);
+ }
+#endif
+
};
@@ -529,6 +539,16 @@
equal_range (const key_type& __x) const {
return _C_rep.equal_range (__x);
}
+
+#if defined (_RWSTD_NO_PART_SPEC_OVERLOAD) && \
+ !defined (_RWSTD_NO_INLINE_FRIENDS)
+
+ friend void swap (multimap& __lhs, multimap& __rhs)
+ {
+ __lhs.swap (__rhs);
+ }
+#endif
+
};
Index: include/set
===================================================================
--- include/set (revision 450357)
+++ include/set (working copy)
@@ -301,6 +301,16 @@
equal_range (const key_type& __x) const {
return _C_rep.equal_range (__x);
}
+
+#if defined (_RWSTD_NO_PART_SPEC_OVERLOAD) && \
+ !defined (_RWSTD_NO_INLINE_FRIENDS)
+
+ friend void swap (set& __lhs, set& __rhs)
+ {
+ __lhs.swap (__rhs);
+ }
+#endif
+
};
@@ -505,6 +515,16 @@
equal_range (const key_type& __x) const {
return _C_rep.equal_range (__x);
}
+
+#if defined (_RWSTD_NO_PART_SPEC_OVERLOAD) && \
+ !defined (_RWSTD_NO_INLINE_FRIENDS)
+
+ friend void swap (multiset& __lhs, multiset& __rhs)
+ {
+ __lhs.swap (__rhs);
+ }
+#endif
+
};
Index: include/string
===================================================================
--- include/string (revision 450357)
+++ include/string (working copy)
@@ -823,6 +823,15 @@
// lwg Issue 5
int compare (size_type, size_type, const_pointer, size_type) const;
+#if defined (_RWSTD_NO_PART_SPEC_OVERLOAD) && \
+ !defined (_RWSTD_NO_INLINE_FRIENDS)
+
+ friend void swap (basic_string& __lhs, basic_string& __rhs)
+ {
+ __lhs.swap (__rhs);
+ }
+#endif
+
#if !defined (_RWSTD_NO_INLINE_MEMBER_TEMPLATES)
\
&& (!defined (_MSC_VER) || _MSC_VER >= 1300 || defined (__INTEL_COMPILER))
\
&& defined (_RWSTD_NO_MEMBER_TEMPLATES)
Index: include/vector
===================================================================
--- include/vector (revision 450357)
+++ include/vector (working copy)
@@ -370,6 +370,15 @@
erase (begin (), end ());
}
+#if defined (_RWSTD_NO_PART_SPEC_OVERLOAD) && \
+ !defined (_RWSTD_NO_INLINE_FRIENDS)
+
+ friend void swap (vector& __lhs, vector& __rhs)
+ {
+ __lhs.swap (__rhs);
+ }
+#endif
+
private:
// implements assign with repetition
@@ -1432,6 +1441,16 @@
{
erase(begin(),end());
}
+
+#if defined (_RWSTD_NO_PART_SPEC_OVERLOAD) && \
+ !defined (_RWSTD_NO_INLINE_FRIENDS)
+
+ friend void swap (vector& __lhs, vector& __rhs)
+ {
+ __lhs.swap (__rhs);
+ }
+#endif
+
};
#undef _Allocator