You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
libcxx_old/test/libcxx/containers/unord/key_value_traits.pass.cpp

61 lines
2.3 KiB
C++

//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include <__hash_table>
#include <unordered_map>
#include <unordered_set>
#include <type_traits>
#include "test_macros.h"
#include "min_allocator.h"
void testKeyValueTrait() {
{
typedef int Tp;
typedef std::__hash_key_value_types<Tp> Traits;
static_assert((std::is_same<Traits::key_type, int>::value), "");
static_assert((std::is_same<Traits::__node_value_type, Tp>::value), "");
static_assert((std::is_same<Traits::__container_value_type, Tp>::value), "");
static_assert(Traits::__is_map == false, "");
}
{
typedef std::pair<int, int> Tp;
typedef std::__hash_key_value_types<Tp> Traits;
static_assert((std::is_same<Traits::key_type, Tp>::value), "");
static_assert((std::is_same<Traits::__node_value_type, Tp>::value), "");
static_assert((std::is_same<Traits::__container_value_type, Tp>::value), "");
static_assert(Traits::__is_map == false, "");
}
{
typedef std::pair<const int, int> Tp;
typedef std::__hash_key_value_types<Tp> Traits;
static_assert((std::is_same<Traits::key_type, Tp>::value), "");
static_assert((std::is_same<Traits::__node_value_type, Tp>::value), "");
static_assert((std::is_same<Traits::__container_value_type, Tp>::value), "");
static_assert(Traits::__is_map == false, "");
}
{
typedef std::__hash_value_type<int, int> Tp;
typedef std::__hash_key_value_types<Tp> Traits;
static_assert((std::is_same<Traits::key_type, int>::value), "");
static_assert((std::is_same<Traits::mapped_type, int>::value), "");
static_assert((std::is_same<Traits::__node_value_type, Tp>::value), "");
static_assert((std::is_same<Traits::__container_value_type,
std::pair<const int, int> >::value), "");
static_assert((std::is_same<Traits::__map_value_type,
std::pair<const int, int> >::value), "");
static_assert(Traits::__is_map == true, "");
}
}
int main(int, char**) {
testKeyValueTrait();
return 0;
}