| 1 | // BoostContainerPmrCompilationError.cpp :
|
|---|
| 2 | // minimal file to reproduce compilation error while using
|
|---|
| 3 | // boost 1.63.0 boost::container::pmr::polymorphic_allocator
|
|---|
| 4 | // with boost::container::map, std::map, std::unordered_map
|
|---|
| 5 | //
|
|---|
| 6 | #include <boost/container/pmr/unsynchronized_pool_resource.hpp>
|
|---|
| 7 | #include <boost/container/pmr/polymorphic_allocator.hpp>
|
|---|
| 8 | #if 1
|
|---|
| 9 | #include <boost/container/map.hpp>
|
|---|
| 10 |
|
|---|
| 11 | namespace pmr = boost::container::pmr;
|
|---|
| 12 | int main()
|
|---|
| 13 | {
|
|---|
| 14 | using KeyType = size_t;
|
|---|
| 15 | pmr::unsynchronized_pool_resource memoryResource;
|
|---|
| 16 | pmr::polymorphic_allocator<std::pair<const KeyType, size_t>> myAllocator(&memoryResource);
|
|---|
| 17 | boost::container::map<KeyType, size_t, std::less<KeyType>
|
|---|
| 18 | , pmr::polymorphic_allocator<std::pair<const KeyType, size_t> >
|
|---|
| 19 | > myMap(myAllocator);
|
|---|
| 20 |
|
|---|
| 21 | myMap.try_emplace(static_cast<size_t>(1), static_cast<size_t>(1));
|
|---|
| 22 | return 0;
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | #elif 0
|
|---|
| 26 |
|
|---|
| 27 | #include <map>
|
|---|
| 28 | namespace pmr = boost::container::pmr;
|
|---|
| 29 | int main()
|
|---|
| 30 | {
|
|---|
| 31 | using KeyType = size_t;
|
|---|
| 32 | pmr::unsynchronized_pool_resource memoryResource;
|
|---|
| 33 | pmr::polymorphic_allocator<std::pair<const KeyType, size_t>> myAllocator(&memoryResource);
|
|---|
| 34 | std::map<KeyType, size_t, std::less<KeyType>
|
|---|
| 35 | , pmr::polymorphic_allocator<std::pair<const KeyType, size_t> >
|
|---|
| 36 | > myMap(myAllocator);
|
|---|
| 37 |
|
|---|
| 38 | myMap.try_emplace(static_cast<size_t>(1), static_cast<size_t>(1));
|
|---|
| 39 | return 0;
|
|---|
| 40 | }
|
|---|
| 41 | #else
|
|---|
| 42 |
|
|---|
| 43 | #include <unordered_map>
|
|---|
| 44 |
|
|---|
| 45 | namespace pmr = boost::container::pmr;
|
|---|
| 46 | int main()
|
|---|
| 47 | {
|
|---|
| 48 | using KeyType = size_t;
|
|---|
| 49 | pmr::unsynchronized_pool_resource memoryResource;
|
|---|
| 50 | boost::unordered_map<KeyType, size_t,
|
|---|
| 51 | std::hash<KeyType>,
|
|---|
| 52 | std::equal_to<KeyType>,
|
|---|
| 53 | pmr::polymorphic_allocator<std::pair<const KeyType, size_t> >
|
|---|
| 54 | > myHashMap(10,
|
|---|
| 55 | std::hash<KeyType>(),
|
|---|
| 56 | std::equal_to<KeyType>(),
|
|---|
| 57 | pmr::polymorphic_allocator<std::pair<const KeyType, size_t> >(
|
|---|
| 58 | &memoryResource
|
|---|
| 59 | )
|
|---|
| 60 | );
|
|---|
| 61 | myHashMap.emplace(static_cast<size_t>(1), static_cast<size_t>(1));
|
|---|
| 62 | return 0;
|
|---|
| 63 | }
|
|---|
| 64 | #endif
|
|---|