Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
pezy committed Sep 4, 2014
2 parents c4a277e + 2130a8e commit 3de3440
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 48 deletions.
48 changes: 0 additions & 48 deletions ch03/ex3_21.cpp

This file was deleted.

44 changes: 44 additions & 0 deletions ch03/ex3_21_generics_version.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//!
//! @author Yue Wang
//! @date 4th Sep 2014
//!

#include <iostream>
#include <vector>

/**
* @brief check
* @param first
* @param last
*
* generics version for ex3.21
*/
template<typename Iter>
void check(Iter first, Iter last)
{
for(auto it = first; it != last; ++it)
std::cout << *it << "\n";

std::cout << "size = " << last - first << "\n\n";
}

int main()
{
std::vector<int> v1;
std::vector<int> v2(10);
std::vector<int> v3(10, 42);
std::vector<int> v4{10};
std::vector<int> v5{10, 42};
std::vector<std::string> v6{10};
std::vector<std::string> v7{10, "hi"};

check(v1.begin(),v1.end());
check(v2.begin(),v2.end());
check(v3.begin(),v3.end());
check(v4.begin(),v4.end());
check(v5.begin(),v5.end());
check(v6.begin(),v6.end());
check(v7.begin(),v7.end());

return 0;
}

0 comments on commit 3de3440

Please sign in to comment.