std::experimental::ranges:: is_swappable_with, std::experimental::ranges:: is_swappable, std::experimental::ranges:: is_nothrow_swappable_with, std::experimental::ranges:: is_nothrow_swappable
From cppreference.net
<
cpp
|
experimental
|
ranges
|
template
<
class
T,
class
U
>
struct is_swappable_with ; |
(1) | (ranges TS) |
|
template
<
class
T
>
struct is_swappable ; |
(2) | (ranges TS) |
|
template
<
class
T,
class
U
>
struct is_nothrow_swappable_with ; |
(3) | (ranges TS) |
|
template
<
class
T
>
struct is_nothrow_swappable ; |
(4) | (ranges TS) |
1)
표현식
ranges::
swap
(
std::
declval
<
T
>
(
)
,
std::
declval
<
U
>
(
)
)
와
ranges::
swap
(
std::
declval
<
U
>
(
)
,
std::
declval
<
T
>
(
)
)
가 모두 평가되지 않은 피연산자로 취급될 때 형식이 잘 구성된 경우, 멤버 상수
value
를
true
와 같게 제공합니다. 그렇지 않으면,
value
는
false
입니다.
접근 검사
는 두 타입 모두와 관련 없는 컨텍스트에서 수행된 것처럼 실행됩니다.
2)
만약
T
가 참조 가능한 타입이 아닌 경우(즉, 가능하게 cv 한정자
void
또는
cv-qualifier-seq
또는
ref-qualifier
를 가진 함수 타입),
value
멤버 상수를
false
와 동일하게 제공합니다. 그렇지 않으면,
value
멤버 상수를
ranges
::
is_swappable_with
<
T
&
, T
&
>
::
value
와 동일하게 제공합니다.
3)
(1)
과 동일하지만,
(1)
의 두 표현식 평가가 예외를 발생시키지 않는 것으로 알려져 있습니다.
4)
(2)
와 동일하지만,
is_nothrow_swappable_with
를 사용합니다.
T
와
U
는 각각 완전한 형식(possibly cv-qualified)
void
이거나 경계를 알 수 없는 배열이어야 합니다. 그렇지 않으면 동작은 정의되지 않습니다.
목차 |
헬퍼 변수 템플릿
|
template
<
class
T,
class
U
>
constexpr bool is_swappable_with_v = is_swappable_with < T, U > :: value ; |
(1) | (ranges TS) |
|
template
<
class
T
>
constexpr bool is_swappable_v = is_swappable < T > :: value ; |
(2) | (ranges TS) |
|
template
<
class
T,
class
U
>
constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with < T, U > :: value ; |
(3) | (ranges TS) |
|
template
<
class
T
>
constexpr bool is_nothrow_swappable_v = is_nothrow_swappable < T > :: value ; |
(4) | (ranges TS) |
std:: integral_constant 로부터 상속됨
멤버 상수
|
value
[static]
|
true
만약
T
가
U
와 교환 가능한 경우,
false
그렇지 않은 경우
(public static member constant) |
멤버 함수
|
operator bool
|
객체를
bool
로 변환,
value
반환
(public member function) |
|
operator()
(C++14)
|
value
반환
(public member function) |
멤버 타입
| 타입 | 정의 |
value_type
|
bool |
type
|
std:: integral_constant < bool , value > |
참고 사항
이 특성은 swap 표현식의 직접적인 문맥 외부의 어떤 것도 확인하지 않습니다:
T
또는
U
의 사용이 템플릿 특수화, 암시적으로 정의된 특수 멤버 함수의 생성 등을 트리거하고, 그것들에 오류가 있는 경우,
ranges::is_swappable_with<T,U>::value
가 컴파일되고
true
로 평가되더라도 실제 swap은 컴파일되지 않을 수 있습니다.
예제
|
이 섹션은 불완전합니다
이유: 예제가 없음 |
참고 항목
|
타입이 교환 가능하거나 두 타입이 서로 교환될 수 있음을 명시함
(concept) |
|
|
(C++17)
(C++17)
(C++17)
(C++17)
|
한 타입의 객체가 동일한 타입이나 다른 타입의 객체와 교환될 수 있는지 확인함
(class template) |