return type is a variable in a class

c++

Solution

The `type` in `typename tuple_element< I, tuple<Types...> >::type` is not a variable. It is a type within another type (`tuple_element< I, tuple<Types...> >`).

Referencing a type within another type can be done by using `::`, the scope resolution operator, just as you do when referencing a variable or function within a class or a namespace.

Example:

namespace my_namespace {

    struct my_type {
        typedef int some_type;  // some_type here is an alias for int (both are types)
    };   

}

int main() {
    my_namespace::my_type::some_type some_variable;
}

Problem

I am looking the C++ reference, and I see the ``` template <size_t I, class... Types> typename tuple_element< I, tuple<Types...> >::type const& get(const tuple<Types...>& tpl) noexcept; ``` and what I cannot understand is the the return type, what does the `typename tuple_element< I, tuple<Types...> >::type const&` means? My interpertation is that it return a const reference to a general type of `tuple_element::type` , but I think that the `tuple_element::type` is like below ``` Class A{ public: int B; } A::B = .........; ``` but why it can be used as a type? I cannot understand it.

Original source

Related problems