| 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // <map> |
| 10 | |
| 11 | // template <class Key, class T, class Compare = less<Key>, |
| 12 | // class Allocator = allocator<pair<const Key, T>>> |
| 13 | // class multimap |
| 14 | // { |
| 15 | // public: |
| 16 | // // types: |
| 17 | // typedef Key key_type; |
| 18 | // typedef T mapped_type; |
| 19 | // typedef pair<const key_type, mapped_type> value_type; |
| 20 | // typedef Compare key_compare; |
| 21 | // typedef Allocator allocator_type; |
| 22 | // typedef typename allocator_type::reference reference; |
| 23 | // typedef typename allocator_type::const_reference const_reference; |
| 24 | // typedef typename allocator_type::pointer pointer; |
| 25 | // typedef typename allocator_type::const_pointer const_pointer; |
| 26 | // typedef typename allocator_type::size_type size_type; |
| 27 | // typedef typename allocator_type::difference_type difference_type; |
| 28 | // ... |
| 29 | // }; |
| 30 | |
| 31 | #include <map> |
| 32 | #include <type_traits> |
| 33 | |
| 34 | #include "test_macros.h" |
| 35 | #include "min_allocator.h" |
| 36 | |
| 37 | int main(int, char**) { |
| 38 | { |
| 39 | typedef std::multimap<int, double> C; |
| 40 | static_assert((std::is_same<C::key_type, int>::value), "" ); |
| 41 | static_assert((std::is_same<C::mapped_type, double>::value), "" ); |
| 42 | static_assert((std::is_same<C::value_type, std::pair<const int, double> >::value), "" ); |
| 43 | static_assert((std::is_same<C::key_compare, std::less<int> >::value), "" ); |
| 44 | static_assert((std::is_same<C::allocator_type, std::allocator<std::pair<const int, double> > >::value), "" ); |
| 45 | static_assert((std::is_same<C::reference, std::pair<const int, double>&>::value), "" ); |
| 46 | static_assert((std::is_same<C::const_reference, const std::pair<const int, double>&>::value), "" ); |
| 47 | static_assert((std::is_same<C::pointer, std::pair<const int, double>*>::value), "" ); |
| 48 | static_assert((std::is_same<C::const_pointer, const std::pair<const int, double>*>::value), "" ); |
| 49 | static_assert((std::is_same<C::size_type, std::size_t>::value), "" ); |
| 50 | static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "" ); |
| 51 | } |
| 52 | #if TEST_STD_VER >= 11 |
| 53 | { |
| 54 | typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C; |
| 55 | static_assert((std::is_same<C::key_type, int>::value), "" ); |
| 56 | static_assert((std::is_same<C::mapped_type, double>::value), "" ); |
| 57 | static_assert((std::is_same<C::value_type, std::pair<const int, double> >::value), "" ); |
| 58 | static_assert((std::is_same<C::key_compare, std::less<int> >::value), "" ); |
| 59 | static_assert((std::is_same<C::allocator_type, min_allocator<std::pair<const int, double> > >::value), "" ); |
| 60 | static_assert((std::is_same<C::reference, std::pair<const int, double>&>::value), "" ); |
| 61 | static_assert((std::is_same<C::const_reference, const std::pair<const int, double>&>::value), "" ); |
| 62 | static_assert((std::is_same<C::pointer, min_pointer<std::pair<const int, double>>>::value), "" ); |
| 63 | static_assert((std::is_same<C::const_pointer, min_pointer<const std::pair<const int, double>>>::value), "" ); |
| 64 | // min_allocator doesn't have a size_type, so one gets synthesized |
| 65 | static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "" ); |
| 66 | static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "" ); |
| 67 | } |
| 68 | #endif |
| 69 | |
| 70 | return 0; |
| 71 | } |
| 72 | |