From 85736ab54e06eb152bdb4b8b13abefa47b7f5291 Mon Sep 17 00:00:00 2001 From: "eric.yang" Date: Tue, 26 Nov 2019 20:11:37 -0800 Subject: [PATCH] fix search example --- example/search_example.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/example/search_example.cpp b/example/search_example.cpp index 438bee9ad..828e498a1 100644 --- a/example/search_example.cpp +++ b/example/search_example.cpp @@ -27,7 +27,7 @@ int main ( int /*argc*/, char * /*argv*/ [] ) { // algorithms. They all have the same (dual) interface. // There is a procedural interface, based on std::search: - if ( ba::boyer_moore_search ( haystack.begin (), haystack.end (), needle1.begin (), needle1.end ()) != haystack.end ()) + if ( ba::boyer_moore_search ( haystack.begin (), haystack.end (), needle1.begin (), needle1.end ()) != std::make_pair(haystack.end(), haystack.end())) std::cout << "Found '" << needle1 << "' in '" << haystack << "' (boyer-moore 1)" << std::endl; else std::cout << "Did NOT find '" << needle1 << "' in '" << haystack << "' (boyer-moore 1)" << std::endl; @@ -36,19 +36,19 @@ int main ( int /*argc*/, char * /*argv*/ [] ) { // you can create a search object and use that over and over again - amortizing the setup // costs across several searches ba::boyer_moore search1 ( needle1.begin (), needle1.end ()); - if ( search1 ( haystack.begin (), haystack.end ()) != haystack.end ()) + if ( search1 ( haystack.begin (), haystack.end ()) != std::make_pair(haystack.end(), haystack.end())) std::cout << "Found '" << needle1 << "' in '" << haystack << "' (boyer-moore 2)" << std::endl; else std::cout << "Did NOT find '" << needle1 << "' in '" << haystack << "' (boyer-moore 2)" << std::endl; // There is also an implementation of boyer-moore-horspool searching - if ( ba::boyer_moore_horspool_search ( haystack.begin (), haystack.end (), needle1.begin (), needle1.end ()) != haystack.end ()) + if ( ba::boyer_moore_horspool_search ( haystack.begin (), haystack.end (), needle1.begin (), needle1.end ()) != std::make_pair(haystack.end(), haystack.end())) std::cout << "Found '" << needle1 << "' in '" << haystack << "' (boyer-moore-horspool)" << std::endl; else std::cout << "Did NOT find '" << needle1 << "' in '" << haystack << "' (boyer-moore-horspool)" << std::endl; // And also the knuth-pratt-morris search algorithm - if ( ba::knuth_morris_pratt_search ( haystack.begin (), haystack.end (), needle1.begin (), needle1.end ()) != haystack.end ()) + if ( ba::knuth_morris_pratt_search ( haystack.begin (), haystack.end (), needle1.begin (), needle1.end ()) != std::make_pair(haystack.end(), haystack.end())) std::cout << "Found '" << needle1 << "' in '" << haystack << "' (knuth_morris_pratt)" << std::endl; else std::cout << "Did NOT find '" << needle1 << "' in '" << haystack << "' (knuth_morris_pratt)" << std::endl;