]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/log/include/boost/log/utility/functional/begins_with.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / log / include / boost / log / utility / functional / begins_with.hpp
CommitLineData
7c673cae
FG
1/*
2 * Copyright Andrey Semashev 2007 - 2015.
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)
6 */
7/*!
8 * \file begins_with.hpp
9 * \author Andrey Semashev
10 * \date 30.03.2008
11 *
12 * This header contains a predicate for checking if the provided string begins with a substring.
13 */
14
15#ifndef BOOST_LOG_UTILITY_FUNCTIONAL_BEGINS_WITH_HPP_INCLUDED_
16#define BOOST_LOG_UTILITY_FUNCTIONAL_BEGINS_WITH_HPP_INCLUDED_
17
18#include <boost/log/detail/config.hpp>
19#include <boost/log/detail/header.hpp>
20
21#ifdef BOOST_HAS_PRAGMA_ONCE
22#pragma once
23#endif
24
25namespace boost {
26
27BOOST_LOG_OPEN_NAMESPACE
28
29//! The \c begins_with functor
30struct begins_with_fun
31{
32 typedef bool result_type;
33
34 template< typename T, typename U >
35 bool operator() (T const& left, U const& right) const
36 {
37 typedef typename T::const_iterator left_iterator;
38 typedef typename U::const_iterator right_iterator;
39
40 left_iterator left_it = left.begin(), left_end = left.end();
41 right_iterator right_it = right.begin(), right_end = right.end();
42 for (; left_it != left_end && right_it != right_end; ++left_it, ++right_it)
43 {
44 if (*left_it != *right_it)
45 break;
46 }
47 return right_it == right_end;
48 }
49};
50
51BOOST_LOG_CLOSE_NAMESPACE // namespace log
52
53} // namespace boost
54
55#include <boost/log/detail/footer.hpp>
56
57#endif // BOOST_LOG_UTILITY_FUNCTIONAL_BEGINS_WITH_HPP_INCLUDED_