Compare commits

..

2 Commits

Author SHA1 Message Date
Peter Dimov 6a9e8c78da Update documentation of swap. 2025-01-26 04:11:14 +02:00
Peter Dimov 55bc631d40 Remove use of core/invoke_swap 2025-01-26 04:08:06 +02:00
2 changed files with 12 additions and 11 deletions
+5 -5
View File
@@ -19,7 +19,7 @@ namespace boost {
template<typename T, std::size_t N> class array;
template<typename T, std::size_t N>
constexpr void swap(array<T, N>&, array<T, N>&);
void swap(array<T, N>&, array<T, N>&);
template<typename T, std::size_t N>
constexpr bool operator==(const array<T, N>&, const array<T, N>&);
@@ -120,7 +120,7 @@ public:
// modifiers
constexpr void swap(array<T, N>&);
swap(array<T, N>&);
constexpr void fill(const T&);
void assign(const T&); // deprecated
@@ -290,10 +290,10 @@ Remarks: :: This function is deprecated. Use `data()` instead.
### Modifiers
```
constexpr void swap(array<T, N>& other);
void swap(array<T, N>& other);
```
[horizontal]
Effects: :: for each `i` in `[0..N)`, calls `swap(elems[i], other.elems[i])`.
Effects: :: `std::swap(elems, other.elems)`.
Complexity: :: linear in `N`.
---
@@ -319,7 +319,7 @@ Remarks: :: An obsolete and deprecated spelling of `fill`. Use `fill` instead.
```
template<typename T, std::size_t N>
constexpr void swap(array<T, N>& x, array<T, N>& y);
void swap(array<T, N>& x, array<T, N>& y);
```
[horizontal]
Effects: :: `x.swap(y)`.
+7 -6
View File
@@ -43,12 +43,12 @@
#endif
#include <boost/assert.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/static_assert.hpp>
#include <boost/throw_exception.hpp>
#include <algorithm>
#include <iterator>
#include <stdexcept>
#include <utility>
#include <cstddef>
namespace boost {
@@ -143,9 +143,9 @@ namespace boost {
enum { static_size = N };
// swap (note: linear complexity)
BOOST_CXX14_CONSTEXPR void swap (array<T,N>& y) {
for (size_type i = 0; i < N; ++i)
boost::core::invoke_swap(elems[i],y.elems[i]);
BOOST_CXX14_CONSTEXPR void swap (array<T,N>& y)
{
std::swap( elems, y.elems );
}
// direct access to data
@@ -264,7 +264,8 @@ namespace boost {
static BOOST_CONSTEXPR size_type max_size() BOOST_NOEXCEPT { return 0; }
enum { static_size = 0 };
void swap (array<T,0>& /*y*/) {
BOOST_CXX14_CONSTEXPR void swap (array<T,0>& /*y*/)
{
}
// direct access to data
@@ -370,7 +371,7 @@ namespace boost {
// global swap()
template<class T, std::size_t N>
inline void swap (array<T,N>& x, array<T,N>& y) {
BOOST_CXX14_CONSTEXPR inline void swap (array<T,N>& x, array<T,N>& y) {
x.swap(y);
}