1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/lambda/algorithm.hpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1377 @@
1.4 +// -- algorithm.hpp -- Boost Lambda Library -----------------------------------
1.5 +// Copyright (C) 2002 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
1.6 +// Copyright (C) 2002 Gary Powell (gwpowell@hotmail.com)
1.7 +//
1.8 +// Distributed under the Boost Software License, Version 1.0. (See
1.9 +// accompanying file LICENSE_1_0.txt or copy at
1.10 +// http://www.boost.org/LICENSE_1_0.txt)
1.11 +//
1.12 +// For more information, see http://www.boost.org
1.13 +
1.14 +#ifndef BOOST_LAMBDA_ALGORITHM_HPP
1.15 +#define BOOST_LAMBDA_ALGORITHM_HPP
1.16 +
1.17 +#include "boost/lambda/core.hpp"
1.18 +
1.19 +#include <algorithm>
1.20 +#include <iterator> // for iterator_traits
1.21 +#include <utility> // for std::pair
1.22 +
1.23 +namespace boost {
1.24 + namespace lambda {
1.25 +
1.26 +namespace ll {
1.27 +
1.28 +// for_each ---------------------------------
1.29 +
1.30 +struct for_each {
1.31 +
1.32 + template <class Args>
1.33 + struct sig {
1.34 + typedef typename boost::remove_const<
1.35 + typename boost::tuples::element<3, Args>::type
1.36 + >::type type;
1.37 + };
1.38 +
1.39 + template <class A, class C>
1.40 + C
1.41 + operator()(A a, A b, C c) const
1.42 + { return ::std::for_each(a, b, c); }
1.43 +};
1.44 +
1.45 +// find ---------------------------------
1.46 +
1.47 +struct find {
1.48 +
1.49 + template <class Args>
1.50 + struct sig {
1.51 + typedef typename boost::remove_const<
1.52 + typename boost::tuples::element<1, Args>::type
1.53 + >::type type;
1.54 + };
1.55 +
1.56 + template <class A, class C>
1.57 + A
1.58 + operator()(A a, A b, const C& c) const
1.59 + { return ::std::find(a, b, c); }
1.60 +};
1.61 +
1.62 +
1.63 +// find_if ---------------------------------
1.64 +
1.65 +struct find_if {
1.66 +
1.67 + template <class Args>
1.68 + struct sig {
1.69 + typedef typename boost::remove_const<
1.70 + typename boost::tuples::element<1, Args>::type
1.71 + >::type type;
1.72 + };
1.73 +
1.74 + template <class A, class C>
1.75 + A
1.76 + operator()(A a, A b, C c) const
1.77 + { return ::std::find_if(a, b, c); }
1.78 +};
1.79 +
1.80 +// find_end ---------------------------------
1.81 +
1.82 +struct find_end {
1.83 +
1.84 + template <class Args>
1.85 + struct sig {
1.86 + typedef typename boost::remove_const<
1.87 + typename boost::tuples::element<1, Args>::type
1.88 + >::type type;
1.89 + };
1.90 +
1.91 + template <class A, class C>
1.92 + A
1.93 + operator()(A a, A b, C c, C d) const
1.94 + { return ::std::find_end(a, b, c, d); }
1.95 +
1.96 + template <class A, class C, class E>
1.97 + A
1.98 + operator()(A a, A b, C c, C d, E e) const
1.99 + { return ::std::find_end(a, b, c, d, e); }
1.100 +
1.101 +};
1.102 +
1.103 +// find_first_of ---------------------------------
1.104 +
1.105 +struct find_first_of {
1.106 +
1.107 + template <class Args>
1.108 + struct sig {
1.109 + typedef typename boost::remove_const<
1.110 + typename boost::tuples::element<1, Args>::type
1.111 + >::type type;
1.112 + };
1.113 +
1.114 + template <class A, class C>
1.115 + A
1.116 + operator()(A a, A b, C c, C d) const
1.117 + { return ::std::find_first_of(a, b, c, d); }
1.118 +
1.119 + template <class A, class C, class E>
1.120 + A
1.121 + operator()(A a, A b, C c, C d, E e) const
1.122 + { return ::std::find_first_of(a, b, c, d, e); }
1.123 +
1.124 +};
1.125 +
1.126 +// adjacent_find ---------------------------------
1.127 +
1.128 +struct adjacent_find {
1.129 +
1.130 + template <class Args>
1.131 + struct sig {
1.132 + typedef typename boost::remove_const<
1.133 + typename boost::tuples::element<1, Args>::type
1.134 + >::type type;
1.135 + };
1.136 +
1.137 + template <class A>
1.138 + A
1.139 + operator()(A a, A b) const
1.140 + { return ::std::adjacent_find(a, b); }
1.141 +
1.142 + template <class A, class C>
1.143 + A
1.144 + operator()(A a, A b, C c) const
1.145 + { return ::std::adjacent_find(a, b, c); }
1.146 +
1.147 +};
1.148 +
1.149 +// count ---------------------------------
1.150 +
1.151 +struct count {
1.152 +
1.153 + template <class Args>
1.154 + struct sig {
1.155 + typedef typename ::std::iterator_traits<
1.156 + typename boost::remove_const<
1.157 + typename boost::tuples::element<1, Args>::type
1.158 + >::type
1.159 + >::difference_type type;
1.160 + };
1.161 +
1.162 + template <class A, class C >
1.163 + typename ::std::iterator_traits<A>::difference_type
1.164 + operator()(A a, A b, const C& c) const
1.165 + { return ::std::count(a, b, c); }
1.166 +};
1.167 +
1.168 +// count_if ---------------------------------
1.169 +
1.170 +struct count_if {
1.171 +
1.172 + template <class Args>
1.173 + struct sig {
1.174 + typedef typename ::std::iterator_traits<
1.175 + typename boost::remove_const<
1.176 + typename boost::tuples::element<1, Args>::type
1.177 + >::type
1.178 + >::difference_type type;
1.179 + };
1.180 +
1.181 + template <class A, class C >
1.182 + typename ::std::iterator_traits<A>::difference_type
1.183 + operator()(A a, A b, C c) const
1.184 + { return ::std::count_if(a, b, c); }
1.185 +};
1.186 +
1.187 +
1.188 +// mismatch ---------------------------------
1.189 +
1.190 +struct mismatch {
1.191 +
1.192 + template <class Args>
1.193 + struct sig {
1.194 + typedef typename boost::remove_const<
1.195 + typename boost::tuples::element<1, Args>::type
1.196 + >::type element1_type;
1.197 +
1.198 + typedef typename boost::remove_const<
1.199 + typename boost::tuples::element<3, Args>::type
1.200 + >::type element2_type;
1.201 +
1.202 + typedef ::std::pair< element1_type, element2_type > type;
1.203 + };
1.204 +
1.205 + template <class A, class C >
1.206 + ::std::pair<A,C>
1.207 + operator()(A a, A b, C c) const
1.208 + { return ::std::mismatch(a, b, c); }
1.209 +
1.210 + template <class A, class C, class D>
1.211 + ::std::pair<A,C>
1.212 + operator()(A a, A b, C c, D d) const
1.213 + { return ::std::mismatch(a, b, c, d); }
1.214 +
1.215 +};
1.216 +
1.217 +// equal ---------------------------------
1.218 +
1.219 +struct equal {
1.220 +
1.221 + template <class Args>
1.222 + struct sig {
1.223 + typedef bool type;
1.224 + };
1.225 +
1.226 + template <class A, class C >
1.227 + bool
1.228 + operator()(A a, A b, C c) const
1.229 + { return ::std::equal(a, b, c); }
1.230 +
1.231 + template <class A, class C, class D>
1.232 + bool
1.233 + operator()(A a, A b, C c, D d) const
1.234 + { return ::std::equal(a, b, c, d); }
1.235 +
1.236 +};
1.237 +
1.238 +// search --------------------------------
1.239 +
1.240 +struct search {
1.241 +
1.242 + template <class Args>
1.243 + struct sig {
1.244 + typedef typename boost::remove_const<
1.245 + typename boost::tuples::element<1, Args>::type
1.246 + >::type type;
1.247 + };
1.248 +
1.249 + template <class A, class C>
1.250 + A
1.251 + operator()(A a, A b, C c, C d) const
1.252 + { return std::search(a, b, c, d);}
1.253 +
1.254 + template <class A, class C, class E>
1.255 + A
1.256 + operator()(A a, A b, C c, C d, E e) const
1.257 + { return std::search(a, b, c, d, e);}
1.258 +
1.259 +};
1.260 +
1.261 +// copy ---------------------------------
1.262 +
1.263 +struct copy {
1.264 +
1.265 + template <class Args>
1.266 + struct sig {
1.267 + typedef typename boost::remove_const<
1.268 + typename boost::tuples::element<3, Args>::type
1.269 + >::type type;
1.270 + };
1.271 +
1.272 + template <class A, class C>
1.273 + C
1.274 + operator()(A a, A b, C c) const
1.275 + { return ::std::copy(a, b, c); }
1.276 +
1.277 +};
1.278 +
1.279 +// copy_backward ---------------------------------
1.280 +
1.281 +struct copy_backward {
1.282 +
1.283 + template <class Args>
1.284 + struct sig {
1.285 + typedef typename boost::remove_const<
1.286 + typename boost::tuples::element<3, Args>::type
1.287 + >::type type;
1.288 + };
1.289 +
1.290 + template <class A, class C>
1.291 + C
1.292 + operator()(A a, A b, C c) const
1.293 + { return ::std::copy_backward(a, b, c); }
1.294 +
1.295 +};
1.296 +
1.297 +// swap ---------------------------------
1.298 +
1.299 +struct swap {
1.300 +
1.301 + template <class Args>
1.302 + struct sig {
1.303 + typedef void type;
1.304 + };
1.305 +
1.306 + template <class A>
1.307 + void
1.308 + operator()(A a, A b) const
1.309 + { ::std::swap(a, b); }
1.310 +
1.311 +};
1.312 +
1.313 +// swap_ranges ---------------------------------
1.314 +
1.315 +struct swap_ranges {
1.316 +
1.317 + template <class Args>
1.318 + struct sig {
1.319 + typedef typename boost::remove_const<
1.320 + typename boost::tuples::element<3, Args>::type
1.321 + >::type type;
1.322 + };
1.323 +
1.324 + template <class A, class C>
1.325 + C
1.326 + operator()(A a, A b, C c) const
1.327 + { return ::std::swap_ranges(a, b, c); }
1.328 +
1.329 +};
1.330 +
1.331 +// iter_swap ---------------------------------
1.332 +
1.333 +struct iter_swap {
1.334 +
1.335 + template <class Args>
1.336 + struct sig {
1.337 + typedef void type;
1.338 + };
1.339 +
1.340 + template <class A>
1.341 + void
1.342 + operator()(A a, A b) const
1.343 + { ::std::iter_swap(a, b); }
1.344 +
1.345 +};
1.346 +
1.347 +
1.348 +// transform --------------------------------
1.349 +
1.350 +struct transform {
1.351 +
1.352 + template <class Args>
1.353 + struct sig {
1.354 + typedef typename boost::remove_const<
1.355 + typename boost::tuples::element<
1.356 + boost::tuples::length<Args>::value - 2,
1.357 + Args
1.358 + >::type
1.359 + >::type type;
1.360 + };
1.361 +
1.362 + template <class A, class C, class D>
1.363 + C
1.364 + operator()(A a, A b, C c, D d) const
1.365 + { return std::transform(a, b, c, d);}
1.366 +
1.367 + template <class A, class C, class D, class E>
1.368 + D
1.369 + operator()(A a, A b, C c, D d, E e) const
1.370 + { return std::transform(a, b, c, d, e);}
1.371 +
1.372 +};
1.373 +
1.374 +// replace ---------------------------------
1.375 +
1.376 +struct replace {
1.377 +
1.378 + template <class Args>
1.379 + struct sig {
1.380 + typedef void type;
1.381 + };
1.382 +
1.383 + template <class A, class C>
1.384 + void
1.385 + operator()(A a, A b, const C& c, const C& d) const
1.386 + { ::std::replace(a, b, c, d); }
1.387 +
1.388 +};
1.389 +
1.390 +// replace_if ---------------------------------
1.391 +
1.392 +struct replace_if {
1.393 +
1.394 + template <class Args>
1.395 + struct sig {
1.396 + typedef void type;
1.397 + };
1.398 +
1.399 + template <class A, class C, class D>
1.400 + void
1.401 + operator()(A a, A b, C c, const D& d) const
1.402 + { ::std::replace_if(a, b, c, d); }
1.403 +
1.404 +};
1.405 +
1.406 +// replace_copy ---------------------------------
1.407 +
1.408 +struct replace_copy {
1.409 +
1.410 + template <class Args>
1.411 + struct sig {
1.412 + typedef typename boost::remove_const<
1.413 + typename boost::tuples::element<3, Args>::type
1.414 + >::type type;
1.415 + };
1.416 +
1.417 + template <class A, class C, class D>
1.418 + C
1.419 + operator()(A a, A b, C c, const D& d, const D& e) const
1.420 + { return ::std::replace_copy(a, b, c, d, e); }
1.421 +
1.422 +};
1.423 +
1.424 +// replace_copy_if ---------------------------------
1.425 +
1.426 +struct replace_copy_if {
1.427 +
1.428 + template <class Args>
1.429 + struct sig {
1.430 + typedef typename boost::remove_const<
1.431 + typename boost::tuples::element<3, Args>::type
1.432 + >::type type;
1.433 + };
1.434 +
1.435 + template <class A, class C, class D, class E>
1.436 + C
1.437 + operator()(A a, A b, C c, D d, const E& e) const
1.438 + { return ::std::replace_copy_if(a, b, c, d, e); }
1.439 +
1.440 +};
1.441 +
1.442 +// fill ---------------------------------
1.443 +
1.444 +struct fill {
1.445 +
1.446 + template <class Args>
1.447 + struct sig {
1.448 + typedef void type;
1.449 + };
1.450 +
1.451 + template <class A, class C>
1.452 + void
1.453 + operator()(A a, A b, const C& c) const
1.454 + { ::std::fill(a, b, c); }
1.455 +
1.456 +};
1.457 +
1.458 +// fill_n ---------------------------------
1.459 +
1.460 +struct fill_n {
1.461 +
1.462 + template <class Args>
1.463 + struct sig {
1.464 + typedef void type;
1.465 + };
1.466 +
1.467 + template <class A, class B, class C>
1.468 + void
1.469 + operator()(A a, B b, const C& c) const
1.470 + { ::std::fill_n(a, b, c); }
1.471 +
1.472 +};
1.473 +
1.474 +// generate ---------------------------------
1.475 +
1.476 +struct generate {
1.477 +
1.478 + template <class Args>
1.479 + struct sig {
1.480 + typedef void type;
1.481 + };
1.482 +
1.483 + template <class A, class C>
1.484 + void
1.485 + operator()(A a, A b, C c) const
1.486 + { ::std::generate(a, b, c); }
1.487 +
1.488 +};
1.489 +
1.490 +// generate_n ---------------------------------
1.491 +
1.492 +struct generate_n {
1.493 +
1.494 + template <class Args>
1.495 + struct sig {
1.496 + typedef void type;
1.497 + };
1.498 +
1.499 + template <class A, class B, class C>
1.500 + void
1.501 + operator()(A a, B b, C c) const
1.502 + { ::std::generate_n(a, b, c); }
1.503 +
1.504 +};
1.505 +
1.506 +// remove ---------------------------------
1.507 +
1.508 +struct remove {
1.509 +
1.510 + template <class Args>
1.511 + struct sig {
1.512 + typedef typename boost::remove_const<
1.513 + typename boost::tuples::element<1, Args>::type
1.514 + >::type type;
1.515 + };
1.516 +
1.517 + template <class A, class C >
1.518 + A
1.519 + operator()(A a, A b, const C& c) const
1.520 + { return ::std::remove(a, b, c); }
1.521 +};
1.522 +
1.523 +// remove_if ---------------------------------
1.524 +
1.525 +struct remove_if {
1.526 +
1.527 + template <class Args>
1.528 + struct sig {
1.529 + typedef typename boost::remove_const<
1.530 + typename boost::tuples::element<1, Args>::type
1.531 + >::type type;
1.532 + };
1.533 +
1.534 + template <class A, class C >
1.535 + A
1.536 + operator()(A a, A b, C c) const
1.537 + { return ::std::remove_if(a, b, c); }
1.538 +};
1.539 +
1.540 +// remove_copy ---------------------------------
1.541 +
1.542 +struct remove_copy {
1.543 +
1.544 + template <class Args>
1.545 + struct sig {
1.546 + typedef typename boost::remove_const<
1.547 + typename boost::tuples::element<3, Args>::type
1.548 + >::type type;
1.549 + };
1.550 +
1.551 + template <class A, class C, class D >
1.552 + C
1.553 + operator()(A a, A b, C c, const D& d) const
1.554 + { return ::std::remove_copy(a, b, c, d); }
1.555 +};
1.556 +
1.557 +// remove_copy_if ---------------------------------
1.558 +
1.559 +struct remove_copy_if {
1.560 +
1.561 + template <class Args>
1.562 + struct sig {
1.563 + typedef typename boost::remove_const<
1.564 + typename boost::tuples::element<3, Args>::type
1.565 + >::type type;
1.566 + };
1.567 +
1.568 + template <class A, class C, class D >
1.569 + C
1.570 + operator()(A a, A b, C c, D d) const
1.571 + { return ::std::remove_copy_if(a, b, c, d); }
1.572 +};
1.573 +
1.574 +// unique ---------------------------------
1.575 +
1.576 +struct unique {
1.577 +
1.578 + template <class Args>
1.579 + struct sig {
1.580 + typedef typename boost::remove_const<
1.581 + typename boost::tuples::element<1, Args>::type
1.582 + >::type type;
1.583 + };
1.584 +
1.585 + template <class A>
1.586 + A
1.587 + operator()(A a, A b) const
1.588 + { return ::std::unique(a, b); }
1.589 +
1.590 + template <class A, class C>
1.591 + A
1.592 + operator()(A a, A b, C c) const
1.593 + { return ::std::unique(a, b, c); }
1.594 +
1.595 +};
1.596 +
1.597 +// unique_copy ---------------------------------
1.598 +
1.599 +struct unique_copy {
1.600 +
1.601 + template <class Args>
1.602 + struct sig {
1.603 + typedef typename boost::remove_const<
1.604 + typename boost::tuples::element<3, Args>::type
1.605 + >::type type;
1.606 + };
1.607 +
1.608 + template <class A, class C >
1.609 + C
1.610 + operator()(A a, A b, C c) const
1.611 + { return ::std::unique_copy(a, b, c); }
1.612 +
1.613 + template <class A, class C, class D>
1.614 + C
1.615 + operator()(A a, A b, C c, D d) const
1.616 + { return ::std::unique_copy(a, b, c, d); }
1.617 +
1.618 +};
1.619 +
1.620 +// reverse ---------------------------------
1.621 +
1.622 +struct reverse {
1.623 +
1.624 + template <class Args>
1.625 + struct sig {
1.626 + typedef void type;
1.627 + };
1.628 +
1.629 + template <class A>
1.630 + void
1.631 + operator()(A a, A b) const
1.632 + { ::std::reverse(a, b); }
1.633 +
1.634 +};
1.635 +
1.636 +// reverse_copy ---------------------------------
1.637 +
1.638 +struct reverse_copy {
1.639 +
1.640 + template <class Args>
1.641 + struct sig {
1.642 + typedef typename boost::remove_const<
1.643 + typename boost::tuples::element<3, Args>::type
1.644 + >::type type;
1.645 + };
1.646 +
1.647 + template <class A, class C >
1.648 + C
1.649 + operator()(A a, A b, C c) const
1.650 + { return ::std::reverse_copy(a, b, c); }
1.651 +
1.652 +};
1.653 +
1.654 +// rotate ---------------------------------
1.655 +
1.656 +struct rotate {
1.657 +
1.658 + template <class Args>
1.659 + struct sig {
1.660 + typedef void type;
1.661 + };
1.662 +
1.663 + template <class A>
1.664 + void
1.665 + operator()(A a, A b, A c) const
1.666 + { ::std::rotate(a, b, c); }
1.667 +
1.668 +};
1.669 +
1.670 +// rotate_copy ---------------------------------
1.671 +
1.672 +struct rotate_copy {
1.673 +
1.674 + template <class Args>
1.675 + struct sig {
1.676 + typedef typename boost::remove_const<
1.677 + typename boost::tuples::element<3, Args>::type
1.678 + >::type type;
1.679 + };
1.680 +
1.681 + template <class A, class D>
1.682 + D
1.683 + operator()(A a, A b, A c, D d) const
1.684 + { return ::std::rotate_copy(a, b, c, d); }
1.685 +
1.686 +};
1.687 +
1.688 +// random_shuffle ---------------------------------
1.689 +
1.690 +struct random_shuffle {
1.691 +
1.692 + template <class Args>
1.693 + struct sig {
1.694 + typedef void type;
1.695 + };
1.696 +
1.697 + template <class A>
1.698 + void
1.699 + operator()(A a, A b) const
1.700 + { ::std::random_shuffle(a, b); }
1.701 +
1.702 + template <class A, class C>
1.703 + void
1.704 + operator()(A a, A b, const C& c) const
1.705 + { ::std::random_shuffle(a, b, c); }
1.706 +
1.707 +};
1.708 +
1.709 +
1.710 +// partition ---------------------------------
1.711 +
1.712 +struct partition {
1.713 +
1.714 + template <class Args>
1.715 + struct sig {
1.716 + typedef typename boost::remove_const<
1.717 + typename boost::tuples::element<1, Args>::type
1.718 + >::type type;
1.719 + };
1.720 +
1.721 + template <class A, class C>
1.722 + A
1.723 + operator()(A a, A b, C c) const
1.724 + { return ::std::partition(a, b, c); }
1.725 +
1.726 +};
1.727 +
1.728 +// stable_partition ---------------------------------
1.729 +
1.730 +struct stable_partition {
1.731 +
1.732 + template <class Args>
1.733 + struct sig {
1.734 + typedef typename boost::remove_const<
1.735 + typename boost::tuples::element<1, Args>::type
1.736 + >::type type;
1.737 + };
1.738 +
1.739 + template <class A, class C>
1.740 + A
1.741 + operator()(A a, A b, C c) const
1.742 + { return ::std::stable_partition(a, b, c); }
1.743 +
1.744 +};
1.745 +
1.746 +// sort ---------------------------------
1.747 +
1.748 +struct sort {
1.749 +
1.750 + template <class Args>
1.751 + struct sig {
1.752 + typedef void type;
1.753 + };
1.754 +
1.755 + template <class A>
1.756 + void
1.757 + operator()(A a, A b) const
1.758 + { ::std::sort(a, b); }
1.759 +
1.760 + template <class A, class C>
1.761 + void
1.762 + operator()(A a, A b, C c) const
1.763 + { ::std::sort(a, b, c); }
1.764 +
1.765 +};
1.766 +
1.767 +// stable_sort ---------------------------------
1.768 +
1.769 +struct stable_sort {
1.770 +
1.771 + template <class Args>
1.772 + struct sig {
1.773 + typedef void type;
1.774 + };
1.775 +
1.776 + template <class A>
1.777 + void
1.778 + operator()(A a, A b) const
1.779 + { ::std::stable_sort(a, b); }
1.780 +
1.781 + template <class A, class C>
1.782 + void
1.783 + operator()(A a, A b, C c) const
1.784 + { ::std::stable_sort(a, b, c); }
1.785 +
1.786 +};
1.787 +
1.788 +// partial_sort ---------------------------------
1.789 +
1.790 +struct partial_sort {
1.791 +
1.792 + template <class Args>
1.793 + struct sig {
1.794 + typedef void type;
1.795 + };
1.796 +
1.797 + template <class A>
1.798 + void
1.799 + operator()(A a, A b, A c) const
1.800 + { ::std::partial_sort(a, b, c); }
1.801 +
1.802 + template <class A, class D>
1.803 + void
1.804 + operator()(A a, A b, A c, D d) const
1.805 + { ::std::partial_sort(a, b, c, d); }
1.806 +
1.807 +};
1.808 +
1.809 +// partial_sort_copy ---------------------------------
1.810 +
1.811 +struct partial_sort_copy {
1.812 +
1.813 + template <class Args>
1.814 + struct sig {
1.815 + typedef typename boost::remove_const<
1.816 + typename boost::tuples::element<3, Args>::type
1.817 + >::type type;
1.818 + };
1.819 +
1.820 + template <class A, class C>
1.821 + C
1.822 + operator()(A a, A b, C c, C d) const
1.823 + { return ::std::partial_sort_copy(a, b, c, d); }
1.824 +
1.825 + template <class A, class C, class E >
1.826 + C
1.827 + operator()(A a, A b, C c, C d, E e) const
1.828 + { return ::std::partial_sort_copy(a, b, c, d, e); }
1.829 +};
1.830 +
1.831 +// nth_element ---------------------------------
1.832 +
1.833 +struct nth_element {
1.834 +
1.835 + template <class Args>
1.836 + struct sig {
1.837 + typedef void type;
1.838 + };
1.839 +
1.840 + template <class A>
1.841 + void
1.842 + operator()(A a, A b, A c) const
1.843 + { ::std::nth_element(a, b, c); }
1.844 +
1.845 + template <class A, class D>
1.846 + void
1.847 + operator()(A a, A b, A c, D d) const
1.848 + { ::std::nth_element(a, b, c, d); }
1.849 +
1.850 +};
1.851 +
1.852 +// lower_bound ---------------------------------
1.853 +
1.854 +struct lower_bound {
1.855 +
1.856 + template <class Args>
1.857 + struct sig {
1.858 + typedef typename boost::remove_const<
1.859 + typename boost::tuples::element<1, Args>::type
1.860 + >::type type;
1.861 + };
1.862 +
1.863 + template <class A, class C>
1.864 + A
1.865 + operator()(A a, A b, const C& c) const
1.866 + { return ::std::lower_bound(a, b, c); }
1.867 +
1.868 + template <class A, class C, class D>
1.869 + A
1.870 + operator()(A a, A b, const C& c, D d) const
1.871 + { return ::std::lower_bound(a, b, c, d); }
1.872 +
1.873 +};
1.874 +
1.875 +// upper_bound ---------------------------------
1.876 +
1.877 +struct upper_bound {
1.878 +
1.879 + template <class Args>
1.880 + struct sig {
1.881 + typedef typename boost::remove_const<
1.882 + typename boost::tuples::element<1, Args>::type
1.883 + >::type type;
1.884 + };
1.885 +
1.886 + template <class A, class C>
1.887 + A
1.888 + operator()(A a, A b, const C& c) const
1.889 + { return ::std::upper_bound(a, b, c); }
1.890 +
1.891 + template <class A, class C, class D>
1.892 + A
1.893 + operator()(A a, A b, const C& c, D d) const
1.894 + { return ::std::upper_bound(a, b, c, d); }
1.895 +
1.896 +};
1.897 +
1.898 +// equal_range ---------------------------------
1.899 +
1.900 +struct equal_range {
1.901 +
1.902 + template <class Args>
1.903 + struct sig {
1.904 + typedef typename boost::remove_const<
1.905 + typename boost::tuples::element<1, Args>::type
1.906 + >::type element_type;
1.907 +
1.908 + typedef ::std::pair< element_type, element_type > type;
1.909 + };
1.910 +
1.911 + template <class A, class C>
1.912 + ::std::pair<A,A>
1.913 + operator()(A a, A b, const C& c) const
1.914 + { return ::std::equal_range(a, b, c); }
1.915 +
1.916 + template <class A, class C, class D>
1.917 + ::std::pair<A,A>
1.918 + operator()(A a, A b, const C& c, D d) const
1.919 + { return ::std::equal_range(a, b, c, d); }
1.920 +
1.921 +};
1.922 +
1.923 +// binary_search ---------------------------------
1.924 +
1.925 +struct binary_search {
1.926 +
1.927 + template <class Args>
1.928 + struct sig {
1.929 + typedef bool type;
1.930 + };
1.931 +
1.932 + template <class A, class C >
1.933 + bool
1.934 + operator()(A a, A b, const C& c) const
1.935 + { return ::std::binary_search(a, b, c); }
1.936 +
1.937 + template <class A, class C, class D>
1.938 + bool
1.939 + operator()(A a, A b, const C& c, D d) const
1.940 + { return ::std::binary_search(a, b, c, d); }
1.941 +
1.942 +};
1.943 +
1.944 +// merge --------------------------------
1.945 +
1.946 +struct merge {
1.947 +
1.948 + template <class Args>
1.949 + struct sig {
1.950 + typedef typename boost::remove_const<
1.951 + typename boost::tuples::element<5, Args>::type
1.952 + >::type type;
1.953 + };
1.954 +
1.955 + template <class A, class C, class E>
1.956 + E
1.957 + operator()(A a, A b, C c, C d, E e) const
1.958 + { return std::merge(a, b, c, d, e);}
1.959 +
1.960 + template <class A, class C, class E, class F>
1.961 + E
1.962 + operator()(A a, A b, C c, C d, E e, F f) const
1.963 + { return std::merge(a, b, c, d, e, f);}
1.964 +
1.965 +};
1.966 +
1.967 +// inplace_merge ---------------------------------
1.968 +
1.969 +struct inplace_merge {
1.970 +
1.971 + template <class Args>
1.972 + struct sig {
1.973 + typedef void type;
1.974 + };
1.975 +
1.976 + template <class A>
1.977 + void
1.978 + operator()(A a, A b, A c) const
1.979 + { ::std::inplace_merge(a, b, c); }
1.980 +
1.981 + template <class A, class D>
1.982 + void
1.983 + operator()(A a, A b, A c, D d) const
1.984 + { ::std::inplace_merge(a, b, c, d); }
1.985 +
1.986 +};
1.987 +
1.988 +// includes ---------------------------------
1.989 +
1.990 +struct includes {
1.991 +
1.992 + template <class Args>
1.993 + struct sig {
1.994 + typedef bool type;
1.995 + };
1.996 +
1.997 + template <class A, class C>
1.998 + bool
1.999 + operator()(A a, A b, C c, C d) const
1.1000 + { return ::std::includes(a, b, c, d); }
1.1001 +
1.1002 + template <class A, class C, class E>
1.1003 + bool
1.1004 + operator()(A a, A b, C c, C d, E e) const
1.1005 + { return ::std::includes(a, b, c, d, e); }
1.1006 +
1.1007 +};
1.1008 +
1.1009 +// set_union --------------------------------
1.1010 +
1.1011 +struct set_union {
1.1012 +
1.1013 + template <class Args>
1.1014 + struct sig {
1.1015 + typedef typename boost::remove_const<
1.1016 + typename boost::tuples::element<5, Args>::type
1.1017 + >::type type;
1.1018 + };
1.1019 +
1.1020 + template <class A, class C, class E>
1.1021 + E
1.1022 + operator()(A a, A b, C c, C d, E e) const
1.1023 + { return std::set_union(a, b, c, d, e);}
1.1024 +
1.1025 + template <class A, class C, class E, class F>
1.1026 + E
1.1027 + operator()(A a, A b, C c, C d, E e, F f) const
1.1028 + { return std::set_union(a, b, c, d, e, f);}
1.1029 +
1.1030 +};
1.1031 +
1.1032 +// set_intersection --------------------------------
1.1033 +
1.1034 +struct set_intersection {
1.1035 +
1.1036 + template <class Args>
1.1037 + struct sig {
1.1038 + typedef typename boost::remove_const<
1.1039 + typename boost::tuples::element<5, Args>::type
1.1040 + >::type type;
1.1041 + };
1.1042 +
1.1043 + template <class A, class C, class E>
1.1044 + E
1.1045 + operator()(A a, A b, C c, C d, E e) const
1.1046 + { return std::set_intersection(a, b, c, d, e);}
1.1047 +
1.1048 + template <class A, class C, class E, class F>
1.1049 + E
1.1050 + operator()(A a, A b, C c, C d, E e, F f) const
1.1051 + { return std::set_intersection(a, b, c, d, e, f);}
1.1052 +
1.1053 +};
1.1054 +
1.1055 +// set_difference --------------------------------
1.1056 +
1.1057 +struct set_difference {
1.1058 +
1.1059 + template <class Args>
1.1060 + struct sig {
1.1061 + typedef typename boost::remove_const<
1.1062 + typename boost::tuples::element<5, Args>::type
1.1063 + >::type type;
1.1064 + };
1.1065 +
1.1066 + template <class A, class C, class E>
1.1067 + E
1.1068 + operator()(A a, A b, C c, C d, E e) const
1.1069 + { return std::set_difference(a, b, c, d, e);}
1.1070 +
1.1071 + template <class A, class C, class E, class F>
1.1072 + E
1.1073 + operator()(A a, A b, C c, C d, E e, F f) const
1.1074 + { return std::set_difference(a, b, c, d, e, f);}
1.1075 +
1.1076 +};
1.1077 +
1.1078 +
1.1079 +// set_symmetric_difference --------------------------------
1.1080 +
1.1081 +struct set_symmetric_difference {
1.1082 +
1.1083 + template <class Args>
1.1084 + struct sig {
1.1085 + typedef typename boost::remove_const<
1.1086 + typename boost::tuples::element<5, Args>::type
1.1087 + >::type type;
1.1088 + };
1.1089 +
1.1090 + template <class A, class C, class E>
1.1091 + E
1.1092 + operator()(A a, A b, C c, C d, E e) const
1.1093 + { return std::set_symmetric_difference(a, b, c, d, e);}
1.1094 +
1.1095 + template <class A, class C, class E, class F>
1.1096 + E
1.1097 + operator()(A a, A b, C c, C d, E e, F f) const
1.1098 + { return std::set_symmetric_difference(a, b, c, d, e, f);}
1.1099 +
1.1100 +};
1.1101 +
1.1102 +// push_heap ---------------------------------
1.1103 +
1.1104 +struct push_heap {
1.1105 +
1.1106 + template <class Args>
1.1107 + struct sig {
1.1108 + typedef void type;
1.1109 + };
1.1110 +
1.1111 + template <class A>
1.1112 + void
1.1113 + operator()(A a, A b) const
1.1114 + { ::std::push_heap(a, b); }
1.1115 +
1.1116 + template <class A, class C>
1.1117 + void
1.1118 + operator()(A a, A b, C c) const
1.1119 + { ::std::push_heap(a, b, c); }
1.1120 +
1.1121 +};
1.1122 +
1.1123 +// pop_heap ---------------------------------
1.1124 +
1.1125 +struct pop_heap {
1.1126 +
1.1127 + template <class Args>
1.1128 + struct sig {
1.1129 + typedef void type;
1.1130 + };
1.1131 +
1.1132 + template <class A>
1.1133 + void
1.1134 + operator()(A a, A b) const
1.1135 + { ::std::pop_heap(a, b); }
1.1136 +
1.1137 + template <class A, class C>
1.1138 + void
1.1139 + operator()(A a, A b, C c) const
1.1140 + { ::std::pop_heap(a, b, c); }
1.1141 +
1.1142 +};
1.1143 +
1.1144 +
1.1145 +// make_heap ---------------------------------
1.1146 +
1.1147 +struct make_heap {
1.1148 +
1.1149 + template <class Args>
1.1150 + struct sig {
1.1151 + typedef void type;
1.1152 + };
1.1153 +
1.1154 + template <class A>
1.1155 + void
1.1156 + operator()(A a, A b) const
1.1157 + { ::std::make_heap(a, b); }
1.1158 +
1.1159 + template <class A, class C>
1.1160 + void
1.1161 + operator()(A a, A b, C c) const
1.1162 + { ::std::make_heap(a, b, c); }
1.1163 +
1.1164 +};
1.1165 +
1.1166 +// sort_heap ---------------------------------
1.1167 +
1.1168 +struct sort_heap {
1.1169 +
1.1170 + template <class Args>
1.1171 + struct sig {
1.1172 + typedef void type;
1.1173 + };
1.1174 +
1.1175 + template <class A>
1.1176 + void
1.1177 + operator()(A a, A b) const
1.1178 + { ::std::sort_heap(a, b); }
1.1179 +
1.1180 + template <class A, class C>
1.1181 + void
1.1182 + operator()(A a, A b, C c) const
1.1183 + { ::std::sort_heap(a, b, c); }
1.1184 +
1.1185 +};
1.1186 +
1.1187 +// min ---------------------------------
1.1188 +
1.1189 +struct min {
1.1190 +
1.1191 + template <class Args>
1.1192 + struct sig {
1.1193 + typedef typename boost::remove_const<
1.1194 + typename boost::tuples::element<1, Args>::type
1.1195 + >::type type;
1.1196 + };
1.1197 +
1.1198 + template <class A>
1.1199 + A
1.1200 + operator()(const A& a, const A& b) const
1.1201 + { return (::std::min)(a, b); }
1.1202 +
1.1203 + template <class A, class C>
1.1204 + A
1.1205 + operator()(const A& a, const A& b, C c) const
1.1206 + { return (::std::min)(a, b, c); }
1.1207 +
1.1208 +};
1.1209 +
1.1210 +// max ---------------------------------
1.1211 +
1.1212 +struct max {
1.1213 +
1.1214 + template <class Args>
1.1215 + struct sig {
1.1216 + typedef typename boost::remove_const<
1.1217 + typename boost::tuples::element<1, Args>::type
1.1218 + >::type type;
1.1219 + };
1.1220 +
1.1221 + template <class A>
1.1222 + A
1.1223 + operator()(const A& a, const A& b) const
1.1224 + { return (::std::max)(a, b); }
1.1225 +
1.1226 + template <class A, class C>
1.1227 + A
1.1228 + operator()(const A& a, const A& b, C c) const
1.1229 + { return (::std::max)(a, b, c); }
1.1230 +
1.1231 +};
1.1232 +
1.1233 +struct min_element {
1.1234 +
1.1235 + template <class Args>
1.1236 + struct sig {
1.1237 + typedef typename boost::remove_const<
1.1238 + typename boost::tuples::element<1, Args>::type
1.1239 + >::type type;
1.1240 + };
1.1241 +
1.1242 + template <class A>
1.1243 + A
1.1244 + operator()(A a, A b) const
1.1245 + { return ::std::min_element(a, b); }
1.1246 +
1.1247 + template <class A, class C>
1.1248 + A
1.1249 + operator()(A a, A b, C c) const
1.1250 + { return ::std::min_element(a, b, c); }
1.1251 +
1.1252 +};
1.1253 +
1.1254 +// max_element ---------------------------------
1.1255 +
1.1256 +struct max_element {
1.1257 +
1.1258 + template <class Args>
1.1259 + struct sig {
1.1260 + typedef typename boost::remove_const<
1.1261 + typename boost::tuples::element<1, Args>::type
1.1262 + >::type type;
1.1263 + };
1.1264 +
1.1265 + template <class A>
1.1266 + A
1.1267 + operator()(A a, A b) const
1.1268 + { return ::std::max_element(a, b); }
1.1269 +
1.1270 + template <class A, class C>
1.1271 + A
1.1272 + operator()(A a, A b, C c) const
1.1273 + { return ::std::max_element(a, b, c); }
1.1274 +
1.1275 +};
1.1276 +
1.1277 +
1.1278 +// lexicographical_compare ---------------------------------
1.1279 +
1.1280 +struct lexicographical_compare {
1.1281 +
1.1282 + template <class Args>
1.1283 + struct sig {
1.1284 + typedef bool type;
1.1285 + };
1.1286 +
1.1287 + template <class A, class C>
1.1288 + bool
1.1289 + operator()(A a, A b, C c, C d) const
1.1290 + { return ::std::lexicographical_compare(a, b, c, d); }
1.1291 +
1.1292 + template <class A, class C, class E>
1.1293 + bool
1.1294 + operator()(A a, A b, C c, C d, E e) const
1.1295 + { return ::std::lexicographical_compare(a, b, c, d, e); }
1.1296 +
1.1297 +};
1.1298 +
1.1299 +// next_permutation ---------------------------------
1.1300 +
1.1301 +struct next_permutation {
1.1302 +
1.1303 + template <class Args>
1.1304 + struct sig {
1.1305 + typedef bool type;
1.1306 + };
1.1307 +
1.1308 + template <class A>
1.1309 + bool
1.1310 + operator()(A a, A b) const
1.1311 + { return ::std::next_permutation(a, b); }
1.1312 +
1.1313 + template <class A, class C >
1.1314 + bool
1.1315 + operator()(A a, A b, C c) const
1.1316 + { return ::std::next_permutation(a, b, c); }
1.1317 +
1.1318 +};
1.1319 +
1.1320 +// prev_permutation ---------------------------------
1.1321 +
1.1322 +struct prev_permutation {
1.1323 +
1.1324 + template <class Args>
1.1325 + struct sig {
1.1326 + typedef bool type;
1.1327 + };
1.1328 +
1.1329 + template <class A>
1.1330 + bool
1.1331 + operator()(A a, A b) const
1.1332 + { return ::std::prev_permutation(a, b); }
1.1333 +
1.1334 + template <class A, class C >
1.1335 + bool
1.1336 + operator()(A a, A b, C c) const
1.1337 + { return ::std::prev_permutation(a, b, c); }
1.1338 +
1.1339 +};
1.1340 +
1.1341 +
1.1342 +
1.1343 +
1.1344 +
1.1345 +} // end of ll namespace
1.1346 +
1.1347 +// There is no good way to call an overloaded member function in a
1.1348 +// lambda expression.
1.1349 +// The macro below defines a function object class for calling a
1.1350 +// const_iterator returning member function of a container.
1.1351 +
1.1352 +#define CALL_MEMBER(X) \
1.1353 +struct call_##X { \
1.1354 +template <class Args> \
1.1355 + struct sig { \
1.1356 + typedef typename boost::remove_const< \
1.1357 + typename boost::tuples::element<1, Args>::type \
1.1358 + >::type::const_iterator type; \
1.1359 + }; \
1.1360 + \
1.1361 + template<class T> \
1.1362 + typename T::const_iterator \
1.1363 + operator()(const T& t) const \
1.1364 + { \
1.1365 + return t.X(); \
1.1366 + } \
1.1367 +};
1.1368 +
1.1369 +// create call_begin and call_end classes
1.1370 +CALL_MEMBER(begin)
1.1371 +CALL_MEMBER(end)
1.1372 +
1.1373 +#undef CALL_MEMBER
1.1374 +
1.1375 +} // end of lambda namespace
1.1376 +} // end of boost namespace
1.1377 +
1.1378 +
1.1379 +
1.1380 +#endif