Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
]
The header file 'is_palindrome.hpp' contains four variants of a single algorithm, is_palindrome.
The algorithm tests the sequence and returns true if the sequence is a palindrome; i.e, it is identical when traversed either backwards or frontwards.
The routine `is_palindrome` takes a sequence and, optionally, a predicate. It will return true if the predicate returns true for tested elements by algorithm in the sequence.
The routine come in 4 forms; the first one takes two iterators to define the range. The second form takes two iterators to define the range and a predicate.
The third form takes a single range parameter, and uses Boost.Range to traverse it. And the fourth form takes a single range parameter ( uses Boost.Range to traverse it) and a predicate.
[heading interface]
The function `is_palindrome` returns true if the predicate returns true any tested by algorithm items in the sequence.
There are four versions:
1) takes two iterators.
2) takes two iterators and a predicate.
3) takes a range.
4) takes a range and a predicate.
``
template<typename BidirectionalIterator>
bool is_palindrome ( BidirectionalIterator begin, BidirectionalIterator end );
`is_palindrome` work on Bidirectional and RandomAccess iterators.
[heading Complexity]
All of the variants of `is_palindrome` run in ['O(N)] (linear) time; that is, they compare against each element in the list once. If any of the comparisons not succeed, the algorithm will terminate immediately, without examining the remaining members of the sequence.
[heading Exception Safety]
All of the variants of `is_palindrome` take their parameters by value or const reference, and do not depend upon any global state. Therefore, all the routines in this file provide the strong exception guarantee.
[heading Notes]
* `is_palindrome` returns true for empty ranges and for single element ranges.
* If you use version of 'is_palindrome' without custom predicate, 'is_palindrome' uses default 'operator==' for elements. If you want use custom predicate, you must redefine 'operator=='.
* Don't use 'const char*' with 'is_palindrome', because 'const char*' is always non-palindromic ('\0' at the end). If you will try to compile 'is_palindrome' with 'const char*', you will get an error.