mirror of
https://github.com/boostorg/poly_collection.git
synced 2026-07-21 13:33:37 +00:00
Fix/null variant_collection (#27)
* fixed boost::variant_collection_of<> * added tests for ==/!=
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@ local library = "poly_collection";
|
||||
|
||||
local triggers =
|
||||
{
|
||||
branch: [ "master", "develop", "feature/*" ]
|
||||
branch: [ "master", "develop", "feature/*", "fix/*" ]
|
||||
};
|
||||
|
||||
local ubsan = { UBSAN: '1', UBSAN_OPTIONS: 'print_stacktrace=1' };
|
||||
|
||||
+3
-2
@@ -1876,7 +1876,8 @@ For the description of the algorithms we use the following notation:
|
||||
of a collection of Boost.PolyCollection such that \[`first`, `middle`) and
|
||||
\[`middle`, `last`) are valid ranges.
|
||||
* `args...` is a function parameter pack of types `Args&&...`,
|
||||
* `Ts...` is a template parameter pack of arbitrary types.
|
||||
* `Ts...` is a template parameter pack of acceptable types for the collection,
|
||||
plus optionally `all_types` in the case of closed collections.
|
||||
* Open collections: `Us...` is defined as `Ts...`.
|
||||
* Closed collections: `Us...` is defined as the set of all acceptable types
|
||||
in the collection if `all_types` is in `Ts...`, or as `Ts...` otherwise.
|
||||
@@ -1917,7 +1918,7 @@ value, which disallows this type of polymorphism.].[br]
|
||||
[*Effects:] Equivalent to `expr`.[br]
|
||||
[*Returns:] `expr`.[br]
|
||||
[*Complexity:] That of `expr`.[br]
|
||||
[*Note:] In the case of closed collections, if `Us...` contains all the
|
||||
[*Note:] In the case of closed collections, if `Us...` is not empty and contains all the
|
||||
acceptable types of the collection (/total restitution/), then
|
||||
the dereference operation of `rfirst`, `rmiddle` and `rlast` to the
|
||||
collection's `value_type` is not ever instantiated.
|
||||
|
||||
@@ -177,8 +177,8 @@ struct restitute_range_class<std::true_type /* total */,F,T>
|
||||
F f;
|
||||
};
|
||||
|
||||
template<typename F>
|
||||
struct restitute_range_class<std::false_type /* non total */,F>
|
||||
template<typename IsTotal,typename F>
|
||||
struct restitute_range_class<IsTotal,F>
|
||||
{
|
||||
restitute_range_class(const F& f):f(f){}
|
||||
|
||||
@@ -266,8 +266,8 @@ struct restitute_iterator_class<std::true_type /* total */,F,T>
|
||||
F f;
|
||||
};
|
||||
|
||||
template<typename F>
|
||||
struct restitute_iterator_class<std::false_type /* non total */,F>
|
||||
template<typename IsTotal,typename F>
|
||||
struct restitute_iterator_class<IsTotal,F>
|
||||
{
|
||||
restitute_iterator_class(const F& f):f(f){}
|
||||
|
||||
|
||||
+13
-12
@@ -24,16 +24,17 @@ project
|
||||
;
|
||||
|
||||
test-suite "poly_collection" :
|
||||
[ run test_algorithm.cpp test_algorithm1.cpp
|
||||
test_algorithm2.cpp test_algorithm3.cpp
|
||||
test_algorithm4.cpp test_algorithm_main.cpp ]
|
||||
[ run test_capacity.cpp test_capacity_main.cpp ]
|
||||
[ run test_comparison.cpp test_comparison_main.cpp ]
|
||||
[ run test_construction.cpp test_construction_main.cpp ]
|
||||
[ run test_emplacement.cpp test_emplacement_main.cpp ]
|
||||
[ run test_erasure.cpp test_erasure_main.cpp ]
|
||||
[ run test_fixed_variant.cpp test_fixed_variant_main.cpp ]
|
||||
[ run test_insertion.cpp test_insertion_main.cpp ]
|
||||
[ run test_iterators.cpp test_iterators_main.cpp ]
|
||||
[ run test_registration.cpp test_registration_main.cpp ]
|
||||
[ run test_algorithm.cpp test_algorithm1.cpp
|
||||
test_algorithm2.cpp test_algorithm3.cpp
|
||||
test_algorithm4.cpp test_algorithm_main.cpp ]
|
||||
[ run test_capacity.cpp test_capacity_main.cpp ]
|
||||
[ run test_comparison.cpp test_comparison_main.cpp ]
|
||||
[ run test_construction.cpp test_construction_main.cpp ]
|
||||
[ run test_emplacement.cpp test_emplacement_main.cpp ]
|
||||
[ run test_erasure.cpp test_erasure_main.cpp ]
|
||||
[ run test_fixed_variant.cpp test_fixed_variant_main.cpp ]
|
||||
[ run test_insertion.cpp test_insertion_main.cpp ]
|
||||
[ run test_iterators.cpp test_iterators_main.cpp ]
|
||||
[ run test_null_variant_collection.cpp test_null_variant_collection_main.cpp ]
|
||||
[ run test_registration.cpp test_registration_main.cpp ]
|
||||
;
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/* 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_null_variant_collection.hpp"
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/poly_collection/variant_collection.hpp>
|
||||
#include <boost/poly_collection/algorithm.hpp>
|
||||
#include <utility>
|
||||
#include "test_utilities.hpp"
|
||||
|
||||
using namespace test_utilities;
|
||||
|
||||
void test_null_variant_collection()
|
||||
{
|
||||
using boost::poly_collection::unregistered_type;
|
||||
using collection_type=boost::variant_collection_of<>;
|
||||
using value_type=collection_type::value_type;
|
||||
|
||||
collection_type c,c2{c},c3{std::move(c2)};
|
||||
const collection_type& cc=c;
|
||||
|
||||
c2=c;
|
||||
c=std::move(c2);
|
||||
|
||||
(void)c.get_allocator();
|
||||
|
||||
(void)c.begin();
|
||||
(void)c.end();
|
||||
(void)c.cbegin();
|
||||
(void)c.cend();
|
||||
check_throw<unregistered_type>(
|
||||
[&]{(void)c.begin(0);},
|
||||
[&]{(void)c.end(0);},
|
||||
[&]{(void)c.cbegin(0);},
|
||||
[&]{(void)c.cend(0);});
|
||||
|
||||
check_throw<unregistered_type>(
|
||||
[&]{c.segment(0);},
|
||||
[&]{cc.segment(0);});
|
||||
|
||||
for(auto seg:c.segment_traversal()){(void)seg;}
|
||||
for(auto seg:cc.segment_traversal()){(void)seg;}
|
||||
|
||||
BOOST_TEST(cc.empty());
|
||||
check_throw<unregistered_type>([&]{(void)cc.empty(0);});
|
||||
|
||||
BOOST_TEST_EQ(cc.size(),0);
|
||||
check_throw<unregistered_type>([&]{(void)cc.size(0);});
|
||||
|
||||
check_throw<unregistered_type>([&]{(void)cc.capacity(0);});
|
||||
|
||||
c.shrink_to_fit();
|
||||
check_throw<unregistered_type>([&]{(void)c.shrink_to_fit(0);});
|
||||
|
||||
c.clear();
|
||||
check_throw<unregistered_type>([&]{(void)c.clear(0);});
|
||||
|
||||
c.swap(c);
|
||||
|
||||
BOOST_TEST(cc==cc);
|
||||
BOOST_TEST(!(cc!=cc));
|
||||
|
||||
auto f=[](value_type&){};
|
||||
|
||||
boost::poly_collection::for_each(c.begin(),c.end(),f);
|
||||
boost::poly_collection::for_each_n(c.begin(),0,f);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
void test_null_variant_collection();
|
||||
@@ -0,0 +1,16 @@
|
||||
/* 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 <boost/core/lightweight_test.hpp>
|
||||
#include "test_null_variant_collection.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
test_null_variant_collection();
|
||||
return boost::report_errors();
|
||||
}
|
||||
Reference in New Issue
Block a user