From 80d742f860953d2d9c476cdbcdce1db721d0aa40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Mon, 25 May 2020 01:50:23 +0200 Subject: [PATCH] Added C++03 portable aliases and tests. Fixes #129 ("Alias templates for small_flat_[multi]{set|map} using small_vector as container") --- doc/container.qbk | 3 +- include/boost/container/container_fwd.hpp | 46 +++++++++++++++++++++++ test/flat_map_adaptor_test.cpp | 15 ++++++++ test/flat_set_adaptor_test.cpp | 14 +++++++ 4 files changed, 77 insertions(+), 1 deletion(-) diff --git a/doc/container.qbk b/doc/container.qbk index 3ff37f1..44dcaf9 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -1319,7 +1319,8 @@ use [*Boost.Container]? There are several reasons for that: [section:release_notes_boost_1_74_00 Boost 1.74 Release] -* Fixed bugs: +* Fixed bugs/issues: + * [@https://github.com/boostorg/container/issues/129 GitHub #129: ['"Alias templates for small_flat_[multi]{set|map} using small_vector as container"]]. * [@https://github.com/boostorg/container/issues/144 GitHub #144: ['"GCC suggest-override warnings"]]. * [@https://github.com/boostorg/container/issues/145 GitHub #145: ['"Allocations not handled correctly in some cases of vector move with unequal allocators"]]. * [@https://github.com/boostorg/container/pull/146 GitHub #146: ['"Changes for Embarcadero C++ clang-based compilers, targeting Boost 1.74. Addition needed for Embarcardero clang-based compilers"]]. diff --git a/include/boost/container/container_fwd.hpp b/include/boost/container/container_fwd.hpp index 95341d1..fb4d7bd 100644 --- a/include/boost/container/container_fwd.hpp +++ b/include/boost/container/container_fwd.hpp @@ -220,6 +220,52 @@ using small_flat_multimap = flat_multimap + , class SmallVectorAllocator = void + , class SmallVectorOptions = void > +struct small_flat_set_of +{ + typedef flat_set > type; +}; + +//! A portable metafunction to obtain a small_flat_multiset +template < class Key + , std::size_t N + , class Compare = std::less + , class SmallVectorAllocator = void + , class SmallVectorOptions = void > +struct small_flat_multiset_of +{ + typedef flat_multiset > type; +}; + +//! A portable metafunction to obtain a small_flat_map +template < class Key + , class T + , std::size_t N + , class Compare = std::less + , class SmallVectorAllocator = void + , class SmallVectorOptions = void > +struct small_flat_map_of +{ + typedef flat_map, N, SmallVectorAllocator, SmallVectorOptions> > type; +}; + +//! A portable metafunction to obtain a small_flat_multimap +template < class Key + , class T + , std::size_t N + , class Compare = std::less + , class SmallVectorAllocator = void + , class SmallVectorOptions = void > +struct small_flat_multimap_of +{ + typedef flat_multimap, N, SmallVectorAllocator, SmallVectorOptions> > type; +}; + template ,class Allocator = void > diff --git a/test/flat_map_adaptor_test.cpp b/test/flat_map_adaptor_test.cpp index 520ef3c..bc75949 100644 --- a/test/flat_map_adaptor_test.cpp +++ b/test/flat_map_adaptor_test.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include @@ -99,6 +100,20 @@ int main() return 1; } } + { + using namespace boost::container; + using boost::container::dtl::is_same; + + typedef flat_map, small_vector, 10> > map_container_t; + typedef flat_multimap, small_vector, 10> > multimap_container_t; + #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) + BOOST_STATIC_ASSERT(( is_same >::value )); + BOOST_STATIC_ASSERT(( is_same >::value )); + #endif + + BOOST_STATIC_ASSERT(( is_same::type >::value )); + BOOST_STATIC_ASSERT(( is_same::type >::value )); + } return 0; } diff --git a/test/flat_set_adaptor_test.cpp b/test/flat_set_adaptor_test.cpp index b59ab17..6225bbf 100644 --- a/test/flat_set_adaptor_test.cpp +++ b/test/flat_set_adaptor_test.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include @@ -96,6 +97,19 @@ int main() return 1; } } + { + using namespace boost::container; + using boost::container::dtl::is_same; + + typedef flat_set, small_vector > set_container_t; + typedef flat_multiset, small_vector > multiset_container_t; + #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) + BOOST_STATIC_ASSERT(( is_same >::value )); + BOOST_STATIC_ASSERT(( is_same >::value )); + #endif + BOOST_STATIC_ASSERT(( is_same::type >::value )); + BOOST_STATIC_ASSERT(( is_same::type >::value )); + } return 0; }