]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/range/test/adaptor_test/filtered.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / range / test / adaptor_test / filtered.cpp
index 17a457fb97f49cceee926fb1389105b3ea41e9a2..be3487262f280525e875ccaafd74c100a9e46850 100644 (file)
@@ -51,6 +51,23 @@ namespace boost
             bool operator()( IntegerT x ) const { return x % 2 != 0; }
         };
 
+        struct lambda_init
+        {
+        };
+
+        struct lambda
+        {
+            lambda(const lambda_init& init) {}
+            lambda(const lambda& rhs) {}
+
+            template< class T1 >
+            bool operator()(T1) const { return false; }
+
+        private:
+            lambda() {}
+            lambda& operator=(const lambda& rhs) { return *this; }
+        };
+
         template< class Container, class Pred >
         void filtered_test_impl( Container& c, Pred pred )
         {
@@ -86,32 +103,53 @@ namespace boost
                                            test_result2.end() );
         }
 
+        template< class Rng >
+        void check_copy_assign(Rng r)
+        {
+            Rng r2 = r;
+            r2 = r;
+        }
+
         template< class Container, class Pred >
+        void filtered_range_copy_assign(Container& c, Pred pred)
+        {
+            using namespace boost::adaptors;
+            check_copy_assign(c | filtered(pred));
+            check_copy_assign(adaptors::filter(c, pred));
+        }
+
+        template< class Container, class Pred, class PredInit >
         void filtered_test_impl()
         {
             using namespace boost::assign;
 
             Container c;
+            PredInit init;
+            Pred pred(init);
 
             // test empty container
-            filtered_test_impl(c, Pred());
+            filtered_test_impl(c, pred);
 
             // test one element
             c += 1;
-            filtered_test_impl(c, Pred());
+            filtered_test_impl(c, pred);
 
             // test many elements
             c += 1,2,2,2,3,4,4,4,4,5,6,7,8,9,9;
-            filtered_test_impl(c, Pred());
+            filtered_test_impl(c, pred);
+
+            // test the range and iterator are copy assignable
+            filtered_range_copy_assign(c, pred);
         }
 
         template< class Container >
         void filtered_test_all_predicates()
         {
-            filtered_test_impl< Container, always_false_pred >();
-            filtered_test_impl< Container, always_true_pred >();
-            filtered_test_impl< Container, is_odd >();
-            filtered_test_impl< Container, is_even >();
+            filtered_test_impl< Container, always_false_pred, always_false_pred >();
+            filtered_test_impl< Container, always_true_pred, always_true_pred >();
+            filtered_test_impl< Container, is_odd, is_odd >();
+            filtered_test_impl< Container, is_even, is_even >();
+            filtered_test_impl< Container, lambda, lambda_init >();
         }
 
         void ticket_10988_single_pass()