@@ -126,6 +126,86 @@ copy_until ( const Range &r, OutputIterator result, Predicate p )
126
126
return boost::algorithm::copy_until (boost::begin (r), boost::end (r), result, p);
127
127
}
128
128
129
+ // / \fn copy_if_while ( InputIterator first, InputIterator last, OutputIterator result, CopyPredicate copy_pred, TerminatePred term_pred )
130
+ // / \brief Copies all the elements from the input range that satisfy the
131
+ // / copy predicate to the output range while the termination predicate is
132
+ // / satisfied.
133
+ // / \return The updated output iterator
134
+ // /
135
+ // / \param first The start of the input sequence
136
+ // / \param last One past the end of the input sequence
137
+ // / \param result An output iterator to write the results into
138
+ // / \param copy_pred A predicate for testing whether to the current element
139
+ // / \param term_pred A predicate for testing whether to end the copy operation
140
+ template <typename InputIterator, typename OutputIterator, typename CopyPredicate, typename TerminatePred>
141
+ BOOST_CXX14_CONSTEXPR std::pair<InputIterator, OutputIterator>
142
+ copy_if_while ( InputIterator first, InputIterator last, OutputIterator result, CopyPredicate copy_pred, TerminatePred term_pred)
143
+ {
144
+ for ( ; first != last && term_pred (*first); ++first ) {
145
+ if (copy_pred (*first)) {
146
+ *result++ = *first;
147
+ }
148
+ }
149
+ return std::make_pair (first, result);
150
+ }
151
+
152
+ // / \fn copy_if_while ( const Range& r, OutputIterator result, CopyPredicate copy_pred, TerminatePred term_pred )
153
+ // / \brief Copies all the elements from the input range that satisfy the
154
+ // / copy predicate to the output range while the termination predicate is
155
+ // / satisfied.
156
+ // / \return The updated output iterator
157
+ // /
158
+ // / \param r The input range
159
+ // / \param result An output iterator to write the results into
160
+ // / \param copy_pred A predicate for testing whether to the current element
161
+ // / \param term_pred A predicate for testing whether to end the copy operation
162
+ template <typename Range, typename OutputIterator, typename CopyPredicate, typename TerminatePred>
163
+ BOOST_CXX14_CONSTEXPR std::pair<typename boost::range_iterator<const Range>::type, OutputIterator>
164
+ copy_if_while ( const Range& r, OutputIterator result, CopyPredicate copy_pred, TerminatePred term_pred)
165
+ {
166
+ return boost::algorithm::copy_if_while (boost::begin (r), boost::end (r), result, copy_pred, term_pred);
167
+ }
168
+
169
+ // / \fn copy_if_until ( InputIterator first, InputIterator last, OutputIterator result, CopyPredicate copy_pred, TerminatePred term_pred )
170
+ // / \brief Copies all the elements from the input range that satisfy the
171
+ // / copy predicate to the output range until the termination predicate is
172
+ // / satisfied.
173
+ // / \return The updated output iterator
174
+ // /
175
+ // / \param first The start of the input sequence
176
+ // / \param last One past the end of the input sequence
177
+ // / \param result An output iterator to write the results into
178
+ // / \param copy_pred A predicate for testing whether to the current element
179
+ // / \param term_pred A predicate for testing whether to end the copy operation
180
+ template <typename InputIterator, typename OutputIterator, typename CopyPredicate, typename TerminatePred>
181
+ BOOST_CXX14_CONSTEXPR std::pair<InputIterator, OutputIterator>
182
+ copy_if_until ( InputIterator first, InputIterator last, OutputIterator result, CopyPredicate copy_pred, TerminatePred term_pred)
183
+ {
184
+ for ( ; first != last && !term_pred (*first); ++first ) {
185
+ if (copy_pred (*first)) {
186
+ *result++ = *first;
187
+ }
188
+ }
189
+ return std::make_pair (first, result);
190
+ }
191
+
192
+ // / \fn copy_if_until ( const Range& r, OutputIterator result, CopyPredicate copy_pred, TerminatePred term_pred )
193
+ // / \brief Copies all the elements from the input range that satisfy the
194
+ // / copy predicate to the output range until the termination predicate is
195
+ // / satisfied.
196
+ // / \return The updated output iterator
197
+ // /
198
+ // / \param r The input range
199
+ // / \param result An output iterator to write the results into
200
+ // / \param copy_pred A predicate for testing whether to the current element
201
+ // / \param term_pred A predicate for testing whether to end the copy operation
202
+ template <typename Range, typename OutputIterator, typename CopyPredicate, typename TerminatePred>
203
+ BOOST_CXX14_CONSTEXPR std::pair<typename boost::range_iterator<const Range>::type, OutputIterator>
204
+ copy_if_until ( const Range& r, OutputIterator result, CopyPredicate copy_pred, TerminatePred term_pred)
205
+ {
206
+ return boost::algorithm::copy_if_until (boost::begin (r), boost::end (r), result, copy_pred, term_pred);
207
+ }
208
+
129
209
}} // namespace boost and algorithm
130
210
131
211
#endif // BOOST_ALGORITHM_COPY_IF_HPP
0 commit comments