Aleph-w
3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
hash_restriction_test.cc
Go to the documentation of this file.
1
2
#include <gtest/gtest.h>
3
#include <
hash-fct.H
>
4
#include <string>
5
#include <type_traits>
6
#include <utility>
7
#include <vector>
8
9
using namespace
Aleph
;
10
11
// This test doesn't actually run anything, it just checks for compilation
12
// behavior (via type traits and decltype if needed, but here we can just
13
// use a compile-time check for the existence of the overload)
14
15
template
<
typename
T,
typename
=
void
>
16
struct
is_hashable
: std::false_type {};
17
18
template
<
typename
T>
19
struct
is_hashable
<
T
,
std
::
void_t
<decltype(fnv_hash(std::declval<T>()))>> : std::true_type {};
20
21
TEST
(
HashRestrictionTest
,
TriviallyCopyableTypesAreHashable
)
22
{
23
EXPECT_TRUE
(
is_hashable<int>::value
);
24
EXPECT_TRUE
(
is_hashable<double>::value
);
25
26
struct
Simple
{
int
a;
char
b; };
27
EXPECT_TRUE
(
is_hashable<Simple>::value
);
28
}
29
30
TEST
(
HashRestrictionTest
,
NonTriviallyCopyableTypesAreNotHashable
)
31
{
32
// std::vector is NOT trivially copyable
33
EXPECT_FALSE
(
is_hashable
<std::vector<int>>
::value
);
34
}
35
36
TEST
(
HashRestrictionTest
,
SpecialOverloadsStillWork
)
37
{
38
// std::string is NOT trivially copyable, but has a special overload
39
EXPECT_TRUE
(
is_hashable<std::string>::value
);
40
41
// const char* is a pointer (trivially copyable) and has overloads
42
EXPECT_TRUE
(
is_hashable<const char*>::value
);
43
}
value
size_t size_t int32_t value
Definition
ca-c-api.h:116
TEST
#define TEST(name)
Definition
disjoint_sparse_table_test.cc:95
Aleph::blossom_maximum_cardinality_matching
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Definition
Blossom.H:466
hash-fct.H
Standard hash functions for Aleph types.
Aleph
Main namespace for Aleph-w library functions.
Definition
ah-arena.H:89
Aleph::T
std::decay_t< typename HeadC::Item_Type > T
Definition
ah-zip.H:105
std
STL namespace.
is_hashable
Definition
hash_restriction_test.cc:16
Tests
hash_restriction_test.cc
Generated by
1.9.8