Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:39:27

0001 /*
0002  *          Copyright Andrey Semashev 2007 - 2015.
0003  * Distributed under the Boost Software License, Version 1.0.
0004  *    (See accompanying file LICENSE_1_0.txt or copy at
0005  *          http://www.boost.org/LICENSE_1_0.txt)
0006  */
0007 /*!
0008  * \file   ends_with.hpp
0009  * \author Andrey Semashev
0010  * \date   30.03.2008
0011  *
0012  * This header contains a predicate for checking if the provided string ends with a substring.
0013  */
0014 
0015 #ifndef BOOST_LOG_UTILITY_FUNCTIONAL_ENDS_WITH_HPP_INCLUDED_
0016 #define BOOST_LOG_UTILITY_FUNCTIONAL_ENDS_WITH_HPP_INCLUDED_
0017 
0018 #include <boost/log/detail/config.hpp>
0019 #include <boost/log/detail/header.hpp>
0020 
0021 #ifdef BOOST_HAS_PRAGMA_ONCE
0022 #pragma once
0023 #endif
0024 
0025 namespace boost {
0026 
0027 BOOST_LOG_OPEN_NAMESPACE
0028 
0029 //! The \c ends_with functor
0030 struct ends_with_fun
0031 {
0032     typedef bool result_type;
0033 
0034     template< typename T, typename U >
0035     bool operator() (T const& left, U const& right) const
0036     {
0037         typedef typename T::const_reverse_iterator left_iterator;
0038         typedef typename U::const_reverse_iterator right_iterator;
0039 
0040         left_iterator left_it = left.rbegin(), left_end = left.rend();
0041         right_iterator right_it = right.rbegin(), right_end = right.rend();
0042         for (; left_it != left_end && right_it != right_end; ++left_it, ++right_it)
0043         {
0044             if (*left_it != *right_it)
0045                 break;
0046         }
0047         return right_it == right_end;
0048     }
0049 };
0050 
0051 BOOST_LOG_CLOSE_NAMESPACE // namespace log
0052 
0053 } // namespace boost
0054 
0055 #include <boost/log/detail/footer.hpp>
0056 
0057 #endif // BOOST_LOG_UTILITY_FUNCTIONAL_ENDS_WITH_HPP_INCLUDED_