::reference::operator= de<bool>vectoriales
Asigna un valor booleano en bit o el valor almacenado por un elemento hace referencia a un bit.
reference& operator=(
const reference& _Right
);
reference& operator=(
bool _Val
);
Parámetros
_Right
La referencia del elemento cuyo valor se asigna al bit._Val
Valor booleano que se asignará al bit.
Valor devuelto
El valor booleano señalado o referencia.
Ejemplo
// vector_bool_ref_op_assign.cpp
// compile with: /EHsc
#include <vector>
#include <iostream>
class MyAlloc{};
int main( )
{
using namespace std;
typedef vector<bool> boolvector;
boolvector v;
bool b1, b2;
v.push_back( false );
v.push_back( true );
boolvector::reference ref1 = v.at( 0 );
boolvector::reference ref2 = v.at( 1 );
b1 = ref1;
b2 = ref2;
cout << "The initial value of the 1st element was: " << b1 << endl;
cout << "The initial value of the 2nd element was: " << b2 << endl;
ref2.operator=( ref1 );
b2 = ref2;
cout << "The value of the 2nd element is now: " << b2 << endl;
ref1.operator=( true );
b1 = bool( ref1 );
cout << "The value of the 1st element is now: " << b1 << endl;
}
Requisitos
encabezado: <vector>
espacio de nombres: std