История изменений
Исправление
wota,
(текущая версия)
:
А чем оно круче сишных массивов?
#include <array>
#include <iostream>
using namespace std;
template<typename T>
void foo1( T a ) {
cout << "Size: " << a.size() << endl;
for( auto it : a )
cout << it << endl;
};
void foo2( array<int,4> a ) {
cout << "Size: must be 4" << endl;
for( int it : a )
cout << it << endl;
};
int main() {
array<int,5> a = { 1,2,3,4,5 };
foo1( a );
foo2( a );
}
Исходная версия
wota,
:
А чем оно круче сишных массивов?
#include <array>
#include <iostream>
using namespace std;
template<typename T>
void foo1( T a ) {
cout << "Size: " << a.size() << endl;
for( auto it : a )
cout << it << endl;
};
void foo2( array<int,4> a ) {
cout << "Size: must be 4" << endl;
for( auto it : a )
cout << it << endl;
};
int main() {
array<int,5> a = { 1,2,3,4,5 };
foo1( a );
foo2( a );
}