Skip to content

Commit

Permalink
remove redundant if checking
Browse files Browse the repository at this point in the history
  • Loading branch information
Mooophy committed Oct 12, 2014
1 parent 0ba0c35 commit fac1054
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions ch16/ex16.5/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @file main.cpp
* @author Alan.W
* @date 02 Feb 2014
* 13 Oct 2014
* @remark This code is for the exercises from C++ Primer 5th Edition
* @note
***************************************************************************/
Expand All @@ -13,8 +14,6 @@
//!

#include <iostream>
#include <vector>
#include <list>
#include <string>

/** @note
Expand All @@ -24,23 +23,19 @@
template<typename T, unsigned size>
void print(const T(&ref)[size])
{
if (ref)
{
auto p = ref;
for (unsigned i = 0; i != size; ++i)
std::cout << *p++ << std::endl;
}
for (unsigned i = 0; i != size; ++i)
std::cout << ref[i] << std::endl;
}

int main()
{
std::string p[] = {"ssss","aaa","ssssss"};
char c[] = {'a','b','c','d'};
int i[] = {1,2,3,4,5};
int i[] = {1};
print(i);
print(c);
print(p);

std::cout << "\nexit normally\n";
return 0;
}

0 comments on commit fac1054

Please sign in to comment.