std::ios_base::xalloc
Da cppreference.com.
![]() | Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate. La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
staticint xalloc(); | ||
Restituisce un valore unico (programma-wide) indice che può essere utilizzato per accedere a un long e uno void* elementi l'ammasso privato chiamando
iword()
e pword()
. La chiamata a xalloc
non alloca la memoria.Original:
Returns an unique (program-wide) index value that can be used to access one long and one void* elements in the private storage by calling
iword()
and pword()
. The call to xalloc
does not allocate memory.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Indice |
[modifica]Parametri
(Nessuno)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[modifica]Valore di ritorno
intero univoco per uso come pword / iword index
Original:
unique integer for use as pword/iword index
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[modifica]Esempio
Utilizza memorizzazione classe base pword per l'identificazione tipo di runtime oggetti flusso derivati .
Original:
Uses base class pword storage for runtime type identification of derived stream objects.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
#include <iostream> template<class charT, class traits =std::char_traits<charT>>class mystream :publicstd::basic_ostream<charT, traits>{public:staticconstint xindex; mystream(std::basic_ostream<charT, traits>& ostr):std::basic_ostream<charT, traits>(ostr.rdbuf()){ this->pword(xindex)= this;} void myfn(){*this <<"[special handling for mystream]";}}; // each specialization of mystream obtains a unique index from xalloc()template<class charT, class traits>constint mystream<charT, traits>::xindex= std::ios_base::xalloc(); // This I/O manipulator will be able to recognize ostreams that are mystreams// by looking up the pointer stored in pwordtemplate<class charT, class traits>std::basic_ostream<charT,traits>& mymanip(std::basic_ostream<charT,traits>& os){if(os.pword(mystream<charT,traits>::xindex)==&os)static_cast<mystream<charT,traits>&>(os).myfn();return os;} int main(){std::cout<<"cout, narrow-character test "<< mymanip <<'\n'; mystream<char> myout(std::cout); myout <<"myout, narrow-character test "<< mymanip <<'\n'; std::wcout<<"wcout, wide-character test "<< mymanip <<'\n'; mystream<wchar_t> mywout(std::wcout); mywout <<"mywout, wide-character test "<< mymanip <<'\n';}
Output:
cout, narrow-character test myout, narrow-character test [special handling for mystream] wcout, wide-character test mywout, wide-character test [special handling for mystream]
[modifica]Vedi anche
ridimensiona l'ammasso privato e, se necessario, l'accesso all'elemento void* in corrispondenza dell'indice specificato Original: resizes the private storage if necessary and access to the void* element at the given index The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) | |
ridimensiona l'ammasso privato e, se necessario, l'accesso all'elemento long in corrispondenza dell'indice specificato Original: resizes the private storage if necessary and access to the long element at the given index The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) |