You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/is_palindrome.qbk
+17-8
Original file line number
Diff line number
Diff line change
@@ -9,23 +9,26 @@ Distributed under the Boost Software License, Version 1.0.
9
9
(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10
10
]
11
11
12
-
The header file 'is_palindrome.hpp' contains four variants of a single algorithm, is_palindrome.
12
+
The header file 'is_palindrome.hpp' contains six variants of a single algorithm, is_palindrome.
13
13
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.
14
14
15
15
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.
16
16
17
-
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.
18
-
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.
17
+
The routine come in 6 forms; the first one takes two iterators to define the range. The second form takes two iterators to define the range and a predicate.
18
+
The third form takes a single range parameter, and uses Boost.Range to traverse it. The fourth form takes a single range parameter ( uses Boost.Range to traverse it) and a predicate.
19
+
The fifth form takes a single C-string and a predicate. The sixth form takes a single C-string.
19
20
20
21
21
22
[heading interface]
22
23
23
24
The function `is_palindrome` returns true if the predicate returns true any tested by algorithm items in the sequence.
24
-
There are four versions:
25
+
There are six versions:
25
26
1) takes two iterators.
26
27
2) takes two iterators and a predicate.
27
28
3) takes a range.
28
29
4) takes a range and a predicate.
30
+
5) takes a C-string and a predicate.
31
+
6) takes a C-string.
29
32
30
33
``
31
34
template<typename BidirectionalIterator>
@@ -36,6 +39,9 @@ template<typename Range>
36
39
bool is_palindrome ( const Range &r );
37
40
template<typename Range, typename Predicate>
38
41
bool is_palindrome ( const Range &r, Predicate p );
42
+
template<typename Predicate>
43
+
bool is_palindrome ( const char* str, Predicate p );
@@ -71,15 +80,15 @@ All of the variants of `is_palindrome` run in ['O(N)] (linear) time; that is, th
71
80
72
81
[heading Exception Safety]
73
82
74
-
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.
83
+
All of the variants of `is_palindrome` take their parameters by value, const pointer or const reference, and do not depend upon any global state. Therefore, all the routines in this file provide the strong exception guarantee.
75
84
76
85
[heading Notes]
77
86
78
-
* `is_palindrome` returns true for empty ranges and for single element ranges.
87
+
* `is_palindrome` returns true for empty ranges, null pointers and for single element ranges.
79
88
80
-
* 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=='.
89
+
* If you use version of 'is_palindrome' without custom predicate, 'is_palindrome' uses default 'operator==()' for elements.
81
90
82
-
* 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.
91
+
* Be careful with using not null pointer 'const char*' without '\0' - if you use it with 'is_palindrome', it's a undefined behaviour.
0 commit comments