/* The following code example is taken from the book
 * "The C++ Standard Library - A Tutorial and Reference"
 * by Nicolai M. Josuttis, Addison-Wesley, 1999
 *
 * (C) Copyright Nicolai M. Josuttis 1999.
 * Permission to copy, use, modify, sell and distribute this software
 * is granted provided this copyright notice appears in all copies.
 * This software is provided "as is" without express or implied
 * warranty, and with no claim as to its suitability for any purpose.
 */
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <cctype>
#include <boost/compose.hpp>
using namespace std;
using namespace boost;

int main()
{
    string s("Internationalization");
    string sub("Nation");

    // 大文字/小文字を区別なしに部分文字列を検索する
    string::iterator pos;
    pos = search (s.begin(),s.end(),           // 検索対象文字列
                  sub.begin(),sub.end(),       // 検索する部分文字列
                  compose_f_gx_hy(equal_to<int>(), // 一致条件
                                  ptr_fun(::toupper),
                                  ptr_fun(::toupper)));

    if (pos != s.end()) {
        cout << "\"" << sub << "\" is part of \"" << s << "\""
             << endl;
    }
}
