Mercurial > Algorithms__Sedgewick
changeset 1:5cc971338a2b
Updated BinarySearch.cpp to work in either c++99 or c++11 modes.
author | Eris Caffee <discordia@eldalin.com> |
---|---|
date | Sat, 16 May 2015 17:42:16 -0500 |
parents | 17ee997bf124 |
children | d1e563e7873f |
files | algs4-c++/BinarySearch/BinarySearch algs4-c++/BinarySearch/BinarySearch.cpp |
diffstat | 2 files changed, 6 insertions(+), 2 deletions(-) [+] |
line diff
1.1 Binary file algs4-c++/BinarySearch/BinarySearch has changed
2.1 --- a/algs4-c++/BinarySearch/BinarySearch.cpp Sat May 16 12:02:55 2015 -0500 2.2 +++ b/algs4-c++/BinarySearch/BinarySearch.cpp Sat May 16 17:42:16 2015 -0500 2.3 @@ -1,4 +1,4 @@ 2.4 -// g++ -D COMPILE_MAIN BinarySearch.cpp -o BinarySearch 2.5 +// g++ -std=c++11 -D BINARY_SEARCH_MAIN BinarySearch.cpp -o BinarySearch 2.6 2.7 #include <algorithm> 2.8 #include <fstream> 2.9 @@ -25,7 +25,7 @@ 2.10 2.11 //////////////////////////////////////////////////////////////////////////////// 2.12 2.13 -#ifdef COMPILE_MAIN 2.14 +#ifdef BINARY_SEARCH_MAIN 2.15 2.16 int main( int argc, char **argv ) { 2.17 std::vector<int> whitelist; 2.18 @@ -41,7 +41,11 @@ 2.19 std::sort( whitelist.begin(), whitelist.end() ); 2.20 2.21 std::cout << "Sorted whitelist" << std::endl; 2.22 +#if __cplusplus >= 201103 2.23 + for ( auto it = whitelist.begin(); it < whitelist.end(); ++it ) { 2.24 +#else 2.25 for ( std::vector<int>::iterator it = whitelist.begin(); it < whitelist.end(); ++it ) { 2.26 +#endif 2.27 std::cout << *it << std::endl; 2.28 } 2.29