Namensräume
Varianten
Aktionen

decltype specifier

Aus cppreference.com
< cpp‎ | language

 
 
Sprache C + +
Allgemeine Themen
Original:
General topics
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Flusskontrolle
Original:
Flow control
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Bedingte Ausführung Aussagen
Original:
Conditional execution statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Iterationsanweisungen
Original:
Iteration statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Gehe Aussagen
Original:
Jump statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Funktionen
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Funktion Erklärung
Lambda-Funktion Erklärung
Funktions-Template
inline-Spezifizierer
Exception-Spezifikationen (veraltet)
noexcept Spezifizierer (C++11)
Ausnahmen
Original:
Exceptions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Namespaces
Original:
Namespaces
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Types
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
decltype specifier (C++11)
Specifiers
Original:
Specifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
cv Planer
Lagerdauer Planer
constexpr Spezifizierer (C++11)
auto Spezifizierer (C++11)
alignas Spezifizierer (C++11)
Initialisierung
Original:
Initialization
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Literale
Original:
Literals
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Expressions
Original:
Expressions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
alternative Darstellungen
Utilities
Original:
Utilities
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Types
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
typedef declaration
Typ Aliasdeklaration (C++11)
Attribute (C++11)
Wirft
Original:
Casts
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
impliziten Konvertierungen
const_cast conversion
static_cast conversion
dynamic_cast conversion
reinterpret_cast conversion
C-Stil und funktionale Besetzung
Speicherzuweisung
Original:
Memory allocation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Classes
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Class-spezifische Funktion Eigenschaften
Original:
Class-specific function properties
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
explizit (C++11)
statisch
Besondere Member-Funktionen
Original:
Special member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Templates
Original:
Templates
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Klassen-Template
Funktions-Template
Template-Spezialisierung
Parameter Packs (C++11)
Verschiedenes
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Inline Montage
 
Überprüft den deklarierten Typ eines Unternehmens oder fragt den Rückgabetyp eines Ausdrucks .
Original:
Inspects the declared type of an entity or queries the return type of an expression.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Inhaltsverzeichnis

[Bearbeiten] Syntax

decltype ( entity ) (1) (seit C++11)
decltype ( expression ) (2) (seit C++11)

[Bearbeiten] Erklärung

1)
Wenn das Argument ist entweder die unparenthesised Namen eines Objekts / Funktion, oder ein Mitglied Zugang Ausdruck (object.member oder pointer->member), dann die decltype gibt den deklarierten Typ des entity durch diesen Ausdruck angegeben .
Original:
If the argument is either the unparenthesised name of an object/function, or is a member access expression (object.member or pointer->member), then the decltype specifies the declared type of the entity specified by this expression.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
Wenn das Argument eine andere Ausdruck des Typs T, dann
Original:
If the argument is any other expression of type T, then
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
a)
wenn die Value-Kategorie der expression ist xWert, dann die decltype gibt T&&
Original:
if the Value-Kategorie of expression is xvalue, then the decltype specifies T&&
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
b)
wenn der Wert Kategorie expression ist lvalue, dann die decltype gibt T&
Original:
if the value category of expression is lvalue, then the decltype specifies T&
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
c)
Andernfalls gibt decltype T
Original:
otherwise, decltype specifies T
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Beachten Sie, dass, wenn der Name eines Objekts parenthesised es ein L-Wert Ausdruck wird damit decltype(arg) und decltype((arg)) sind oft verschiedene Arten .
Original:
Note that if the name of an object is parenthesised, it becomes an lvalue expression, thus decltype(arg) and decltype((arg)) are often different types.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
decltype ist nützlich bei der Deklaration von Typen, die nur schwer oder gar nicht zu erklären, unter Verwendung von Standard-Notation, wie Lambda-verwandte Typen oder Arten, die auf Template-Parameter abhängig sind .
Original:
decltype is useful when declaring types that are difficult or impossible to declare using standard notation, like lambda-related types or types that depend on template parameters.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[Bearbeiten] Keywords

decltype

[Bearbeiten] Beispiel

#include <iostream>
 
struct A {
   double x;
};
const A* a = new A();
 
decltype( a->x ) x3;       // type of x3 is double (declared type)
decltype((a->x)) x4 = x3;  // type of x4 is const double& (lvalue expression)
 
template <class T, class U>
auto add(T t, U u) -> decltype(t + u); // return type depends on template parameters
 
int main() 
{
    int i = 33;
    decltype(i) j = i*2;
 
    std::cout << "i = " << i << ", "
              << "j = " << j << '\n';
 
    auto f = [](int a, int b) -> int {
       return a*b;
    };
 
    decltype(f) f2{f}; // the type of a lambda function is unique and unnamed
    i = f(2, 2);
    j = f2(3, 3);
 
    std::cout << "i = " << i << ", "
              << "j = " << j << '\n';
}

Output:

i = 33, j = 66
i = 4, j = 9

[Bearbeiten] Siehe auch

(C++11)
erhält die Art des Ausdrucks in unevaluierten Kontext
Original:
obtains the type of expression in unevaluated context
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(Funktions-Template) [edit]