Namespaces
Variants

boolean-testable

From cppreference.net
template < class B >
concept __boolean_testable_impl = std:: convertible_to < B, bool > ;
(1) (C++20 이후)
( 설명 전용* )
template < class B >

concept boolean - testable =
__boolean_testable_impl < B > &&
requires ( B && b ) {
{ ! std:: forward < B > ( b ) } - > __boolean_testable_impl ;

} ;
(2) (C++20 이후)
( 설명 전용* )

전시 전용(exposition-only) 개념 boolean-testable bool 로 변환 가능하고, 논리 연산자가 일반적인 동작(두 개의 서로 다른 boolean-testable 타입에 대해서도 단락 평가(short-circuiting) 포함)을 가지는 표현식에 대한 요구 사항을 명시합니다.

공식적으로, 설명 전용 개념 __boolean_testable_impl 을 모델링하려면 해당 타입은 어떤 멤버 operator && operator || 도 정의해서는 안 되며, 인수 종속 lookup 으로 보일 수 있는 유효한 비멤버 operator && operator || 도 존재해서는 안 됩니다. 추가적으로, e 의 표현식이 decltype ( ( e ) ) B 인 경우, boolean-testable bool ( e ) == ! bool ( ! e ) 인 경우에만 모델링됩니다.

동등성 보존

표준 라이브러리 개념의 requires expressions 에 선언된 표현식들은 equality-preserving 해야 합니다(다르게 명시된 경우를 제외하고).

참고 사항

boolean-testable 타입의 예시로는 bool , std::true_type , std:: bitset < N > :: reference , 그리고 int * 이 있습니다.

참조문헌

  • C++23 표준 (ISO/IEC 14882:2024):
  • 18.5.2 Boolean testability [concept.booleantestable]
  • C++20 표준 (ISO/IEC 14882:2020):
  • 18.5.2 불린 테스트 가능성 [concept.booleantestable]