In this code:
struct
{
auto operator[](const char*)
{
return *this;
}
} m_some_class;
What is type of auto
in here?
What is type of
auto
in here ?
The type is decltype(m_some_class)
- I.e., the return value is of the same type as the variable m_some_class
.
Note that the function will return a copy of *this
.
If a reference to *this
is wanted instead, you can use
auto&
or, since C++14, the more generic decltype(auto)
.