File: test_algorithm4.cpp

package info (click to toggle)
boost1.90 1.90.0-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 593,120 kB
  • sloc: cpp: 4,190,908; xml: 196,648; python: 34,618; ansic: 23,145; asm: 5,468; sh: 3,774; makefile: 1,161; perl: 1,020; sql: 728; ruby: 676; yacc: 478; java: 77; lisp: 24; csh: 6
file content (101 lines) | stat: -rw-r--r-- 3,891 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/* Copyright 2024 Joaquin M Lopez Munoz.
 * 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)
 *
 * See http://www.boost.org/libs/poly_collection for library home page.
 */

#include "test_algorithm4.hpp"

#include <boost/detail/workaround.hpp>
#include <boost/iterator/function_output_iterator.hpp>
#include <iterator>
#include <random>
#include <type_traits>
#include "variant_types.hpp"
#include "test_algorithm_impl.hpp"

template<typename T>
struct pierced_pred
{
  template<
    typename Q,
    typename std::enable_if<!std::is_same<T,Q>::value>::type* =nullptr
  >
  bool operator()(const Q&)const{return true;}

  template<
    typename Q,typename R,
    typename std::enable_if<
      !std::is_same<T,Q>::value&&!std::is_same<T,R>::value>::type* =nullptr
  >
  bool operator()(const Q&,const R&)const{return true;}
};

template<typename PolyCollection,typename T>
void test_total_restitution_algorithm()
{
  using namespace boost::poly_collection;
  using value_type=typename PolyCollection::value_type;

  PolyCollection           p;
  pierced_pred<value_type> pred;
  int                      seq[1];
  auto                     out=boost::make_function_output_iterator(pred);

#if BOOST_WORKAROUND(BOOST_MSVC,>=1910)&&BOOST_WORKAROUND(BOOST_MSVC,<1920)
/* Internal fix for https://lists.boost.org/Archives/boost/2017/06/235687.php
 * causes instantiation of std alg for value_type.
 */
#else
  (void)all_of<all_types>(p.begin(),p.end(),pred);
  (void)any_of<all_types>(p.begin(),p.end(),pred);
  (void)none_of<all_types>(p.begin(),p.end(),pred);
  (void)count_if<all_types>(p.begin(),p.end(),pred);
  (void)is_permutation<all_types>(
    p.begin(),p.end(),std::begin(seq),pred);
  (void)copy<all_types>(p.begin(),p.end(),out);
  (void)copy_if<all_types>(p.begin(),p.end(),out,pred);
  (void)rotate_copy<all_types>(p.begin(),p.begin(),p.end(),out);
  (void)move<all_types>(p.begin(),p.end(),out);
  (void)transform<all_types>(p.begin(),p.end(),out,pred);
  (void)remove_copy<all_types>(p.begin(),p.end(),out,T{0});
  (void)remove_copy_if<all_types>(p.begin(),p.end(),out,pred);
  (void)is_partitioned<all_types>(p.begin(),p.begin(),pred);
  (void)partition_copy<all_types>(p.begin(),p.begin(),out,out,pred);
#endif

  (void)for_each<all_types>(p.begin(),p.end(),pred);
  (void)for_each_n<all_types>(p.begin(),0,pred);
     /* find: no easy way to check value_type is not compared against */
  (void)find_if<all_types>(p.begin(),p.end(),pred);
  (void)find_if_not<all_types>(p.begin(),p.end(),pred);
  (void)find_end<all_types>
    (p.begin(),p.end(),std::begin(seq),std::end(seq),pred);
  (void)find_first_of<all_types>
    (p.begin(),p.end(),std::begin(seq),std::end(seq),pred);
  (void)adjacent_find<all_types>(p.begin(),p.end(),pred);
     /* count, no easy way to check value_type is not compared against */
  (void)mismatch<all_types>(p.begin(),p.end(),std::begin(seq),pred);
  (void)equal<all_types>(p.begin(),p.end(),std::begin(seq),pred);
  (void)search<all_types>(
    p.begin(),p.end(),std::begin(seq),std::end(seq),pred);
  (void)search_n<all_types>(p.begin(),p.end(),1,T{0},pred);
  (void)copy_n<all_types>(p.begin(),0,out);
  (void)replace_copy<all_types>(p.begin(),p.end(),out,T{0},T{0});
  (void)replace_copy_if<all_types>(p.begin(),p.end(),out,pred,T{0});
  (void)unique_copy<all_types>(p.begin(),p.end(),out,pred);
  (void)sample<all_types>(p.begin(),p.begin(),out,0,std::mt19937{});
  (void)partition_point<all_types>(p.begin(),p.begin(),pred);
};

void test_algorithm4()
{
  test_algorithm<
    variant_types::collection,jammed_auto_increment,variant_types::to_int,
    variant_types::t1,variant_types::t2,variant_types::t3,
    variant_types::t4,variant_types::t5>();
  test_total_restitution_algorithm<
    variant_types::collection,variant_types::t1>();
}