diff --git a/.drone.jsonnet b/.drone.jsonnet index dac39c2..f7404d9 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -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' }; diff --git a/doc/reference.qbk b/doc/reference.qbk index 872a98c..eafdaba 100644 --- a/doc/reference.qbk +++ b/doc/reference.qbk @@ -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. diff --git a/include/boost/poly_collection/detail/type_restitution.hpp b/include/boost/poly_collection/detail/type_restitution.hpp index 111223c..7a6387d 100644 --- a/include/boost/poly_collection/detail/type_restitution.hpp +++ b/include/boost/poly_collection/detail/type_restitution.hpp @@ -177,8 +177,8 @@ struct restitute_range_class F f; }; -template -struct restitute_range_class +template +struct restitute_range_class { restitute_range_class(const F& f):f(f){} @@ -266,8 +266,8 @@ struct restitute_iterator_class F f; }; -template -struct restitute_iterator_class +template +struct restitute_iterator_class { restitute_iterator_class(const F& f):f(f){} diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index f38c353..7d9ca8f 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -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 ] ; diff --git a/test/test_null_variant_collection.cpp b/test/test_null_variant_collection.cpp new file mode 100644 index 0000000..4d6a4c6 --- /dev/null +++ b/test/test_null_variant_collection.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 +#include +#include +#include +#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( + [&]{(void)c.begin(0);}, + [&]{(void)c.end(0);}, + [&]{(void)c.cbegin(0);}, + [&]{(void)c.cend(0);}); + + check_throw( + [&]{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([&]{(void)cc.empty(0);}); + + BOOST_TEST_EQ(cc.size(),0); + check_throw([&]{(void)cc.size(0);}); + + check_throw([&]{(void)cc.capacity(0);}); + + c.shrink_to_fit(); + check_throw([&]{(void)c.shrink_to_fit(0);}); + + c.clear(); + check_throw([&]{(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); +} diff --git a/test/test_null_variant_collection.hpp b/test/test_null_variant_collection.hpp new file mode 100644 index 0000000..9443ce4 --- /dev/null +++ b/test/test_null_variant_collection.hpp @@ -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(); diff --git a/test/test_null_variant_collection_main.cpp b/test/test_null_variant_collection_main.cpp new file mode 100644 index 0000000..05d96a9 --- /dev/null +++ b/test/test_null_variant_collection_main.cpp @@ -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 +#include "test_null_variant_collection.hpp" + +int main() +{ + test_null_variant_collection(); + return boost::report_errors(); +}