2 * Copyright Andrey Semashev 2007 - 2014.
3 * Distributed under the Boost Software License, Version 1.0.
4 * (See accompanying file LICENSE_1_0.txt or copy at
5 * http://www.boost.org/LICENSE_1_0.txt)
9 * \author Andrey Semashev
12 * This header contains a predicate for checking if the provided string contains a substring.
15 #ifndef BOOST_LOG_UTILITY_FUNCTIONAL_CONTAINS_HPP_INCLUDED_
16 #define BOOST_LOG_UTILITY_FUNCTIONAL_CONTAINS_HPP_INCLUDED_
18 #include <boost/log/detail/config.hpp>
19 #include <boost/log/detail/header.hpp>
21 #ifdef BOOST_HAS_PRAGMA_ONCE
27 BOOST_LOG_OPEN_NAMESPACE
29 //! The \c contains functor
32 typedef bool result_type;
34 template< typename T, typename U >
35 bool operator() (T const& left, U const& right) const
37 typedef typename T::const_iterator left_iterator;
38 typedef typename U::const_iterator right_iterator;
40 typename U::size_type const right_size = right.size();
41 if (left.size() >= right_size)
43 const left_iterator search_end = left.end() - right_size + 1;
44 const right_iterator right_end = right.end();
45 for (left_iterator it = left.begin(); it != search_end; ++it)
47 left_iterator left_it = it;
48 right_iterator right_it = right.begin();
49 for (; right_it != right_end; ++left_it, ++right_it)
51 if (*left_it != *right_it)
54 if (right_it == right_end)
63 BOOST_LOG_CLOSE_NAMESPACE // namespace log
67 #include <boost/log/detail/footer.hpp>
69 #endif // BOOST_LOG_UTILITY_FUNCTIONAL_CONTAINS_HPP_INCLUDED_