attribute specifier sequence(desde C++11)
Da cppreference.com
![]() |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
Introduz implementação atributos definidos para os tipos, objetos de código, etc
Original:
Introduces implementation-defined attributes for types, objects, code, etc.
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.
[[
attr]]
[[
attr1, attr2, attr3(
args)
]]
[[
namespace::
attr(
args)
]]
alignas_specifier
[editar] Explicação
Atributos fornecer a sintaxe padrão unificado para aplicação definida extensões de linguagem, como a GNU e extensões de linguagem IBM
__attribute__((...))
, extensão da Microsoft __declspec()
, etcOriginal:
Attributes provide the unified standard syntax for implementation-defined language extensions, such as the GNU and IBM language extensions
__attribute__((...))
, Microsoft extension __declspec()
, etc.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.
Um atributo pode ser usado em quase todo o programa em C + +, e pode ser aplicada a quase tudo: os tipos, para as variáveis, para as funções, para nomes, para blocos de código, para unidades de tradução inteiras, embora cada atributo especial só é válida onde é permitida pela aplicação:
[[probably(true)]]
só pode ser usado com um if, e não com uma declaração da classe. [[omp::parallel()]]
pode ser aplicado a um bloco de código ou de um loop for, mas não para o tipo int
, etcOriginal:
An attribute can be used almost everywhere in the C++ program, and can be applied to almost everything: to types, to variables, to functions, to names, to code blocks, to entire translation units, although each particular attribute is only valid where it is permitted by the implementation:
[[probably(true)]]
can only be used with an if, and not with an class declaration. [[omp::parallel()]]
can apply to a code block or to a for loop, but not to the type int
, etc.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.
Em declarações, os atributos podem aparecer antes e logo após o nome da entidade que é declarada, caso em que eles são combinados. Nas restantes situações, os atributos se aplicam à entidade diretamente anterior.
Original:
In declarations, attributes may appear both before and directly after the name of the entity that is declared, in which case they are combined. In most other situations, attributes apply to the directly preceding entity.
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.
alignas_specifier é uma parte da sequência de especificador atributo, embora tenha sintaxe diferente. Pode verificar-se onde os atributos
[[...]]
aparecer e pode misturar-se com eles (desde que seja utilizado em alignas é permitida)Original:
alignas_specifier is a part of the attribute specifier sequence, although it has different syntax. It may appear where the
[[...]]
attributes appear and may mix with them (provided it is used where alignas is permitted)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.
[editar] Atributos padrão
Apenas os dois seguintes atributos são definidos pelo padrão C + +. Todos os outros atributos são a implementação específica.
Original:
Only the following two attributes are defined by the C++ standard. All other attributes are implementation-specific.
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.
[[noreturn]]
|
Indica que a função não retorna.
Este atributo aplica-se a funcionar apenas as declarações. O comportamento é indefinido se a função com esse atributo na verdade, retorna. The seguintes funções padrão tem esse atributo: std::_Exit, std::abort, std::exit, std::quick_exit, std::unexpected, std::terminate, std::rethrow_exception, std::throw_with_nested, std::rethrow_nested Original: Indicates that the function does not return. This attribute applies to function declarations only. The behavior is undefined if the function with this attribute actually returns. The following standard functions have this attribute: std::_Exit, std::abort, std::exit, std::quick_exit, std::unexpected, std::terminate, std::rethrow_exception, std::throw_with_nested, std::rethrow_nested The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[[carries_dependency]]
|
Indica que a cadeia de dependência em liberação consumir std::memory_order propaga dentro e fora da função, o que permite ao compilador para ignorar desnecessária memória atributo instructions.
This cerca pode aparecer em duas situações: 1) que podem ser aplicadas às declarações de parâmetro de uma função ou expressões lambda-, caso em que se indica que a inicialização do parâmetro transporta dependência em lvalue para rvalue-conversão desse object. Original: Indicates that dependency chain in release-consume std::memory_order propagates in and out of the function, which allows the compiler to skip unnecessary memory fence instructions. This attribute may appear in two situations: 1) it may apply to the parameter declarations of a function or lambda-expressions, in which case it indicates that initialization of the parameter carries dependency into lvalue-to-rvalue conversion of that object. The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[editar] Exemplo
Esta seção está incompleta Motivo: sem exemplo |