Top "Decltype" questions

decltype is a C++11 keyword that can be used to find the type of an expression.

Get the return type of a method from a member function pointer

I'm trying to declare a variable so that its type is the same as the return type of a member …

c++ typetraits member-function-pointers decltype
C++ decltype deducing current function returned type

I would like to automatically deduce the returned type of the function I'm writing. Example: std::vector<int> …

c++ c++11 types decltype type-deduction
Enlightening Usage of C++11 decltype

I've just seen this really nice talk Rock Hard: C++ Evolving by Boris Jabes. In the section of the talk …

c++ templates c++11 decltype
What is decltype with two arguments?

Edit, in order to avoid confusion: decltype does not accept two arguments. See answers. The following two structs can be …

c++ c++11 sfinae typetraits decltype
Initializing multiset with custom comparison function in C++

Consider following comparison function: bool compare(std::shared_ptr<myObject> &lhs, std::shared_ptr<myObject> &…

c++ decltype multiset
Detect operator support with decltype/SFINAE

A (somewhat) outdated article explores ways to use decltype along with SFINAE to detect if a type supports certain operators, …

c++ c++11 sfinae decltype
Member function call in decltype

The following code: struct A { int f(int); auto g(int x) -> decltype(f(x)); }; Fails to compile …

c++ c++11 decltype member-functions
Using auto and decltype to return reference from function in templated class

How can I coerce a function in a templated class to return a reference to a member variable using auto/…

c++ templates c++11 auto decltype
What is the type of decltype(this) in C++?

Apparently clang thinks decltype(this) is a pointer to the cv-qualified class, while gcc thinks it is a const reference …

c++ c++11 this decltype
Difference between decltype and typeof?

Two question regarding decltype and typeof: Is there any difference between the decltype and typeof operators? Does typeof become obsolete …

c++ c++11 typeof decltype