Namespaces
Variants

std:: vector<bool, Alloc>:: reference

From cppreference.net
class reference ;

std::vector < bool , Alloc > 특수화는 std::vector < bool , Alloc > :: reference 를 공개적으로 접근 가능한 중첩 클래스로 정의합니다. std::vector < bool , Alloc > :: reference std::vector < bool , Alloc > 내의 단일 비트에 대한 참조 동작을 대리합니다.

std::vector < bool , Alloc > :: reference 의 주요 용도는 operator [ ] 에서 반환될 수 있는 할당 가능한 값을 제공하는 것입니다.

std::vector < bool , Alloc > :: reference 를 통해 벡터에 수행되는 모든 읽기 또는 쓰기 작업은 잠재적으로 기본 벡터 전체를 읽거나 쓸 수 있습니다.

목차

멤버 함수

(constructor)
참조를 생성함
(public member function)
(destructor)
참조를 파괴함
(public member function)
operator=
참조된 비트에 값을 할당함
(public member function)
operator bool
참조된 비트를 반환함
(public member function)
flip
참조된 비트를 반전시킴
(public member function)

std::vector<bool, Alloc>::reference:: reference

reference ( const reference & ) = default ;
(C++11부터)
(C++20부터 constexpr)

다른 reference로부터 reference를 생성합니다. 복사 생성자는 암시적으로 선언됩니다. (C++11 이전)

다른 생성자들은 std::vector < bool , Alloc > 에 의해서만 접근 가능합니다.

std::vector<bool, Alloc>::reference:: ~reference

~reference ( ) ;
(constexpr since C++20)

참조자를 파괴합니다.

std::vector<bool, Alloc>::reference:: operator=

reference & operator = ( bool x ) ;
(1) (C++11부터 noexcept)
(C++20부터 constexpr)
constexpr const reference & operator = ( bool x ) const noexcept ;
(2) (C++23부터)
reference & operator = ( const reference & x ) ;
(3) (C++11부터 noexcept)
(C++20부터 constexpr)

참조된 비트에 값을 할당합니다.

const operator = std::vector<bool,Alloc>::iterator output_iterator 를 만족하도록 합니다.

(C++23부터)

매개변수

x - 할당할 값

반환 값

* this

std::vector<bool, Alloc>::reference:: operator bool

operator bool ( ) const ;
(noexcept since C++11)
(constexpr since C++20)

참조된 비트의 값을 반환합니다.

Return value

참조된 비트.

std::vector<bool, Alloc>::reference:: flip

void flip ( ) ;
(noexcept since C++11)
(constexpr since C++20)

참조된 비트를 반전시킵니다.

헬퍼 클래스

std:: formatter <std::vector<bool, Alloc>::reference>

template < class T, class CharT >

requires /*is-vector-bool-reference*/ < T >

struct formatter < T, CharT > ;
(C++23부터)

std::vector < bool , Alloc > :: reference 에 대한 std::formatter 특수화입니다. 이 특수화는 참조된 비트가 서식 지정을 위해 bool 로 변환되어 std:: formatter < bool , CharT > 을 기반 포매터( underlying_ 로 표시)로 사용합니다.

설명 전용 상수 /*is-vector-bool-reference*/ < T > T 가 어떤 타입 Alloc 에 대해 std::vector < bool , Alloc > :: reference 타입을 나타내고, std::vector < bool , Alloc > 프로그램 정의 특수화 가 아닌 경우에만 true 입니다.

멤버 함수

template < class ParseContext >
constexpr ParseContext :: iterator parse ( ParseContext & ctx ) ;
(1) (C++23부터)
template < class FormatContext >
FormatContext :: iterator format ( const T & r, FormatContext & ctx ) const ;
(2) (C++23부터)
1) return underlying_ . parse ( ctx ) ; 와 동등합니다.
2) return underlying_ . format ( r, ctx ) ; 와 동등합니다.

예제

참고 항목

지정된 요소에 접근
( std::vector<T,Allocator> 의 public member function)
[static]
두 개의 std::vector<bool>:: reference 를 교환
(public static member function)

외부 링크

Scott Meyers의 "Effective Modern C++"(2015), 2장 항목 6: "원치 않는 타입을 추론할 때는 명시적으로 타입을 지정하는 초기화 관용구를 사용하라" auto (p.43-46) — 프록시 클래스 std::vector<bool>::reference 의 가능한 오용에 대해 설명합니다.