Home c++ What Returns DeclType and how does it work?

What Returns DeclType and how does it work?




Hello everyone. I began to recently study C++ and ran into the DeclType operator. As far as I know, the operators as well as the functions return a certain value, but reading the documentation on the Microsoft website (https://docs.microsoft.com/ru-ru/cpp/cpp/decltype-cpp?view=msvc-160 ) I saw the next line” decltype type descriptor Returns the type of specified expression. “. As far as I know the type, as a returned value, cannot be returned, but then how does this happen? Thank you in advance, I hope you will help.

Answer 1, Authority 100%

See, for example

int a;

I want to declare the variable of the same type as a

decltype (a) b;

Roughly – But to understand – DeclType (a) is replaced by the type with which A Decl AreD Type

Answer 2

decltype and has no return value, as this is not a function, but part of the type specifier. In essence, this design is related * (makes from the type on the left pointer or & amp; & amp; (makes from the type of RVALUE link). Unlike them, Delctype makes one type that has an expression in parentheses. In this case, the expression in parentheses is not executed (UNEVALUED CONTEXT).

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions