I looked at how it std::tuple_sizeis defined in the standard library of my system. I have a Mac OS and a compiler version Apple LLVM version 8.1.0 (clang-802.0.42). The standard library is in the location InstalledDirthat is displayedg++ --version
Given that the following code does not compile (because it clangdoesn’t like to specialize / re-declare something as structthat which was previously defined as classand vice versa)
#include <iostream>
#include <utility>
#include <array>
#include <tuple>
#include <type_traits>
using std::cout;
using std::endl;
template <class T>
class Something;
template <class One, class Two>
struct Something<std::pair<One, Two>>;
template <class One, class Two>
class Something<std::pair<One, Two>>
: public std::integral_constant<int, 2> {};
int main() {
cout << std::tuple_size<std::array<int, 2>>::value << endl;
cout << std::tuple_size<std::tuple<int, int>>::value << endl;
cout << std::tuple_size<std::pair<int, int>>::value << endl;
}
with the following error
error: struct template 'Something' was previously declared as a class template [-Werror,-Wmismatched-tags]
struct Something<std::pair<One, Two>>;
^
test.cpp:49:7: note: previous use is here
class Something;
I saw the following code in the header of the standard library <array>(with a special definition of tuple_sizelike classfollowing it later)
template <class T> class tuple_size;
template <size_t I, class T> class tuple_element;
template <class T1, class T2> struct tuple_size<pair<T1, T2> >;
Something? tuple_size, class, struct?