brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · a117884 Raw
59 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include <__cxx03/__hash_table>10#include <unordered_map>11#include <unordered_set>12#include <type_traits>13 14#include "test_macros.h"15#include "min_allocator.h"16 17void testKeyValueTrait() {18  {19    typedef int Tp;20    typedef std::__hash_key_value_types<Tp> Traits;21    static_assert((std::is_same<Traits::key_type, int>::value), "");22    static_assert((std::is_same<Traits::__node_value_type, Tp>::value), "");23    static_assert((std::is_same<Traits::__container_value_type, Tp>::value), "");24    static_assert(Traits::__is_map == false, "");25  }26  {27    typedef std::pair<int, int> Tp;28    typedef std::__hash_key_value_types<Tp> Traits;29    static_assert((std::is_same<Traits::key_type, Tp>::value), "");30    static_assert((std::is_same<Traits::__node_value_type, Tp>::value), "");31    static_assert((std::is_same<Traits::__container_value_type, Tp>::value), "");32    static_assert(Traits::__is_map == false, "");33  }34  {35    typedef std::pair<const int, int> Tp;36    typedef std::__hash_key_value_types<Tp> Traits;37    static_assert((std::is_same<Traits::key_type, Tp>::value), "");38    static_assert((std::is_same<Traits::__node_value_type, Tp>::value), "");39    static_assert((std::is_same<Traits::__container_value_type, Tp>::value), "");40    static_assert(Traits::__is_map == false, "");41  }42  {43    typedef std::__hash_value_type<int, int> Tp;44    typedef std::__hash_key_value_types<Tp> Traits;45    static_assert((std::is_same<Traits::key_type, int>::value), "");46    static_assert((std::is_same<Traits::mapped_type, int>::value), "");47    static_assert((std::is_same<Traits::__node_value_type, Tp>::value), "");48    static_assert((std::is_same<Traits::__container_value_type, std::pair<const int, int> >::value), "");49    static_assert((std::is_same<Traits::__map_value_type, std::pair<const int, int> >::value), "");50    static_assert(Traits::__is_map == true, "");51  }52}53 54int main(int, char**) {55  testKeyValueTrait();56 57  return 0;58}59