language: C++11 (gcc-4.7.2)
date: 468 days 2 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
 
template<typename T, size_t Length>
size_t f(const T (&)[Length]) {
    return Length;
}
 
template<typename T, size_t Length, typename... Args>
size_t f(const T (&)[Length], Args... rest) {
    return Length + f(rest...);
}
 
int main() {
    int a[] = { 1, 2, 3 }, b[] = { 1, 2, 3, 4, 5 }, c[] = { 1 };
 
    std::cout << f(a, b, c);
}
 
prog.cpp: In function 'size_t f(const T (&)[Length], Args ...) [with T = int, unsigned int Length = 3u, Args = {int*, int*}, size_t = unsigned int]':
prog.cpp:16:27:   instantiated from here
prog.cpp:10:30: error: no matching function for call to 'f(int*&, int*&)'