std::shared_ptr
|
|
Esta página se ha traducido por ordenador/computador/computadora de la versión en inglés de la Wiki usando Google Translate.
La traducción puede contener errores y palabras aparatosas/incorrectas. Planea sobre el texto para ver la versión original. Puedes ayudar a corregir los errores y mejorar la traducción. Para instrucciones haz clic aquí. |
| Definido en el archivo de encabezado <memory>
|
||
| template< class T > class shared_ptr; |
(desde C++11) | |
std::shared_ptr es un puntero inteligente que mantiene la propiedad compartida de un objeto a través de un puntero. Varios objetos shared_ptr pueden poseer el mismo objeto, el objeto se destruye cuando el shared_ptr último que queda apuntando a que se destruye o se restablece. El objeto se destruye usando delete-expression o un Deleter personalizado que se suministra a shared_ptr durante la construcción .std::shared_ptr is a smart pointer that retains shared ownership of an object through a pointer. Several shared_ptr objects may own the same object; the object is destroyed when the last remaining shared_ptr pointing to it is destroyed or reset. The object is destroyed using delete-expression or a custom deleter that is supplied to shared_ptr during construction.You can help to correct and verify the translation. Click here for instructions.
shared_ptr también puede poseer ningún objeto, en cuyo caso se llama vacío .shared_ptr may also own no objects, in which case it is called empty.You can help to correct and verify the translation. Click here for instructions.
shared_ptr cumple los requisitos de CopyConstructible y CopyAssignable .You can help to correct and verify the translation. Click here for instructions.
[editar] Tipos de miembros
| Miembro de tipo
Original: Member type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Definition |
| element_type | T |
[editar] Las funciones miembro
constructs new shared_ptr (función miembro pública) | |
| destruye la propiedad del objeto si no hay vínculo más shared_ptrs a ella Original: destructs the owned object if no more shared_ptrs link to it The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) | |
| asigna el shared_ptr Original: assigns the shared_ptr The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) | |
Original: Modifiers The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
| reemplaza el objeto administrado Original: replaces the managed object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) | |
| intercambia los objetos gestionados Original: swaps the managed objects The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) | |
Original: Observers The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
| devuelve un puntero al objeto gestionado Original: returns a pointer to the managed object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) | |
| desreferencia de puntero al objeto gestionado (función miembro pública) | |
| devuelve el número de objetos que se refieren a la shared_ptr objeto gestionado mismo Original: returns the number of shared_ptr objects referring to the same managed object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) | |
| Comprueba si el objeto administrado es manejado sólo por la instancia shared_ptr actual Original: checks whether the managed object is managed only by the current shared_ptr instance The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) | |
| comprueba si se asocia objeto administrado Original: checks if there is associated managed object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) | |
| proporciona propietario basado pedido de punteros compartidos Original: provides owner-based ordering of shared pointers The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) | |
[editar] Terceros funciones
| Crea un puntero compartido que gestiona un nuevo objeto. (plantilla de función) | |
| Crea un puntero compartido que gestiona un nuevo objeto asignado usando un asignador. (plantilla de función) | |
| Aplica static_cast, dynamic_cast, const_cast, o reinterpret_cast al puntero almacenado. (plantilla de función) | |
| Devuelve el eliminador del tipo especificado, si se posee. (plantilla de función) | |
| (eliminado en C++20)(eliminado en C++20)(eliminado en C++20)(eliminado en C++20)(eliminado en C++20)(C++20) |
Se compara con otro
|
| Emite el valor del puntero almacenado a un flujo de salida. (plantilla de función) | |
| (C++11) |
Especializa el algoritmo std::swap. (plantilla de función) |
| Especializa las operaciones atómicas para std::shared_ptr (plantilla de función) |
[editar] Clases de ayuda
| (C++11) |
Soporte hash para std::shared_ptr. (especialización de plantilla de clase) |
[editar] Notas de aplicación
You can help to correct and verify the translation. Click here for instructions.
- un puntero para el objeto de referenciaOriginal:a pointer to the referenced objectThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - un puntero a' bloque de controlOriginal:a pointer to control blockThe 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.
- un puntero al objeto gestionado o administrado el objeto en síOriginal:a pointer to the managed object or the managed object itselfThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - el DeleterOriginal:the deleterThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - el asignadorOriginal:the allocatorThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - el número de
shared_ptrs que poseen el objeto administradoOriginal:the number ofshared_ptrs that own the managed objectThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - el número de
weak_ptrs que se refieren al objeto administradoOriginal:the number ofweak_ptrs that refer to the managed objectThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
shared_ptr se crea llamando std::make_shared o std::allocate_shared, el bloque de control contiene el objeto administrado directamente, como un miembro de datos. Cuando shared_ptr se crea llamando a un constructor, un puntero se guarda .shared_ptr is created by calling std::make_shared or std::allocate_shared, the control block holds the managed object directly, as a data member. When shared_ptr is created by calling a constructor, a pointer is stored.You can help to correct and verify the translation. Click here for instructions.
shared_ptr directamente es la devuelta por get(), mientras que el puntero / object poder del bloque de control es el que se eliminarán cuando el número de propietarios compartidas llega a cero: estos indicadores no son necesariamente iguales .shared_ptr directly is the one returned by get(), while the pointer/object held by the control block is the one that will be deleted when the number of shared owners reaches zero: these pointers are not necessarily equal.You can help to correct and verify the translation. Click here for instructions.
shared_ptr disminuye el número de propietarios compartidos del bloque de control y, en caso de que llegue a cero, el bloque de control llama al destructor del objeto gestionado, pero el bloque de control no se desasigna hasta que el contador llegue a cero std::weak_ptr también .shared_ptr decrements the number of shared owners of the control block, and if that reaches zero, the control block calls the destructor of the managed object, but the control block does not deallocate itself until the std::weak_ptr counter reaches zero as well.You can help to correct and verify the translation. Click here for instructions.

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
