#include <array>
#include <iostream>
#include <string>

template <typename T>
struct size_getter {
    static size_t getSize( T );
};

template <typename T>
void serialize(const T &data)
{
    size_t data_size = size_getter<T>::getSize( data );
    std::cout << "Size: " << data_size << std::endl;
}

template<>
struct size_getter<int> {
    static constexpr size_t getSize( int )
    {
        return sizeof(int);
    }
};

template<>
struct size_getter<std::string> {
    static size_t getSize( const std::string &s )
    {
        return s.size();
    }
};

template <typename T, size_t N>
struct size_getter<std::array<T, N>>
{
    static size_t getSize(const std::array<T, N> &array)
    {
        size_t array_size = 0;
        for (const T &element : array)
            array_size += size_getter<T>::getSize(element);
        return array_size;
    }
};

int main()
{
    int a;
    serialize(a);

    std::string str = "foo";
    serialize(str);

    std::array<std::string, 2> arr = {{"foo", "foobar"}};
    serialize(arr);

    return 0;
}