Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/container/mdspan/swap2"

From cppreference.com
< cpp‎ | container‎ | mdspan
m (fix links.)
(note that this is a hidden friend)
Line 1: Line 1:
{{cpp/title|swap(std::mdspan)}}
+
{{title|swap{{small|(std::mdspan)}}}}
 
{{cpp/container/mdspan/navbar}}
 
{{cpp/container/mdspan/navbar}}
  
{{ddcl|header=mdspan|since=c++23|
+
{{ddcl|since=c++23|
 
friend constexpr void swap( mdspan& x, mdspan& y ) noexcept;
 
friend constexpr void swap( mdspan& x, mdspan& y ) noexcept;
 
}}
 
}}
Line 14: Line 14:
 
std::swap(x.acc_, y.acc_);
 
std::swap(x.acc_, y.acc_);
 
}}
 
}}
 +
 +
{{cpp/hidden friend|std::mdspan}}
  
 
===Parameters===
 
===Parameters===

Revision as of 08:49, 18 October 2024

 
 
 
 
friend constexpr void swap( mdspan& x, mdspan& y ) noexcept;
(since C++23)

Overloads the std::swap algorithm for std::mdspan. Exchanges the state of x with that of y.

Given ptr_, map_, and acc_ as exposition-only data members, equivalent to:

std::swap(x.ptr_, y.ptr_);
std::swap(x.map_, y.map_);
std::swap(x.acc_, y.acc_);

This function is not visible to ordinary unqualified or qualified lookup, and can only be found by argument-dependent lookup when std::mdspan is an associated class of the arguments.

Contents

Parameters

x, y - mdspan objects whose states to swap

Return value

(none)

Example

See also