Created
May 21, 2013 17:09
-
-
Save cbsmith/5621454 to your computer and use it in GitHub Desktop.
C++98 version of two_stars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -*- compile-command: "clang++ -ggdb -o two_stars_98 -std=c++98 -stdlib=libc++ two_stars_98.cpp" -*- | |
#include <algorithm> | |
#include <iostream> | |
using namespace std; | |
bool points_to_two(int* x) { | |
return *x == 2; | |
} | |
int main(int argc, char** argv) { | |
int a = 1; | |
int b = 2; | |
int c = 3; | |
int d = 4; | |
int e = 2; | |
int* two_star_container[] = { &a, &b, &c, &d, &e }; | |
int** start = two_star_container; | |
int** end = &two_star_container[6]; | |
for (int** i = start; i != end; ++i) { | |
cout << **i << endl; | |
} | |
int** new_end = remove_if(start, end, points_to_two); | |
cout << "Removed the 2's" << endl; | |
for (int** i = start; i != new_end; ++i) { | |
cout << **i << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment