| 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 |
#include <__cxx03/__tree> |
| 10 |
#include <map> |
| 11 |
#include <set> |
| 12 |
#include <type_traits> |
| 13 |
|
| 14 |
#include "test_macros.h" |
| 15 |
#include "min_allocator.h" |
| 16 |
|
| 17 |
void testKeyValueTrait() { |
| 18 |
{ |
| 19 |
typedef int Tp; |
| 20 |
typedef std::__tree_key_value_types<Tp> Traits; |
| 21 |
static_assert((std::is_same<Traits::key_type, int>::value), ""); |
| 22 |
static_assert((std::is_same<Traits::__container_value_type, Tp>::value), ""); |
| 23 |
static_assert(Traits::__is_map == false, ""); |
| 24 |
} |
| 25 |
{ |
| 26 |
typedef std::pair<int, int> Tp; |
| 27 |
typedef std::__tree_key_value_types<Tp> Traits; |
| 28 |
static_assert((std::is_same<Traits::key_type, Tp>::value), ""); |
| 29 |
static_assert((std::is_same<Traits::__container_value_type, Tp>::value), ""); |
| 30 |
static_assert(Traits::__is_map == false, ""); |
| 31 |
} |
| 32 |
{ |
| 33 |
typedef std::pair<const int, int> Tp; |
| 34 |
typedef std::__tree_key_value_types<Tp> Traits; |
| 35 |
static_assert((std::is_same<Traits::key_type, Tp>::value), ""); |
| 36 |
static_assert((std::is_same<Traits::__container_value_type, Tp>::value), ""); |
| 37 |
static_assert(Traits::__is_map == false, ""); |
| 38 |
} |
| 39 |
{ |
| 40 |
typedef std::__value_type<int, int> Tp; |
| 41 |
typedef std::__tree_key_value_types<Tp> Traits; |
| 42 |
static_assert((std::is_same<Traits::key_type, int>::value), ""); |
| 43 |
static_assert((std::is_same<Traits::mapped_type, int>::value), ""); |
| 44 |
static_assert((std::is_same<Traits::__container_value_type, std::pair<const int, int> >::value), ""); |
| 45 |
static_assert((std::is_same<Traits::__map_value_type, std::pair<const int, int> >::value), ""); |
| 46 |
static_assert(Traits::__is_map == true, ""); |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
int main(int, char**) { |
| 51 |
testKeyValueTrait(); |
| 52 |
|
| 53 |
return 0; |
| 54 |
} |