[ create a new paste ] login | about

Link: http://codepad.org/Ho2FMF0M    [ raw code | output | fork ]

C++, pasted on Mar 9:
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>

template<typename T, size_t N>
size_t array_len(T (&t)[N])
{
    return N;
}

int main()
{
    int i[] = {1,2,3,4,5};
    std::cout << array_len(i) << std::endl;
}


Output:
1
5


Create a new paste based on this one


Comments: