From 0153ee19202f0d8b417585bdb7d44f604995a73b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 2 Jan 2021 00:37:44 +0100 Subject: [PATCH] Rewrite [flat_]map/set insert overloads to be more standard compliant. Fixes #102 ("flat_map::insert ambiguous with initializer list & pairs that need to convert"). --- test/map_test.hpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/test/map_test.hpp b/test/map_test.hpp index d3ce4cb..e422dc3 100644 --- a/test/map_test.hpp +++ b/test/map_test.hpp @@ -103,6 +103,44 @@ int map_test_copyable(boost::container::dtl::true_type) } if(!CheckEqualContainers(boostmap, stdmap)) return 1; if(!CheckEqualContainers(boostmultimap, stdmultimap)) return 1; + + boostmap.clear(); + boostmap.clear(); + boostmultimap.clear(); + stdmultimap.clear(); + //Now try from convertible pair + for(i = 0; i < MaxElem; ++i){ + { + boostmap.insert(std::pair(i, i)); + stdmap.insert(StdPairType(i, i)); + } + { + boostmultimap.insert(std::pair(i, i)); + stdmultimap.insert(StdPairType(i, i)); + } + } + if(!CheckEqualContainers(boostmap, stdmap)) return 1; + if(!CheckEqualContainers(boostmultimap, stdmultimap)) return 1; + + #if !defined BOOST_NO_CXX11_HDR_INITIALIZER_LIST + boostmap.clear(); + boostmap.clear(); + boostmultimap.clear(); + stdmultimap.clear(); + //Now try from convertible pair + for(i = 0; i < MaxElem; ++i){ + { + boostmap.insert({IntType(i), IntType(i)}); + stdmap.insert(StdPairType(i, i)); + } + { + boostmultimap.insert({IntType(i), IntType(i)}); + stdmultimap.insert(StdPairType(i, i)); + } + } + if(!CheckEqualContainers(boostmap, stdmap)) return 1; + if(!CheckEqualContainers(boostmultimap, stdmultimap)) return 1; + #endif //BOOST_NO_CXX11_HDR_INITIALIZER_LIST { //Now, test copy constructor MyBoostMap boostmapcopy(boostmap);