std::tuple_size and references

Viewed 532

My question is of the curious kind and quite short: Is there a good reason why there are no specializations of std::tuple_size for references?

(now the motivation)

I have a lot of code that looks like:

template<typename Tuple, typename Indices = 
    std::make_index_sequence<
        std::tuple_size<
            typename std::remove_reference<Tuple>::type>::value
        >
    >
auto func(Tuple&& t, ...) -> decltype(...) {
    return ...;
}

I hope using remove_reference is not the-wrong-way-to-do-it, but since it only works on type-level I see no problem here. Another possibilty would be to pass the tuples using std::move since then Tuple is not a reference, but since I only want to forward tuples I'd like to pass lvalue refs, too, so I used std::remove_reference.

It is not that bad, I was just curious why tuple_size doesn't work with reference types. Any idea?

1 Answers
Related