blob: 3185cad34bd3a2eb3ff0e47eefdb8af6b5b1bec9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <cmath>
#include <limits>
#include <vespa/vespalib/stllike/string.h>
namespace search {
namespace attribute {
// for all integers
template <typename T>
constexpr T getUndefined() {
return std::numeric_limits<T>::min();
}
template <>
inline constexpr float getUndefined<float>() {
return -std::numeric_limits<float>::quiet_NaN();
}
template <>
inline constexpr double getUndefined<double>() {
return -std::numeric_limits<double>::quiet_NaN();
}
// for all signed integers
template <typename T>
bool isUndefined(const T & value) {
return value == getUndefined<T>();
}
template <>
inline bool isUndefined<uint8_t>(const uint8_t &) {
return false;
}
template <>
inline bool isUndefined<uint16_t>(const uint16_t &) {
return false;
}
template <>
inline bool isUndefined<uint32_t>(const uint32_t &) {
return false;
}
template <>
inline bool isUndefined<uint64_t>(const uint64_t &) {
return false;
}
template <>
inline bool isUndefined<float>(const float & value) {
return std::isnan(value);
}
template <>
inline bool isUndefined<double>(const double & value) {
return std::isnan(value);
}
template <>
inline bool isUndefined<vespalib::string>(const vespalib::string & value) {
return value.empty();
}
}
}
|